]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: rules: guess devices if internal or external 40649/head
authorDavid Santamaría Rogado <howl.nsp@gmail.com>
Wed, 11 Feb 2026 18:28:02 +0000 (19:28 +0100)
committerDavid Santamaría Rogado <howl.nsp@gmail.com>
Mon, 16 Feb 2026 02:46:25 +0000 (03:46 +0100)
Set ID_INTEGRATION variable to hint if a device is internal (inherent
part of the system) or external otherwise.

hwdb.d/70-joystick.hwdb
hwdb.d/70-touchpad.hwdb
rules.d/60-persistent-input.rules
rules.d/65-integration.rules [new file with mode: 0644]
rules.d/meson.build

index e2008676e92b0a5226585357bff4386028692d78..ad654478b6939b54f892f24c844742d7e77fee94 100644 (file)
 #
 #   If the property is missing, user-space can assume:
 #   ID_INPUT_JOYSTICK_INTEGRATION=external
+#
+#   By default i8042, i2c, and rmi devices are assumed to be internal,
+#   bluetooth devices are assumed to be external, usb devices are assumed
+#   to be internal when connected to a PCB port and external otherwise.
 
-joystick:bluetooth:*
- ID_INPUT_JOYSTICK_INTEGRATION=external
-
-###########################################################
-# GPD
-###########################################################
-
-# GPD Win, Classic and XBox 360 compat modes
-joystick:usb:v11c5p5507*
-joystick:usb:v045ep028e*
- ID_INPUT_JOYSTICK_INTEGRATION=internal
+# Example entry; vid: ffff, pid: 0000; both must be lowecase.
+# this will make this usb joystick to behave as internal.
+#joystick:usb:vffffp0000*
+# ID_INPUT_JOYSTICK_INTEGRATION=internal
index d5285566f11c8ccb223576eb4143356533f78747..ddb06c764284c8489e2f708487e9f45fc34f212a 100644 (file)
 # Permitted keys:
 #   Specify whether a touchpad is a built-in one or external:
 #   ID_INPUT_TOUCHPAD_INTEGRATION=internal|external
+#
+#   By default i8042, i2c, and rmi devices are assumed to be internal,
+#   bluetooth devices are assumed to be external, usb devices are assumed
+#   to be internal when connected to a PCB port and external otherwise.
 
-touchpad:i8042:*
-touchpad:rmi:*
-touchpad:usb:*
- ID_INPUT_TOUCHPAD_INTEGRATION=internal
-
-touchpad:bluetooth:*
- ID_INPUT_TOUCHPAD_INTEGRATION=external
-
-###########################################################
-# Apple
-###########################################################
-# Magic Trackpad (1 and 2)
-touchpad:usb:v05acp030e:*
-touchpad:usb:v05acp0265:*
-touchpad:usb:v05acp0324:*
- ID_INPUT_TOUCHPAD_INTEGRATION=external
-
-###########################################################
-# HP Elite x2 1013 G3
-###########################################################
-touchpad:usb:v044ep1221:*
- ID_INPUT_TOUCHPAD_INTEGRATION=external
+# Example entry; vid: ffff, pid: 0000; both must be lowecase.
+# this will make this bluetooth touchpad to behave as internal.
+#touchpad:bluetooth:vffffp0000:*
+# ID_INPUT_TOUCHPAD_INTEGRATION=internal
 
 ###########################################################
 # Lenovo IdeaPad Duet3 10IGL5 (82AT)
 ###########################################################
 touchpad:bluetooth:v17efp60fa:*
  ID_INPUT_TOUCHPAD_INTEGRATION=internal
-
-###########################################################
-# Logitech
-###########################################################
-touchpad:usb:v046d*
- ID_INPUT_TOUCHPAD_INTEGRATION=external
-
-###########################################################
-# Wacom
-###########################################################
-touchpad:usb:v056a*
- ID_INPUT_TOUCHPAD_INTEGRATION=external
index d02b46caf07d182ab4db7d7651fcf9c8078764a5..5ac23c6122a64fe5f9faf2f9666b809c6e009209 100644 (file)
@@ -5,11 +5,19 @@ SUBSYSTEM!="input", GOTO="persistent_input_end"
 SUBSYSTEMS=="bluetooth", ENV{ID_BUS}="bluetooth", GOTO="persistent_input_end"
 # Bluetooth devices don't always have the bluetooth subsystem
 ATTRS{id/bustype}=="0005", ENV{ID_BUS}="bluetooth", GOTO="persistent_input_end"
