From 819e943ab0d366e6a2bc2b16aad0615c078e1428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Santamar=C3=ADa=20Rogado?= Date: Tue, 17 Feb 2026 17:46:20 +0100 Subject: [PATCH] evdev: use udev's ID_INTEGRATION MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Part-of: --- src/evdev-mt-touchpad.c | 16 +++++++++++++ src/evdev.c | 28 ++++++++++++++++++++++- test/litest-device-generic-usb-touchpad.c | 2 +- test/litest-device-magic-trackpad.c | 2 +- test/litest.h | 3 +-- 5 files changed, 46 insertions(+), 5 deletions(-) diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index e60ced9b..dafc0000 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -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) { diff --git a/src/evdev.c b/src/evdev.c index c08d0291..c42c559c 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -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")) { diff --git a/test/litest-device-generic-usb-touchpad.c b/test/litest-device-generic-usb-touchpad.c index a2cf0bf4..4dfad7d0 100644 --- a/test/litest-device-generic-usb-touchpad.c +++ b/test/litest-device-generic-usb-touchpad.c @@ -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, ) diff --git a/test/litest-device-magic-trackpad.c b/test/litest-device-magic-trackpad.c index 227b20cc..5706c9aa 100644 --- a/test/litest-device-magic-trackpad.c +++ b/test/litest-device-magic-trackpad.c @@ -120,6 +120,6 @@ TEST_DEVICE(LITEST_MAGIC_TRACKPAD, .absinfo = absinfo, .udev_properties = { - { "ID_INPUT_TOUCHPAD_INTEGRATION", "external" }, + { "ID_INTEGRATION", "external" }, { NULL }, }, ) diff --git a/test/litest.h b/test/litest.h index b8b8d798..bac7c399 100644 --- a/test/litest.h +++ b/test/litest.h @@ -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);