From d57c6115e0aa3d04fea4c87c67ec455ffe5a0c75 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Mon, 10 Mar 2014 08:54:22 +0100 Subject: [PATCH] input_id: Recognize buttonless joystick types Input devices like rudders or pedals are joystick-like; they don't have buttons, but axes like RX, THROTTLE, or RUDDER. These don't interfere with other device types with absolute axes (touch screens, touchpads, and accelerometers), so it's fairly safe to mark them as ID_INPUT_JOYSTICK and thus hand out dynamic ACLs to the user. https://bugs.freedesktop.org/show_bug.cgi?id=70734 (cherry picked from commit 2658624399b22a9c4a345a22c69886dc9417f801) (cherry picked from commit 33fc27712a13b7502804a2a3016ce490a89e000d) --- src/udev/udev-builtin-input_id.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/udev/udev-builtin-input_id.c b/src/udev/udev-builtin-input_id.c index 4691fc0..33c8075 100644 --- a/src/udev/udev-builtin-input_id.c +++ b/src/udev/udev-builtin-input_id.c @@ -116,16 +116,27 @@ static void test_pointers (struct udev_device *dev, udev_builtin_add_property(dev, test, "ID_INPUT_TABLET", "1"); else if (test_bit (BTN_TOOL_FINGER, bitmask_key) && !test_bit (BTN_TOOL_PEN, bitmask_key)) is_touchpad = 1; - else if (test_bit (BTN_TRIGGER, bitmask_key) || - test_bit (BTN_A, bitmask_key) || - test_bit (BTN_1, bitmask_key)) - udev_builtin_add_property(dev, test, "ID_INPUT_JOYSTICK", "1"); else if (test_bit (BTN_MOUSE, bitmask_key)) /* This path is taken by VMware's USB mouse, which has * absolute axes, but no touch/pressure button. */ is_mouse = 1; else if (test_bit (BTN_TOUCH, bitmask_key)) udev_builtin_add_property(dev, test, "ID_INPUT_TOUCHSCREEN", "1"); + /* joysticks don't necessarily have to have buttons; e. g. + * rudders/pedals are joystick-like, but buttonless; they have + * other fancy axes */ + else if (test_bit (BTN_TRIGGER, bitmask_key) || + test_bit (BTN_A, bitmask_key) || + test_bit (BTN_1, bitmask_key) || + test_bit (ABS_RX, bitmask_abs) || + test_bit (ABS_RY, bitmask_abs) || + test_bit (ABS_RZ, bitmask_abs) || + test_bit (ABS_THROTTLE, bitmask_abs) || + test_bit (ABS_RUDDER, bitmask_abs) || + test_bit (ABS_WHEEL, bitmask_abs) || + test_bit (ABS_GAS, bitmask_abs) || + test_bit (ABS_BRAKE, bitmask_abs)) + udev_builtin_add_property(dev, test, "ID_INPUT_JOYSTICK", "1"); } if (test_bit (EV_REL, bitmask_ev) &&