[PATCH libinput 1/2] evdev: force-assign 10 slots to evdev devices

Peter Hutterer peter.hutterer at who-t.net
Tue Feb 24 23:37:25 PST 2015


If the device doesn't have any slots, mtdev->caps.slot.maximum is 0. Since we
only use mtdev if we don't have slots, this caused protocol A devices to
always fail.

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

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/evdev.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/evdev.c b/src/evdev.c
index cf21d2e..a0c020b 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -524,6 +524,14 @@ evdev_process_touch(struct evdev_device *device,
 {
 	switch (e->code) {
 	case ABS_MT_SLOT:
+		if ((size_t)e->value >= device->mt.slots_len) {
+			log_bug_libinput(device->base.seat->libinput,
+					 "%s exceeds slots (%d of %d)\n",
+					 device->devname,
+					 e->value,
+					 device->mt.slots_len);
+			e->value = device->mt.slots_len - 1;
+		}
 		evdev_flush_pending_event(device, time);
 		device->mt.slot = e->value;
 		break;
@@ -1467,10 +1475,9 @@ evdev_configure_device(struct evdev_device *device)
 				if (!device->mtdev)
 					return -1;
 
-				num_slots = device->mtdev->caps.slot.maximum;
-				if (device->mtdev->caps.slot.minimum < 0 ||
-				    num_slots <= 0)
-					return -1;
+				/* pick 10 slots as default for type A
+				   devices. */
+				num_slots = 10;
 				active_slot = device->mtdev->caps.slot.value;
 			} else {
 				num_slots = libevdev_get_num_slots(device->evdev);
-- 
2.1.0



More information about the wayland-devel mailing list