diff mbox

[1/3] Input: mt - prevent balanced slot assignment to assign twice the slot

Message ID 1427753368-2795-2-git-send-email-benjamin.tissoires@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Benjamin Tissoires March 30, 2015, 10:09 p.m. UTC
If two touches are under the dmax distance, it looks like they can now
be assigned to the same slot. Add a band aid to prevent such situation
and be able to use the balanced slot assignment.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
 drivers/input/input-mt.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c
index cb150a1..ad74f64 100644
--- a/drivers/input/input-mt.c
+++ b/drivers/input/input-mt.c
@@ -371,11 +371,16 @@  static void input_mt_set_slots(struct input_mt *mt,
 		*p = -1;
 
 	for (s = mt->slots; s != mt->slots + mt->num_slots; s++) {
+		bool found = false;
+
 		if (!input_mt_is_active(s))
 			continue;
 		for (p = slots; p != slots + num_pos; p++)
-			if (*w++ < 0)
+			if ((*w++ < 0) && !found) {
 				*p = s - mt->slots;
+				/* no break here: w won't be incremented */
+				found = true;
+			}
 	}
 
 	for (s = mt->slots; s != mt->slots + mt->num_slots; s++) {