[PATCH v2 libinput] evdev: only reject devices with missing MT x/y if they're MT devices

Peter Hutterer peter.hutterer at who-t.net
Thu Jan 7 16:51:21 PST 2016


A fake MT device may have ABS_MT_POSITION_X but not Y. In this case we don't
care, because we don't handle those axes anyway.

http://bugs.freedesktop.org/show_bug.cgi?id=93474

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
Changes to v1:
- reduce to the hunk that actually matters. sorry, not sure what happened
  there, some rebase gone wrong of my original approach and I didn't notice
  it before sending it.

 src/evdev.c      |  3 ++-
 test/Makefile.am |  1 +
 test/device.c    | 31 +++++++++++++++++++++++++++++++
 test/litest.c    |  2 ++
 test/litest.h    |  1 +
 5 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/src/evdev.c b/src/evdev.c
index 3708072..df5fee3 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1868,7 +1868,8 @@ evdev_reject_device(struct evdev_device *device)
 	    libevdev_has_event_code(evdev, EV_REL, REL_Y))
 		return -1;
 
-	if (libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_X) ^
+	if (!evdev_is_fake_mt_device(device) &&
+	    libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_X) ^
 	    libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_Y))
 		return -1;
 
diff --git a/test/Makefile.am b/test/Makefile.am
index e4ed8e5..1b3090e 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -15,6 +15,7 @@ liblitest_la_SOURCES = \
 	litest-int.h \
 	litest-device-alps-semi-mt.c \
 	litest-device-alps-dualpoint.c \
+	litest-device-anker-mouse-kbd.c \
 	litest-device-asus-rog-gladius.c \
 	litest-device-atmel-hover.c \
 	litest-device-bcm5974.c \
diff --git a/test/device.c b/test/device.c
index b7fa0e0..03659ac 100644
--- a/test/device.c
+++ b/test/device.c
@@ -1254,6 +1254,35 @@ START_TEST(device_abs_rel)
 }
 END_TEST
 
+START_TEST(device_quirks_no_abs_mt_y)
+{
+	struct litest_device *dev = litest_current_device();
+	struct libinput *li = dev->libinput;
+	struct libinput_event *event;
+	struct libinput_event_pointer *pev;
+	int code;
+
+	litest_drain_events(li);
+
+	litest_event(dev, EV_REL, REL_HWHEEL, 1);
+	litest_event(dev, EV_SYN, SYN_REPORT, 0);
+	libinput_dispatch(li);
+
+	event = libinput_get_event(li);
+	pev = litest_is_axis_event(event,
+				   LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL,
+				   LIBINPUT_POINTER_AXIS_SOURCE_WHEEL);
+	libinput_event_destroy(libinput_event_pointer_get_base_event(pev));
+
+	for (code = ABS_MISC + 1; code < ABS_MAX; code++) {
+		litest_event(dev, EV_ABS, code, 1);
+		litest_event(dev, EV_SYN, SYN_REPORT, 0);
+		litest_assert_empty_queue(li);
+	}
+
+}
+END_TEST
+
 void
 litest_setup_tests(void)
 {
@@ -1308,4 +1337,6 @@ litest_setup_tests(void)
 	litest_add_no_device("device:invalid rel events", device_touchpad_rel);
 	litest_add_no_device("device:invalid rel events", device_touch_rel);
 	litest_add_no_device("device:invalid rel events", device_abs_rel);
+
+	litest_add_for_device("device:quirks", device_quirks_no_abs_mt_y, LITEST_ANKER_MOUSE_KBD);
 }
diff --git a/test/litest.c b/test/litest.c
index fc188b6..e51004e 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -367,6 +367,7 @@ extern struct litest_test_device litest_magicpad_device;
 extern struct litest_test_device litest_elantech_touchpad_device;
 extern struct litest_test_device litest_mouse_gladius_device;
 extern struct litest_test_device litest_mouse_wheel_click_angle_device;
+extern struct litest_test_device litest_anker_mouse_kbd_device;
 
 struct litest_test_device* devices[] = {
 	&litest_synaptics_clickpad_device,
@@ -400,6 +401,7 @@ struct litest_test_device* devices[] = {
 	&litest_elantech_touchpad_device,
 	&litest_mouse_gladius_device,
 	&litest_mouse_wheel_click_angle_device,
+	&litest_anker_mouse_kbd_device,
 	NULL,
 };
 
diff --git a/test/litest.h b/test/litest.h
index 1268e10..be270ee 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -144,6 +144,7 @@ enum litest_device_type {
 	LITEST_ELANTECH_TOUCHPAD = -30,
 	LITEST_MOUSE_GLADIUS = -31,
 	LITEST_MOUSE_WHEEL_CLICK_ANGLE = -32,
+	LITEST_ANKER_MOUSE_KBD = -33,
 };
 
 enum litest_device_feature {
-- 
2.5.0



More information about the wayland-devel mailing list