diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2022-09-06 09:46:42 +0200 |
---|---|---|
committer | Marge Bot <marge-bot@gnome.org> | 2022-11-09 10:46:55 +0000 |
commit | d274d4359fcc1d689932082eba0f5d419578b402 (patch) | |
tree | 13a4af2b4ac036577911bc99e74b0227e47bdf6e | |
parent | 3ca78fa44a1377b8a9b7d86dddb602124fb68b42 (diff) | |
download | mutter-d274d4359fcc1d689932082eba0f5d419578b402.tar.gz |
backends/native: Set up trackball/trackpoint capabilities
Use udev to detect these features in input devices.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2617>
-rw-r--r-- | src/backends/native/meta-input-device-native.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/backends/native/meta-input-device-native.c b/src/backends/native/meta-input-device-native.c index 380dda4f5..dbbe3a674 100644 --- a/src/backends/native/meta-input-device-native.c +++ b/src/backends/native/meta-input-device-native.c @@ -1350,10 +1350,28 @@ determine_device_type (struct libinput_device *ldev) return CLUTTER_EXTENSION_DEVICE; } +static gboolean +has_udev_property (struct udev_device *udev_device, + const char *property) +{ + struct udev_device *parent_udev_device; + + if (NULL != udev_device_get_property_value (udev_device, property)) + return TRUE; + + parent_udev_device = udev_device_get_parent (udev_device); + + if (!parent_udev_device) + return FALSE; + + return udev_device_get_property_value (parent_udev_device, property) != NULL; +} + static ClutterInputCapabilities translate_device_capabilities (struct libinput_device *ldev) { ClutterInputCapabilities caps = 0; + struct udev_device *udev_device; /* This setting is specific to touchpads and alike, only in these * devices there is this additional layer of touch event interpretation. @@ -1371,6 +1389,18 @@ translate_device_capabilities (struct libinput_device *ldev) if (libinput_device_has_capability (ldev, LIBINPUT_DEVICE_CAP_KEYBOARD)) caps |= CLUTTER_INPUT_CAPABILITY_KEYBOARD; + udev_device = libinput_device_get_udev_device (ldev); + + if (udev_device) + { + if (has_udev_property (udev_device, "ID_INPUT_TRACKBALL")) + caps |= CLUTTER_INPUT_CAPABILITY_TRACKBALL; + if (has_udev_property (udev_device, "ID_INPUT_POINTINGSTICK")) + caps |= CLUTTER_INPUT_CAPABILITY_TRACKPOINT; + + udev_device_unref (udev_device); + } + return caps; } |