]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/udev/udev-builtin-input_id.c
udev: if a tablet has BTN_0, label it as ID_INPUT_TABLET_PAD
[thirdparty/systemd.git] / src / udev / udev-builtin-input_id.c
index 215287c114cb0050f884246324edba6bd85389ce..81dd03e4c50db79652f32b39e5c0bdc436cc562b 100644 (file)
@@ -154,17 +154,20 @@ static bool test_pointers(sd_device *dev,
         bool has_rel_coordinates = false;
         bool has_mt_coordinates = false;
         bool has_joystick_axes_or_buttons = false;
+        bool has_pad_buttons = false;
         bool is_direct = false;
         bool has_touch = false;
         bool has_3d_coordinates = false;
         bool has_keys = false;
-        bool stylus_or_pen = false;
+        bool has_stylus = false;
+        bool has_pen = false;
         bool finger_but_no_pen = false;
         bool has_mouse_button = false;
         bool is_mouse = false;
         bool is_touchpad = false;
         bool is_touchscreen = false;
         bool is_tablet = false;
+        bool is_tablet_pad = false;
         bool is_joystick = false;
         bool is_accelerometer = false;
         bool is_pointing_stick = false;
@@ -183,7 +186,8 @@ static bool test_pointers(sd_device *dev,
         }
 
         is_pointing_stick = test_bit(INPUT_PROP_POINTING_STICK, bitmask_props);
-        stylus_or_pen = test_bit(BTN_STYLUS, bitmask_key) || test_bit(BTN_TOOL_PEN, bitmask_key);
+        has_stylus = test_bit(BTN_STYLUS, bitmask_key);
+        has_pen = test_bit(BTN_TOOL_PEN, bitmask_key);
         finger_but_no_pen = test_bit(BTN_TOOL_FINGER, bitmask_key) && !test_bit(BTN_TOOL_PEN, bitmask_key);
         for (button = BTN_MOUSE; button < BTN_JOYSTICK && !has_mouse_button; button++)
                 has_mouse_button = test_bit(button, bitmask_key);
@@ -195,6 +199,7 @@ static bool test_pointers(sd_device *dev,
                 has_mt_coordinates = false;
         is_direct = test_bit(INPUT_PROP_DIRECT, bitmask_props);
         has_touch = test_bit(BTN_TOUCH, bitmask_key);
+        has_pad_buttons = test_bit(BTN_0, bitmask_key) && has_stylus && !has_pen;
 
         /* joysticks don't necessarily have buttons; e. g.
          * rudders/pedals are joystick-like, but buttonless; they have
@@ -216,7 +221,7 @@ static bool test_pointers(sd_device *dev,
                 has_joystick_axes_or_buttons = test_bit(axis, bitmask_abs);
 
         if (has_abs_coordinates) {
-                if (stylus_or_pen)
+                if (has_stylus || has_pen)
                         is_tablet = true;
                 else if (finger_but_no_pen && !is_direct)
                         is_touchpad = true;
@@ -232,7 +237,7 @@ static bool test_pointers(sd_device *dev,
                 is_joystick = true;
 
         if (has_mt_coordinates) {
-                if (stylus_or_pen)
+                if (has_stylus || has_pen)
                         is_tablet = true;
                 else if (finger_but_no_pen && !is_direct)
                         is_touchpad = true;
@@ -240,6 +245,9 @@ static bool test_pointers(sd_device *dev,
                         is_touchscreen = true;
         }
 
+        if (is_tablet && has_pad_buttons)
+                is_tablet_pad = true;
+
         if (!is_tablet && !is_touchpad && !is_joystick &&
             has_mouse_button &&
             (has_rel_coordinates ||
@@ -262,6 +270,8 @@ static bool test_pointers(sd_device *dev,
                 udev_builtin_add_property(dev, test, "ID_INPUT_JOYSTICK", "1");
         if (is_tablet)
                 udev_builtin_add_property(dev, test, "ID_INPUT_TABLET", "1");
+        if (is_tablet_pad)
+                udev_builtin_add_property(dev, test, "ID_INPUT_TABLET_PAD", "1");
 
         return is_tablet || is_mouse || is_touchpad || is_touchscreen || is_joystick || is_pointing_stick;
 }