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 <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
Peter Hutterer 2014-11-05 11:01:45 +10:00
parent 01cc70ff58
commit f04f58213f

View file

@ -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,