From f04f58213fb50dbeeafb7f4a465bb9b3fc3632e0 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 5 Nov 2014 11:01:45 +1000 Subject: [PATCH] evdev: handle fake MT devices 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 Reviewed-by: Hans de Goede --- src/evdev.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/evdev.c b/src/evdev.c index 234a1d52..3346b543 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -1095,7 +1095,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,