[PATCH libinput 3/4] evdev: handle fake MT devices

Peter Hutterer peter.hutterer at who-t.net
Tue Nov 4 20:44:25 PST 2014


The kernel requires absolute axes to fit into the semantic ABS_ naming
scheme but doesn't provide enough free bits unlabelled axes. Devices with many
axes run into the ABS_MT range and look like MT devices when they're not.
See http://www.freedesktop.org/software/libevdev/doc/1.3/group__mt.html

Affected is e.g. the MS Surface 2 touch cover that has codes [41, 62]
set for min/max [-127, 127].

No special handling needed other than forcing has_mt/has_touch to be 0.
ABS_MT_* events from non-touch devices are discarded by libinput.

The has_mt/has_touch = 0 isn't needed, but looks nicer than an empty if
body.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=85836

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
CC: Leonid Borisenko <leo.borisenko at gmail.com>
---
 src/evdev.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/evdev.c b/src/evdev.c
index bda6af4..6dad32a 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1096,7 +1096,15 @@ evdev_configure_device(struct evdev_device *device)
 			device->abs.absinfo_y = absinfo;
 			has_abs = 1;
 		}
-		if (libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_X) &&
+
+		/* Fake MT devices have the ABS_MT_SLOT bit set because of
+		   the limited ABS_* range - they aren't MT devices, they
+		   just have too many ABS_ axes */
+		if (libevdev_has_event_code(evdev, EV_ABS, ABS_MT_SLOT) &&
+		    libevdev_get_num_slots(evdev) == -1) {
+			has_mt = 0;
+			has_touch = 0;
+		} else if (libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_X) &&
 		    libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_Y)) {
 			absinfo = libevdev_get_abs_info(evdev, ABS_MT_POSITION_X);
 			if (evdev_fix_abs_resolution(evdev,
-- 
2.1.0



More information about the wayland-devel mailing list