From c874fed3481638155a23601ce65985b2d0283e9c Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 22 Jun 2017 09:11:15 +1000 Subject: [PATCH 1/2] udev: consider a device with BTN_TRIGGER_HAPPY as joystick These buttons were added specifically for joysticks with lots of buttons, no other device should be using them. See kernel commit cf2f765f18960 "HID: handle joysticks with large number of buttons" We only test for BTN_TRIGGER_HAPPY (an alias for BTN_TRIGGER_HAPPY1) here, a device that sets buttons 2 and above but doesn't set 1 is considered buggy. https://github.com/systemd/systemd/issues/6137 Signed-off-by: Peter Hutterer --- src/udev/udev-builtin-input_id.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/udev/udev-builtin-input_id.c b/src/udev/udev-builtin-input_id.c index 4303b2593d..7ea86b21b8 100644 --- a/src/udev/udev-builtin-input_id.c +++ b/src/udev/udev-builtin-input_id.c @@ -206,6 +206,7 @@ static bool test_pointers(struct udev_device *dev, * rudders/pedals are joystick-like, but buttonless; they have * other fancy axes */ has_joystick_axes_or_buttons = test_bit(BTN_TRIGGER, bitmask_key) || + test_bit(BTN_TRIGGER_HAPPY, bitmask_key) || test_bit(BTN_A, bitmask_key) || test_bit(BTN_1, bitmask_key) || test_bit(ABS_RX, bitmask_abs) || From 2e856c63d466455f91bed3046265beffb5235044 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 22 Jun 2017 09:19:32 +1000 Subject: [PATCH 2/2] udev: always consider devices with joystick axes/buttons as joystick Even when they don't have an x/y axis. https://github.com/systemd/systemd/issues/6137 Signed-off-by: Peter Hutterer --- src/udev/udev-builtin-input_id.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/udev/udev-builtin-input_id.c b/src/udev/udev-builtin-input_id.c index 7ea86b21b8..47f41a6607 100644 --- a/src/udev/udev-builtin-input_id.c +++ b/src/udev/udev-builtin-input_id.c @@ -204,7 +204,7 @@ static bool test_pointers(struct udev_device *dev, has_touch = test_bit(BTN_TOUCH, bitmask_key); /* joysticks don't necessarily have buttons; e. g. * rudders/pedals are joystick-like, but buttonless; they have - * other fancy axes */ + * other fancy axes. Others have buttons only but no axes. */ has_joystick_axes_or_buttons = test_bit(BTN_TRIGGER, bitmask_key) || test_bit(BTN_TRIGGER_HAPPY, bitmask_key) || test_bit(BTN_A, bitmask_key) || @@ -231,7 +231,10 @@ static bool test_pointers(struct udev_device *dev, is_touchscreen = true; else if (has_joystick_axes_or_buttons) is_joystick = true; + } else if (has_joystick_axes_or_buttons) { + is_joystick = true; } + if (has_mt_coordinates) { if (stylus_or_pen) is_tablet = true;