[xorg-x11-drv-synaptics/f21] Discard jumps of more than 20mm (#1130656)
Peter Hutterer
whot at fedoraproject.org
Wed Sep 17 21:51:21 UTC 2014
commit 1122c435ec56159f1d746c70ae9e207aea4e06d1
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date: Thu Sep 18 07:39:42 2014 +1000
Discard jumps of more than 20mm (#1130656)
0001-Limit-the-movement-to-20-mm-per-event.patch | 113 ++++++++++++++++++++++
xorg-x11-drv-synaptics.spec | 6 +-
2 files changed, 118 insertions(+), 1 deletions(-)
---
diff --git a/0001-Limit-the-movement-to-20-mm-per-event.patch b/0001-Limit-the-movement-to-20-mm-per-event.patch
new file mode 100644
index 0000000..f33521e
--- /dev/null
+++ b/0001-Limit-the-movement-to-20-mm-per-event.patch
@@ -0,0 +1,113 @@
+From 711e3d89ef167cd37d5e1966d9919e51da0aaefc Mon Sep 17 00:00:00 2001
+From: Peter Hutterer <peter.hutterer at who-t.net>
+Date: Tue, 16 Sep 2014 08:52:56 +1000
+Subject: [PATCH synaptics] Limit the movement to 20 mm per event
+
+Touchpads are limited by a fixed sampling rate (usually 80Hz). Some finger
+changes may happen too fast for this sampling rate, resulting in two distinct
+event sequences:
+* finger 1 up and finger 2 down in the same EV_SYN frame. Synaptics sees one
+ finger down before and after and the changed coordinates
+* finger 1 up and finger 2 down _between_ two EV_SYN frames. Synaptics sees one
+ touchpoint move from f1 position to f2 position.
+
+That move causes a large cursor jump. The former could be solved (with
+difficulty) by adding fake EV_SYN handling after releasing touchpoints but
+that won't fix the latter case.
+
+So as a solution for now limit the finger movement to 20mm per event.
+Tests on a T440 and an x220 showed that this is just above what a reasonable
+finger movement would trigger. If a movement is greater than that limit, reset
+it to 0/0.
+
+On devices without resolution, use 0.25 of the touchpad's diagonal instead.
+
+Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
+Reviewed-by: Hans de Goede <hdegoede at redhat.com>
+(cherry picked from commit 41b2312c006fca1f24e1a366174d3203a63fa04a)
+---
+ src/synaptics.c | 33 +++++++++++++++++++++++++++++++++
+ src/synapticsstr.h | 2 ++
+ 2 files changed, 35 insertions(+)
+
+diff --git a/src/synaptics.c b/src/synaptics.c
+index b49957c..127c7e8 100644
+--- a/src/synaptics.c
++++ b/src/synaptics.c
+@@ -770,6 +770,23 @@ set_default_parameters(InputInfoPtr pInfo)
+ pars->resolution_vert =
+ xf86SetIntOption(opts, "VertResolution", vertResolution);
+
++ /* Touchpad sampling rate is too low to detect all movements.
++ A user may lift one finger and put another one down within the same
++ EV_SYN or even between samplings so the driver doesn't notice at all.
++
++ We limit the movement to 20 mm within one event, that is more than
++ recordings showed is needed (17mm on a T440).
++ */
++ if (pars->resolution_horiz > 1 &&
++ pars->resolution_vert > 1)
++ pars->maxDeltaMM = 20;
++ else {
++ /* on devices without resolution set the vector length to 0.25 of
++ the touchpad diagonal */
++ pars->maxDeltaMM = diag * 0.25;
++ }
++
++
+ /* Warn about (and fix) incorrectly configured TopEdge/BottomEdge parameters */
+ if (pars->top_edge > pars->bottom_edge) {
+ int tmp = pars->top_edge;
+@@ -2213,6 +2230,13 @@ get_delta(SynapticsPrivate *priv, const struct SynapticsHwState *hw,
+ *dy = integral;
+ }
+
++/* Vector length, but not sqrt'ed, we only need it for comparison */
++static inline double
++vlenpow2(double x, double y)
++{
++ return x * x + y * y;
++}
++
+ /**
+ * Compute relative motion ('deltas') including edge motion.
+ */
+@@ -2222,6 +2246,7 @@ ComputeDeltas(SynapticsPrivate * priv, const struct SynapticsHwState *hw,
+ {
+ enum MovingState moving_state;
+ double dx, dy;
++ double vlen;
+ int delay = 1000000000;
+
+ dx = dy = 0;
+@@ -2267,6 +2292,14 @@ ComputeDeltas(SynapticsPrivate * priv, const struct SynapticsHwState *hw,
+ out:
+ priv->prevFingers = hw->numFingers;
+
++ vlen = vlenpow2(dx/priv->synpara.resolution_horiz,
++ dy/priv->synpara.resolution_vert);
++
++ if (vlen > priv->synpara.maxDeltaMM * priv->synpara.maxDeltaMM) {
++ dx = 0;
++ dy = 0;
++ }
++
+ *dxP = dx;
+ *dyP = dy;
+
+diff --git a/src/synapticsstr.h b/src/synapticsstr.h
+index 4bd32ac..75f52d5 100644
+--- a/src/synapticsstr.h
++++ b/src/synapticsstr.h
+@@ -226,6 +226,8 @@ typedef struct _SynapticsParameters {
+ int area_left_edge, area_right_edge, area_top_edge, area_bottom_edge; /* area coordinates absolute */
+ int softbutton_areas[4][4]; /* soft button area coordinates, 0 => right, 1 => middle , 2 => secondary right, 3 => secondary middle button */
+ int hyst_x, hyst_y; /* x and y width of hysteresis box */
++
++ int maxDeltaMM; /* maximum delta movement (vector length) in mm */
+ } SynapticsParameters;
+
+ struct _SynapticsPrivateRec {
+--
+1.9.3
+
diff --git a/xorg-x11-drv-synaptics.spec b/xorg-x11-drv-synaptics.spec
index 14425c2..2822714 100644
--- a/xorg-x11-drv-synaptics.spec
+++ b/xorg-x11-drv-synaptics.spec
@@ -8,7 +8,7 @@
Name: xorg-x11-drv-synaptics
Summary: Xorg X11 Synaptics touchpad input driver
Version: 1.8.0
-Release: 8%{?gitdate:.%{gitdate}git%{gitversion}}%{?dist}
+Release: 9%{?gitdate:.%{gitdate}git%{gitversion}}%{?dist}
URL: http://www.x.org
License: MIT
Group: User Interface/X Hardware Support
@@ -27,6 +27,7 @@ Patch01: 0001-conf-increase-top-software-button-area-to-15.patch
Patch02: 0002-Prevent-two-finger-taps-from-being-ignored.patch
Patch03: 0001-Include-xorg-server.h-to-fix-build-errors-on-newest-.patch
Patch04: 0001-eventcomm-ensure-we-re-on-the-same-clock-as-the-serv.patch
+Patch05: 0001-Limit-the-movement-to-20-mm-per-event.patch
ExcludeArch: s390 s390x
@@ -145,6 +146,9 @@ Development files for the Synaptics TouchPad for X.Org.
%changelog
+* Thu Sep 18 2014 Peter Hutterer <peter.hutterer at redhat.com> 1.8.0-9
+- Discard jumps of more than 20mm (#1130656)
+
* Tue Sep 09 2014 Peter Hutterer <peter.hutterer at redhat.com> 1.8.0-8
- Apply (and fix conflicts with) the clockdrift patch
- Use git to apply patches so I don't always forget to add them
More information about the scm-commits
mailing list