summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/synaptics.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/synaptics.c b/src/synaptics.c
index 56dc55b..e00604b 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -2785,10 +2785,11 @@ clickpad_guess_clickfingers(SynapticsPrivate * priv,
int nfingers = 0;
#if HAVE_MULTITOUCH
- char close_point[SYNAPTICS_MAX_TOUCHES] = { 0 }; /* 1 for each point close
- to another one */
+ uint32_t close_point = 0; /* 1 bit for each point close to another one */
int i, j;
+ BUG_RETURN_VAL(hw->num_mt_mask > sizeof(close_point) * 8, 0);
+
for (i = 0; i < hw->num_mt_mask - 1; i++) {
ValuatorMask *f1;
@@ -2820,14 +2821,16 @@ clickpad_guess_clickfingers(SynapticsPrivate * priv,
* size. Good luck. */
if (abs(x1 - x2) < (priv->maxx - priv->minx) * .3 &&
abs(y1 - y2) < (priv->maxy - priv->miny) * .3) {
- close_point[j] = 1;
- close_point[i] = 1;
+ close_point |= (1 << j);
+ close_point |= (1 << i);
}
}
}
- for (i = 0; i < SYNAPTICS_MAX_TOUCHES; i++)
- nfingers += close_point[i];
+ while (close_point > 0) {
+ nfingers += close_point & 0x1;
+ close_point >>= 1;
+ }
#endif
return nfingers;