+SUBSYSTEMS=="acpi", ENV{ID_BUS}="acpi"
+# platform must be before serio as serio can be child
+SUBSYSTEMS=="platform", ENV{ID_BUS}="platform"
+SUBSYSTEMS=="i2c", ENV{ID_BUS}="i2c"
 SUBSYSTEMS=="rmi4", ENV{ID_BUS}="rmi"
 SUBSYSTEMS=="serio", ENV{ID_BUS}="i8042"
 
 SUBSYSTEMS=="usb", ENV{ID_BUS}=="", IMPORT{builtin}="usb_id"
 
+# subsystems before (usb, platform, i2c) can be under pci so only set them if we still have no ID_BUS.
+# we could set this the first but will break the ENV{ID_BUS}=="" condition for usb.
+SUBSYSTEMS=="pci", ENV{ID_BUS}=="", ENV{ID_BUS}="pci"
+
 # determine class name for persistent symlinks
 ENV{ID_INPUT_KEYBOARD}=="?*", ENV{.INPUT_CLASS}="kbd"
 ENV{ID_INPUT_MOUSE}=="?*", ENV{.INPUT_CLASS}="mouse"
diff --git a/rules.d/65-integration.rules b/rules.d/65-integration.rules
new file mode 100644 (file)
index 0000000..cd3dfdc
--- /dev/null
@@ -0,0 +1,25 @@
+# do not edit this file, it will be overwritten on update
+
+# ID_INTEGRATION variable tells us if a device is internal (inherent part of the system) or external otherwise.
+# This must be loaded after 60-persistent-*.rules to have ID_BUS.
+
+ACTION=="remove", GOTO="integration_end"
+ENV{ID_BUS}=="", GOTO="integration_end"
+
+# ACPI, platform, PS/2, I2C, RMI and PCI devices: Internal by default.
+ENV{ID_BUS}=="acpi|platform|i8042|i2c|rmi|pci", ENV{ID_INTEGRATION}="internal"
+
+# Bluetooth devices: External by default.
+ENV{ID_BUS}=="bluetooth", ENV{ID_INTEGRATION}="external"
+
+# USB devices: Internal if it's connected to a fixed port, external to a removable or unknown.
+ENV{ID_BUS}=="usb", DRIVERS=="usb", ATTRS{maxchild}=="0", ATTRS{removable}=="fixed", ENV{ID_INTEGRATION}="internal"
+ENV{ID_BUS}=="usb", DRIVERS=="usb", ATTRS{maxchild}=="0", ATTRS{removable}=="removable|unknown", ENV{ID_INTEGRATION}="external"
+
+# libinput compatibility variables, must be loaded before 70-(joystick|touchpad).rules to allow hwdb quirks to override.
+ENV{ID_INPUT}=="", GOTO="integration_libinput_end"
+ENV{ID_INPUT_JOYSTICK}=="1", ENV{ID_INPUT_JOYSTICK_INTEGRATION}="$env{ID_INTEGRATION}"
+ENV{ID_INPUT_TOUCHPAD}=="1", ENV{ID_INPUT_TOUCHPAD_INTEGRATION}="$env{ID_INTEGRATION}"
+LABEL="integration_libinput_end"
+
+LABEL="integration_end"
index 6029ec8768bc7b60c6bab54eb749b81448f9b0d3..839190658b40a71f81954e26ccb6bbb4243f4bcc 100644 (file)
@@ -23,6 +23,7 @@ rules = [
                '60-persistent-v4l.rules',
                '60-sensor.rules',
                '60-serial.rules',
+               '65-integration.rules',
                '70-camera.rules',
                '70-joystick.rules',
                '70-mouse.rules',