]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
rules: extend 60-input-id.rules to allow for bus/vid/pid/name matches
authorPeter Hutterer <peter.hutterer@who-t.net>
Thu, 9 Oct 2025 00:55:16 +0000 (10:55 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Mon, 20 Oct 2025 04:14:39 +0000 (14:14 +1000)
Same approach as used in 70-mouse.rules, allow for a name-based match
optionally combined with bus/vid/pid (which the existing modalias rule
would already allow us anyway). Note that ID_BUS isn't assigned until
after this rule has run so we need to use the id/bustype attribute
directly.

Related to https://github.com/systemd/systemd/issues/36677

hwdb.d/60-input-id.hwdb
hwdb.d/parse_hwdb.py
rules.d/60-input-id.rules

index 6730ac9efaedc095d73004700dbbe30738239098..edc166c8470659b1b670fc75b9319f92cbb96e1f 100644 (file)
@@ -5,6 +5,7 @@
 #
 # Match string formats:
 # id-input:modalias:<modalias>
+# id-input:<bus>:v<vid>p<pid>:name:<name>:*
 #
 # To add local entries, create a new file
 #   /etc/udev/hwdb.d/61-input-id-local.hwdb
 # id-input:modalias:input:b0003v1234pABCD*
 #  ID_INPUT_TOUCHPAD=1
 #  ID_INPUT=1
+#
+# id-input:usb:v12abp34cd:name:SomeVendor *:*
+#  ID_INPUT_TOUCHPAD=1
+#  ID_INPUT=1
+#
+# For technical reasons the hexadecimal vid/pid in the modalias match are
+# uppercase but lowercase in the bus/vid/pid/name match.
 
 # Sort by brand, model
 
index 9a599e735c362b7f2eeea614f4cec270e3895103..ae5c9403fd7356c4cd3d5dcce630236210084318 100755 (executable)
@@ -75,7 +75,7 @@ UDEV_TAG = Word(string.ascii_uppercase, alphanums + '_')
 TYPES = {'mouse':    ('usb', 'bluetooth', 'ps2', '*'),
          'evdev':    ('name', 'atkbd', 'input'),
          'fb':       ('pci', 'vmbus'),
-         'id-input': ('modalias'),
+         'id-input': ('modalias', 'bluetooth', 'i2c', 'usb'),
          'touchpad': ('i8042', 'rmi', 'bluetooth', 'usb'),
          'joystick': ('i8042', 'rmi', 'bluetooth', 'usb'),
          'keyboard': ('name', ),
index bb8a812d1b7a3eb5393445dab7a479940ce00215..c2bdbfdc27232c21db2839faf8cdcb3d80b1c77c 100644 (file)
@@ -5,4 +5,15 @@ ACTION=="remove", GOTO="id_input_end"
 SUBSYSTEM=="input", ENV{ID_INPUT}=="", IMPORT{builtin}="input_id"
 SUBSYSTEM=="input", IMPORT{builtin}="hwdb --subsystem=input --lookup-prefix=id-input:modalias:"
 
+# id-input:<bus>:v<vid>p<pid>:name:<name>:*
+KERNELS=="input*", ATTRS{id/bustype}=="0003", \
+        IMPORT{builtin}="hwdb 'id-input:usb:v$attr{id/vendor}p$attr{id/product}:name:$attr{name}:'", \
+        GOTO="id_input_end"
+KERNELS=="input*", ATTRS{id/bustype}=="0005", \
+        IMPORT{builtin}="hwdb 'id-input:bluetooth:v$attr{id/vendor}p$attr{id/product}:name:$attr{name}:'", \
+        GOTO="id_input_end"
+KERNELS=="input*", ATTRS{id/bustype}=="0018", \
+        IMPORT{builtin}="hwdb 'id-input:i2c:v$attr{id/vendor}p$attr{id/product}:name:$attr{name}:'", \
+        GOTO="id_input_end"
+
 LABEL="id_input_end"