[PATCH libinput v3 01/17] touchpad: set ntouches for single-touch pads depending on key bits

Hans de Goede hdegoede at redhat.com
Tue May 20 07:34:49 PDT 2014


From: Peter Hutterer <peter.hutterer at who-t.net>

A single-touch touchpad that provides BTN_TOOL_TRIPLETAP has 3 touches, etc.
There aren't a lot of these out there, but some touchpads don't have slots but
do provide two- or three-finger detection.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
Signed-off-by: Hans de Goede <hdegoede at redhat.com>
Reviewed-by: Jonas Ådahl <jadahl at gmail.com>
Reviewed-by: Hans de Goede <hdegoede at redhat.com>
---
 src/evdev-mt-touchpad.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 109441d..b4a89e3 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -715,9 +715,29 @@ tp_init_slots(struct tp_dispatch *tp,
 		tp->slot = absinfo->value;
 		tp->has_mt = true;
 	} else {
-		tp->ntouches = 5; /* FIXME: based on DOUBLETAP, etc. */
+		struct map {
+			unsigned int code;
+			int ntouches;
+		} max_touches[] = {
+			{ BTN_TOOL_QUINTTAP, 5 },
+			{ BTN_TOOL_QUADTAP, 4 },
+			{ BTN_TOOL_TRIPLETAP, 3 },
+			{ BTN_TOOL_DOUBLETAP, 2 },
+		};
+		struct map *m;
+
 		tp->slot = 0;
 		tp->has_mt = false;
+		tp->ntouches = 1;
+
+		ARRAY_FOR_EACH(max_touches, m) {
+			if (libevdev_has_event_code(device->evdev,
+						    EV_KEY,
+						    m->code)) {
+				tp->ntouches = m->ntouches;
+				break;
+			}
+		}
 	}
 	tp->touches = calloc(tp->ntouches,
 			     sizeof(struct tp_touch));
-- 
1.9.0



More information about the wayland-devel mailing list