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>
This commit is contained in:
Carlos Garnacho 2022-09-06 09:46:42 +02:00 committed by Marge Bot
parent 3ca78fa44a
commit d274d4359f

View File

@ -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;
}