From d274d4359fcc1d689932082eba0f5d419578b402 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 6 Sep 2022 09:46:42 +0200 Subject: [PATCH] backends/native: Set up trackball/trackpoint capabilities Use udev to detect these features in input devices. Part-of: --- .../native/meta-input-device-native.c | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) 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; }