On 04/10/2012 05:03 PM, Peter Hutterer wrote: > 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.
The above description actually results in the correct count for three touches. A better description would mention the case where AC, BC, and AB are all close enough to trigger the check, in which case we have too many fingers. > 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 <[email protected]> > --- > 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 I think we would get the same results if we merely added a "break;" after "nfingers++;". This would ensure we only increment the finger count once for each outer loop iteration. In the example, we would see AB, and BC, but not AC because we broke out of the inner loop after AB. -- Chase _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
