[PATCH synaptics] Don't count fingers twice when guessing distance (#48316)

Peter Hutterer peter.hutterer at who-t.net
Tue Apr 10 17:03:20 PDT 2012


A finger may be closer than the required distance to more than one finger.
e.g. for fingers A, B, C, AC and BC could both trigger the check and count
C twice.

Avoid double-counting by marking those fingers already close enough to a
previous finger to avoid overcounting.

X.Org Bug 48316 <http://bugs.freedesktop.org/show_bug.cgi?id=48316>

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/synaptics.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/src/synaptics.c b/src/synaptics.c
index 918dc6f..0e10aeb 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -2624,7 +2624,9 @@ clickpad_guess_clickfingers(SynapticsPrivate *priv, struct SynapticsHwState *hw)
 {
     int nfingers = 0;
 #if HAVE_MULTITOUCH
+    int skip[SYNAPTICS_MAX_TOUCHES] = {0};
     int i, j;
+
     for (i = 0; i < hw->num_mt_mask - 1; i++) {
         ValuatorMask *f1;
 
@@ -2642,6 +2644,9 @@ clickpad_guess_clickfingers(SynapticsPrivate *priv, struct SynapticsHwState *hw)
                 hw->slot_state[j] == SLOTSTATE_CLOSE)
                 continue;
 
+            if (skip[j])
+                continue;
+
             f2 = hw->mt_mask[j];
 
             x1 = valuator_mask_get_double(f1, 0);
@@ -2655,8 +2660,10 @@ clickpad_guess_clickfingers(SynapticsPrivate *priv, struct SynapticsHwState *hw)
              * you'll need to find a touchpad that doesn't lie about it's
              * size. Good luck. */
             if (abs(x1 - x2) < (priv->maxx - priv->minx) * .3 &&
-                abs(y1 - y2) < (priv->maxy - priv->miny) * .3)
+                abs(y1 - y2) < (priv->maxy - priv->miny) * .3) {
                 nfingers++;
+                skip[j] = 1;
+            }
         }
     }
 #endif
-- 
1.7.7.6


More information about the xorg-devel mailing list