[PATCH libinput 06/12] evdev: add quirk for Logitech Marble Mouse

Peter Hutterer peter.hutterer at who-t.net
Mon Feb 20 20:53:33 UTC 2017


Device needs BTN_MIDDLE disabled, this way middle button emulation is present
by default.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/evdev.c                        |  5 +++++
 src/evdev.h                        |  1 +
 test/test-device.c                 | 13 +++++++++++++
 test/test-pointer.c                | 14 ++++++++++++++
 udev/90-libinput-model-quirks.hwdb |  4 ++++
 5 files changed, 37 insertions(+)

diff --git a/src/evdev.c b/src/evdev.c
index 1b7d5a8..b1d2db2 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2261,6 +2261,7 @@ evdev_read_model_flags(struct evdev_device *device)
 		MODEL(HP_ZBOOK_STUDIO_G3),
 		MODEL(HP_PAVILION_DM4_TOUCHPAD),
 		MODEL(APPLE_TOUCHPAD_ONEBUTTON),
+		MODEL(LOGITECH_MARBLE_MOUSE),
 #undef MODEL
 		{ "ID_INPUT_TRACKBALL", EVDEV_MODEL_TRACKBALL },
 		{ NULL, EVDEV_MODEL_DEFAULT },
@@ -2858,6 +2859,10 @@ evdev_pre_configure_model_quirks(struct evdev_device *device)
 	 * https://bugs.freedesktop.org/show_bug.cgi?id=98100 */
 	if (device->model_flags & EVDEV_MODEL_HP_ZBOOK_STUDIO_G3)
 		libevdev_set_abs_maximum(device->evdev, ABS_MT_SLOT, 1);
+
+	/* Logitech Marble Mouse claims to have a middle button */
+	if (device->model_flags & EVDEV_MODEL_LOGITECH_MARBLE_MOUSE)
+		libevdev_disable_event_code(device->evdev, EV_KEY, BTN_MIDDLE);
 }
 
 struct evdev_device *
diff --git a/src/evdev.h b/src/evdev.h
index 967feaf..35eec84 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -126,6 +126,7 @@ enum evdev_device_model {
 	EVDEV_MODEL_HP_ZBOOK_STUDIO_G3 = (1 << 23),
 	EVDEV_MODEL_HP_PAVILION_DM4_TOUCHPAD = (1 << 24),
 	EVDEV_MODEL_APPLE_TOUCHPAD_ONEBUTTON = (1 << 25),
+	EVDEV_MODEL_LOGITECH_MARBLE_MOUSE = (1 << 26),
 };
 
 struct mt_slot {
diff --git a/test/test-device.c b/test/test-device.c
index 48ba55d..fdbab20 100644
--- a/test/test-device.c
+++ b/test/test-device.c
@@ -1482,6 +1482,18 @@ START_TEST(device_quirks_apple_magicmouse)
 }
 END_TEST
 
+START_TEST(device_quirks_logitech_marble_mouse)
+{
+	struct litest_device *dev = litest_current_device();
+	struct libinput *li = dev->libinput;
+
+	litest_drain_events(li);
+
+	ck_assert(!libinput_device_pointer_has_button(dev->libinput_device,
+						      BTN_MIDDLE));
+}
+END_TEST
+
 START_TEST(device_capability_at_least_one)
 {
 	struct litest_device *dev = litest_current_device();
@@ -1648,6 +1660,7 @@ litest_setup_tests_device(void)
 	litest_add_for_device("device:quirks", device_quirks_no_abs_mt_y, LITEST_ANKER_MOUSE_KBD);
 	litest_add_for_device("device:quirks", device_quirks_cyborg_rat_mode_button, LITEST_CYBORG_RAT);
 	litest_add_for_device("device:quirks", device_quirks_apple_magicmouse, LITEST_MAGICMOUSE);
+	litest_add_for_device("device:quirks", device_quirks_logitech_marble_mouse, LITEST_LOGITECH_TRACKBALL);
 
 	litest_add("device:capability", device_capability_at_least_one, LITEST_ANY, LITEST_ANY);
 	litest_add("device:capability", device_capability_check_invalid, LITEST_ANY, LITEST_ANY);
diff --git a/test/test-pointer.c b/test/test-pointer.c
index 27978a9..8929a0d 100644
--- a/test/test-pointer.c
+++ b/test/test-pointer.c
@@ -1161,6 +1161,19 @@ START_TEST(pointer_scroll_nowheel_defaults)
 }
 END_TEST
 
+START_TEST(pointer_scroll_defaults_logitech_marble)
+{
+	struct litest_device *dev = litest_current_device();
+	struct libinput_device *device = dev->libinput_device;
+	enum libinput_config_scroll_method method;
+
+	method = libinput_device_config_scroll_get_method(device);
+	ck_assert_int_eq(method, LIBINPUT_CONFIG_SCROLL_NO_SCROLL);
+	method = libinput_device_config_scroll_get_default_method(device);
+	ck_assert_int_eq(method, LIBINPUT_CONFIG_SCROLL_NO_SCROLL);
+}
+END_TEST
+
 START_TEST(pointer_accel_defaults)
 {
 	struct litest_device *dev = litest_current_device();
@@ -1939,6 +1952,7 @@ litest_setup_tests_pointer(void)
 	litest_add("pointer:scroll", pointer_scroll_button_no_event_before_timeout, LITEST_RELATIVE|LITEST_BUTTON, LITEST_ANY);
 	litest_add("pointer:scroll", pointer_scroll_button_middle_emulation, LITEST_RELATIVE|LITEST_BUTTON, LITEST_ANY);
 	litest_add("pointer:scroll", pointer_scroll_nowheel_defaults, LITEST_RELATIVE|LITEST_BUTTON, LITEST_WHEEL);
+	litest_add_for_device("pointer:scroll", pointer_scroll_defaults_logitech_marble , LITEST_LOGITECH_TRACKBALL);
 	litest_add("pointer:scroll", pointer_scroll_natural_defaults, LITEST_WHEEL, LITEST_TABLET);
 	litest_add("pointer:scroll", pointer_scroll_natural_defaults_noscroll, LITEST_ANY, LITEST_WHEEL);
 	litest_add("pointer:scroll", pointer_scroll_natural_enable_config, LITEST_WHEEL, LITEST_TABLET);
diff --git a/udev/90-libinput-model-quirks.hwdb b/udev/90-libinput-model-quirks.hwdb
index c1d6235..2ff50b6 100644
--- a/udev/90-libinput-model-quirks.hwdb
+++ b/udev/90-libinput-model-quirks.hwdb
@@ -169,6 +169,10 @@ libinput:name:SynPS/2 Synaptics TouchPad:dmi:*svnLENOVO:*:pvrThinkPadX1Carbon3rd
 libinput:name:*Logitech M570*:dmi:*
  LIBINPUT_MODEL_TRACKBALL=1
 
+# Logitech Marble Mouse trackball
+libinput:mouse:input:b0003v046DpC408*
+ LIBINPUT_MODEL_LOGITECH_MARBLE_MOUSE=1
+
 ##########################################
 # Microsoft
 ##########################################
-- 
2.9.3



More information about the wayland-devel mailing list