]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: don't label high-button mice as joysticks (#8493)
authorPeter Hutterer <peter.hutterer@who-t.net>
Fri, 23 Mar 2018 14:15:41 +0000 (00:15 +1000)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 23 Mar 2018 14:15:41 +0000 (15:15 +0100)
If a device exposes more than 16 mouse buttons, we run into the BTN_JOYSTICK
range, also labelling it as joystick. And since 774ff9b this results in only
ID_INPUT_JOYSTICK but no ID_INPUT_MOUSE.

Fixes #8460

src/udev/udev-builtin-input_id.c

index 02b86cce239eb2ebbf80302c47ca9336b9882cac..4d5b1233f17fcd312af5b01d5e0f9beef38848e4 100644 (file)
@@ -195,15 +195,23 @@ static bool test_pointers(struct udev_device *dev,
                 has_mt_coordinates = false;
         is_direct = test_bit(INPUT_PROP_DIRECT, bitmask_props);
         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. Others have buttons only but no axes. */
-        for (button = BTN_JOYSTICK; button < BTN_DIGI && !has_joystick_axes_or_buttons; button++)
-                has_joystick_axes_or_buttons = test_bit(button, bitmask_key);
-        for (button = BTN_TRIGGER_HAPPY1; button <= BTN_TRIGGER_HAPPY40 && !has_joystick_axes_or_buttons; button++)
-                has_joystick_axes_or_buttons = test_bit(button, bitmask_key);
-        for (button = BTN_DPAD_UP; button <= BTN_DPAD_RIGHT && !has_joystick_axes_or_buttons; button++)
-                has_joystick_axes_or_buttons = test_bit(button, bitmask_key);
+         * other fancy axes. Others have buttons only but no axes.
+         *
+         * The BTN_JOYSTICK range starts after the mouse range, so a mouse
+         * with more than 16 buttons runs into the joystick range (e.g. Mad
+         * Catz Mad Catz M.M.O.TE). Skip those.
+         */
+        if (!test_bit(BTN_JOYSTICK - 1, bitmask_key)) {
+                for (button = BTN_JOYSTICK; button < BTN_DIGI && !has_joystick_axes_or_buttons; button++)
+                        has_joystick_axes_or_buttons = test_bit(button, bitmask_key);
+                for (button = BTN_TRIGGER_HAPPY1; button <= BTN_TRIGGER_HAPPY40 && !has_joystick_axes_or_buttons; button++)
+                        has_joystick_axes_or_buttons = test_bit(button, bitmask_key);
+                for (button = BTN_DPAD_UP; button <= BTN_DPAD_RIGHT && !has_joystick_axes_or_buttons; button++)
+                        has_joystick_axes_or_buttons = test_bit(button, bitmask_key);
+        }
         for (axis = ABS_RX; axis < ABS_PRESSURE && !has_joystick_axes_or_buttons; axis++)
                 has_joystick_axes_or_buttons = test_bit(axis, bitmask_abs);