tablet: clear tablet history on tool contact change

On some ELAN tablets we get a coordinate jump in the same frame that we put
the tip down. The existing axis smoothing causes that jump to be somewhere in
the middle between the previous and the next coordinates, causing a small
stroke from the smoothed position to the next. Prevent this by resetting the
history on tip down/up so we always take that coordinate.

Fixes #94

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
jeff 2018-07-30 13:03:03 -04:00 committed by Peter Hutterer
parent 4ee1eb3c26
commit 326b2e3261

View file

@ -657,6 +657,14 @@ tablet_check_notify_axes(struct tablet_dispatch *tablet,
rc = true;
out:
/* The tool position often jumps to a different spot when contact changes.
* If tool contact changes, clear the history to prevent axis smoothing
* from trying to average over the spatial discontinuity. */
if (tablet_has_status(tablet, TABLET_TOOL_ENTERING_CONTACT) ||
tablet_has_status(tablet, TABLET_TOOL_LEAVING_CONTACT)) {
tablet_history_reset(tablet);
}
tablet_history_push(tablet, &tablet->axes);
tablet_smoothen_axes(tablet, &axes);