summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Gerecke <jason.gerecke@wacom.com>2019-07-24 13:26:34 -0700
committerJason Gerecke <killertofu@gmail.com>2019-09-04 09:43:04 -0700
commit73c0fdb41eeea00667029d5eea1129c0ad14e17e (patch)
tree370015a64ec4bb07d3bf0e2a0b31631876f5acee
parent8cc538503cdadcf6e4801c53a6ad1badc8c7e2d4 (diff)
downloadxf86-input-wacom-73c0fdb41eeea00667029d5eea1129c0ad14e17e.tar.gz
Do not start scroll gesture if fingers are moving opposite directions
The driver sometimes has difficulty distinguishing scroll and zoom gestures. This is caused by a combination of the zoom spread distance being larger than the scroll distance and the "pointsInLine" checks being blind to fingers moving in opposite directions. Zoom gestures that have fingers moving in opposite directions along the same axis are especially likely to be misinterpreted as a scroll. To improve recognition accuracy, this commit adds a function that verifies the two fingers are actually moving in the same direction. As long as the motion vectors for the two fingers are more than 90 degrees apart, scrolling will be inhibited. The allowed difference could be significantly reduced if necessary, but this seems to do the trick for me. Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
-rw-r--r--src/wcmTouchFilter.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/wcmTouchFilter.c b/src/wcmTouchFilter.c
index 68382c8..c23b47e 100644
--- a/src/wcmTouchFilter.c
+++ b/src/wcmTouchFilter.c
@@ -189,6 +189,22 @@ static double touchDistance(WacomDeviceState ds0, WacomDeviceState ds1)
return distance;
}
+static Bool vectorsSameDirection(WacomCommonPtr common, WacomDeviceState ds00,
+ WacomDeviceState ds01, WacomDeviceState ds10, WacomDeviceState ds11)
+{
+ float dx0 = ds01.x - ds00.x;
+ float dy0 = ds01.y - ds00.y;
+ float m0 = sqrt(dx0*dx0 + dy0*dy0);
+ float dx1 = ds11.x - ds10.x;
+ float dy1 = ds11.y - ds10.y;
+ float m1 = sqrt(dx1*dx1 + dy1*dy1);
+
+ float dot = (dx0/m0 * dx1/m1) + (dy0/m0 * dy1/m1);
+ float angle = acos(dot);
+
+ return angle < (3.141592f / 2);
+}
+
static Bool pointsInLine(WacomCommonPtr common, WacomDeviceState ds0,
WacomDeviceState ds1)
{
@@ -644,7 +660,8 @@ static void wcmFingerScroll(WacomDevicePtr priv)
*/
if (pointsInLine(common, ds[0], start[0])
&& pointsInLine(common, ds[1], start[1])
- && common->wcmGestureParameters.wcmScrollDirection)
+ && common->wcmGestureParameters.wcmScrollDirection
+ && vectorsSameDirection(common, ds[0], start[0], ds[1], start[1]))
{
/* left button might be down. Send it up first */
wcmSendButtonClick(priv, 1, 0);