evdev: use udev's ID_INTEGRATION

Now we have in udev the ID_INTEGRATION propery that tells us if a device
is internal or external, use it while still allow hwdb and quirks to
override it.

In the future is possible that we could remove quirks for keyboards
integration and hwdb for touchpads and joysticks integration.

Signed-off-by: David Santamaría Rogado <howl.nsp@gmail.com>
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1429>
This commit is contained in:
David Santamaría Rogado 2026-02-17 17:46:20 +01:00 committed by Marge Bot
parent 1c82aa1659
commit 819e943ab0
5 changed files with 46 additions and 5 deletions

View file

@ -2678,6 +2678,22 @@ evdev_tag_touchpad(struct evdev_device *device, struct udev_device *udev_device)
int bustype, vendor;
const char *prop;
prop = udev_device_get_property_value(udev_device, "ID_INTEGRATION");
if (prop) {
if (streq(prop, "internal")) {
evdev_tag_touchpad_internal(device);
return;
}
if (streq(prop, "external")) {
evdev_tag_touchpad_external(device);
return;
}
evdev_log_info(device, "tagged with unknown value %s\n", prop);
}
/* Fall back to ID_TOUCHPAD_INTEGRATION if ID_INTEGRATION is missing */
prop = udev_device_get_property_value(udev_device,
"ID_INPUT_TOUCHPAD_INTEGRATION");
if (prop) {

View file

@ -489,6 +489,7 @@ static void
evdev_tag_trackpoint(struct evdev_device *device, struct udev_device *udev_device)
{
char *prop;
const char *udev_prop;
if (!libevdev_has_property(device->evdev, INPUT_PROP_POINTING_STICK) &&
!parse_udev_flag(device, udev_device, "ID_INPUT_POINTINGSTICK"))
@ -496,10 +497,22 @@ evdev_tag_trackpoint(struct evdev_device *device, struct udev_device *udev_devic
device->tags |= EVDEV_TAG_TRACKPOINT;
udev_prop = udev_device_get_property_value(udev_device, "ID_INTEGRATION");
if (udev_prop) {
if (streq(udev_prop, "internal")) {
/* noop, this is the default anyway */
} else if (streq(udev_prop, "external"))
device->tags |= EVDEV_TAG_EXTERNAL_MOUSE;
else
evdev_log_info(device,
"tagged with unknown value %s\n",
udev_prop);
}
_unref_(quirks) *q = libinput_device_get_quirks(&device->base);
if (q && quirks_get_string(q, QUIRK_ATTR_TRACKPOINT_INTEGRATION, &prop)) {
if (streq(prop, "internal")) {
/* noop, this is the default anyway */
device->tags &= ~EVDEV_TAG_EXTERNAL_MOUSE;
} else if (streq(prop, "external")) {
device->tags |= EVDEV_TAG_EXTERNAL_MOUSE;
evdev_log_info(device, "is an external pointing stick\n");
@ -527,6 +540,7 @@ static void
evdev_tag_keyboard(struct evdev_device *device, struct udev_device *udev_device)
{
char *prop;
const char *udev_prop;
int code;
if (!libevdev_has_event_type(device->evdev, EV_KEY))
@ -537,6 +551,18 @@ evdev_tag_keyboard(struct evdev_device *device, struct udev_device *udev_device)
return;
}
udev_prop = udev_device_get_property_value(udev_device, "ID_INTEGRATION");
if (udev_prop) {
if (streq(udev_prop, "internal"))
evdev_tag_keyboard_internal(device);
else if (streq(udev_prop, "external"))
evdev_tag_keyboard_external(device);
else
evdev_log_info(device,
"tagged with unknown value %s\n",
udev_prop);
}
_unref_(quirks) *q = libinput_device_get_quirks(&device->base);
if (q && quirks_get_string(q, QUIRK_ATTR_KEYBOARD_INTEGRATION, &prop)) {
if (streq(prop, "internal")) {

View file

@ -100,7 +100,7 @@ TEST_DEVICE(LITEST_GENERIC_USBCOMBO_TOUCHPAD,
.events = events,
.absinfo = absinfo,
.udev_properties = {
{ "ID_INPUT_TOUCHPAD_INTEGRATION", "external" },
{ "ID_INTEGRATION", "external" },
{ NULL },
},
.quirk_file = quirk_file, )

View file

@ -120,6 +120,6 @@ TEST_DEVICE(LITEST_MAGIC_TRACKPAD,
.absinfo = absinfo,
.udev_properties = {
{ "ID_INPUT_TOUCHPAD_INTEGRATION", "external" },
{ "ID_INTEGRATION", "external" },
{ NULL },
}, )

View file

@ -1765,8 +1765,7 @@ litest_touchpad_is_external(struct litest_device *dev)
return true;
udev_device = libinput_device_get_udev_device(dev->libinput_device);
prop = udev_device_get_property_value(udev_device,
"ID_INPUT_TOUCHPAD_INTEGRATION");
prop = udev_device_get_property_value(udev_device, "ID_INTEGRATION");
is_external = prop && streq(prop, "external");
udev_device_unref(udev_device);