Skip to content

Conversation

6by9
Copy link
Contributor

@6by9 6by9 commented Sep 22, 2025

libinput/wlroots/Wayfire/labwc match input device by the device name only. If you add 2 identical USB connected touch devices, you can't select between them.

Add the usb bus&device name to the start of the name so that the names end up being unique,

Supercedes #6356
Addresses raspberrypi/bookworm-feedback#446
https://forums.raspberrypi.com/viewtopic.php?t=376569

@P33M
Copy link
Contributor

P33M commented Sep 22, 2025

Nit: trailing comma in the commit message. Otherwise, lgtm.

libinput/wlroots/Wayfire/labwc match input device by the
device name only. If you add 2 identical USB connected
touch devices, you can't select between them.

Add the usb bus&device name to the start of the name so that
the names end up being unique.

Signed-off-by: Dave Stevenson <[email protected]>
@6by9 6by9 force-pushed the rpi-6.12.y-usbhid branch from a8d63bd to 18da0e8 Compare September 22, 2025 16:04
@6by9
Copy link
Contributor Author

6by9 commented Sep 22, 2025

Nit: trailing comma in the commit message. Otherwise, lgtm.

Fixed.

@HiassofT
Copy link
Contributor

Please don't fiddle around with the name, this breaks name-based udev/hwdb matches and likely other programs, too.

Connect eg a Logitech M100 mouse and observe that the MOUSE_DPI= setting will be missing in udevadm info output, because the hwdb entry https://github.com/systemd/systemd/blob/v258/hwdb.d/70-mouse.hwdb#L694-L696 no longer matches.

udevadm info output with plain 6.12.48 RPi kernel:

P: /devices/platform/axi/1000120000.pcie/1f00300000.usb/xhci-hcd.1/usb3/3-1/3-1:1.0/0003:046D:C05A.0001/input/input2/event2
M: event2
R: 2
J: c13:66
U: input
D: c 13:66
N: input/event2
L: 0
S: input/by-path/platform-xhci-hcd.1-usb-0:1:1.0-event-mouse
S: input/by-path/platform-xhci-hcd.1-usbv2-0:1:1.0-event-mouse
S: input/by-id/usb-Logitech_USB_Optical_Mouse-event-mouse
E: DEVPATH=/devices/platform/axi/1000120000.pcie/1f00300000.usb/xhci-hcd.1/usb3/3-1/3-1:1.0/0003:046D:C05A.0001/input/input2/event2
E: DEVNAME=/dev/input/event2
E: MAJOR=13
E: MINOR=66
E: SUBSYSTEM=input
E: USEC_INITIALIZED=11747040
E: ID_INPUT=1
E: ID_INPUT_MOUSE=1
E: ID_BUS=usb
E: ID_MODEL=USB_Optical_Mouse
E: ID_MODEL_ENC=USB\x20Optical\x20Mouse
E: ID_MODEL_ID=c05a
E: ID_SERIAL=Logitech_USB_Optical_Mouse
E: ID_VENDOR=Logitech
E: ID_VENDOR_ENC=Logitech
E: ID_VENDOR_ID=046d
E: ID_REVISION=6300
E: ID_TYPE=hid
E: ID_USB_MODEL=USB_Optical_Mouse
E: ID_USB_MODEL_ENC=USB\x20Optical\x20Mouse
E: ID_USB_MODEL_ID=c05a
E: ID_USB_SERIAL=Logitech_USB_Optical_Mouse
E: ID_USB_VENDOR=Logitech
E: ID_USB_VENDOR_ENC=Logitech
E: ID_USB_VENDOR_ID=046d
E: ID_USB_REVISION=6300
E: ID_USB_TYPE=hid
E: ID_USB_INTERFACES=:030102:
E: ID_USB_INTERFACE_NUM=00
E: ID_USB_DRIVER=usbhid
E: ID_PATH_WITH_USB_REVISION=platform-xhci-hcd.1-usbv2-0:1:1.0
E: ID_PATH=platform-xhci-hcd.1-usb-0:1:1.0
E: ID_PATH_TAG=platform-xhci-hcd_1-usb-0_1_1_0
E: KEY=70000 0 0 0 0
E: MOUSE_DPI=1000@125
E: LIBINPUT_DEVICE_GROUP=3/46d/c05a:usb-xhci-hcd.1-1
E: DEVLINKS=/dev/input/by-path/platform-xhci-hcd.1-usb-0:1:1.0-event-mouse /dev/input/by-path/platform-xhci-hcd.1-usbv2-0:1:1.0-event-mouse /dev/input/by-id/usb-Logitech_USB_Optical_Mouse-event-mouse

udevadm info output with this PR:

P: /devices/platform/axi/1000120000.pcie/1f00300000.usb/xhci-hcd.1/usb3/3-1/3-1:1.0/0003:046D:C05A.0001/input/input2/event2
M: event2
R: 2
J: c13:66
U: input
D: c 13:66
N: input/event2
L: 0
S: input/by-id/usb-Logitech_USB_Optical_Mouse-event-mouse
S: input/by-path/platform-xhci-hcd.1-usb-0:1:1.0-event-mouse
S: input/by-path/platform-xhci-hcd.1-usbv2-0:1:1.0-event-mouse
E: DEVPATH=/devices/platform/axi/1000120000.pcie/1f00300000.usb/xhci-hcd.1/usb3/3-1/3-1:1.0/0003:046D:C05A.0001/input/input2/event2
E: DEVNAME=/dev/input/event2
E: MAJOR=13
E: MINOR=66
E: SUBSYSTEM=input
E: USEC_INITIALIZED=9187506
E: ID_INPUT=1
E: ID_INPUT_MOUSE=1
E: ID_BUS=usb
E: ID_MODEL=USB_Optical_Mouse
E: ID_MODEL_ENC=USB\x20Optical\x20Mouse
E: ID_MODEL_ID=c05a
E: ID_SERIAL=Logitech_USB_Optical_Mouse
E: ID_VENDOR=Logitech
E: ID_VENDOR_ENC=Logitech
E: ID_VENDOR_ID=046d
E: ID_REVISION=6300
E: ID_TYPE=hid
E: ID_USB_MODEL=USB_Optical_Mouse
E: ID_USB_MODEL_ENC=USB\x20Optical\x20Mouse
E: ID_USB_MODEL_ID=c05a
E: ID_USB_SERIAL=Logitech_USB_Optical_Mouse
E: ID_USB_VENDOR=Logitech
E: ID_USB_VENDOR_ENC=Logitech
E: ID_USB_VENDOR_ID=046d
E: ID_USB_REVISION=6300
E: ID_USB_TYPE=hid
E: ID_USB_INTERFACES=:030102:
E: ID_USB_INTERFACE_NUM=00
E: ID_USB_DRIVER=usbhid
E: ID_PATH_WITH_USB_REVISION=platform-xhci-hcd.1-usbv2-0:1:1.0
E: ID_PATH=platform-xhci-hcd.1-usb-0:1:1.0
E: ID_PATH_TAG=platform-xhci-hcd_1-usb-0_1_1_0
E: KEY=70000 0 0 0 0
E: LIBINPUT_DEVICE_GROUP=3/46d/c05a:usb-xhci-hcd.1-1
E: DEVLINKS=/dev/input/by-id/usb-Logitech_USB_Optical_Mouse-event-mouse /dev/input/by-path/platform-xhci-hcd.1-usb-0:1:1.0-event-mouse /dev/input/by-path/platform-xhci-hcd.1-usbv2-0:1:1.0-event-mouse

If you have issues with labwc please fix it there.

@pelwell
Copy link
Contributor

pelwell commented Sep 22, 2025

If you have issues with labwc please fix it there.

Are you saying that, with the unmodified kernel, labwc already has enough information to be able to distinguish between multiple instances of identical USB devices?

@HiassofT
Copy link
Contributor

HiassofT commented Sep 22, 2025

I'm not familiar with labwc but all the needed seems to be available from udev.

Looking at udevadm info -a the info from the added usb-x-y string in the name is available as KERNEL(S) info 3 parent nodes up:

  looking at device '/devices/platform/axi/1000120000.pcie/1f00300000.usb/xhci-hcd.1/usb3/3-1/3-1:1.0/0003:046D:C05A.0001/input/input2/event2':
    KERNEL=="event2"
    SUBSYSTEM=="input"
    DRIVER==""
    ATTR{power/control}=="auto"
    ATTR{power/runtime_active_time}=="0"
    ATTR{power/runtime_status}=="unsupported"
    ATTR{power/runtime_suspended_time}=="0"

  looking at parent device '/devices/platform/axi/1000120000.pcie/1f00300000.usb/xhci-hcd.1/usb3/3-1/3-1:1.0/0003:046D:C05A.0001/input/input2':
    KERNELS=="input2"
    SUBSYSTEMS=="input"
    DRIVERS==""
    ATTRS{capabilities/abs}=="0"
    ATTRS{capabilities/ev}=="17"
    ATTRS{capabilities/ff}=="0"
    ATTRS{capabilities/key}=="70000 0 0 0 0"
    ATTRS{capabilities/led}=="0"
    ATTRS{capabilities/msc}=="10"
    ATTRS{capabilities/rel}=="903"
    ATTRS{capabilities/snd}=="0"
    ATTRS{capabilities/sw}=="0"
    ATTRS{id/bustype}=="0003"
    ATTRS{id/product}=="c05a"
    ATTRS{id/vendor}=="046d"
    ATTRS{id/version}=="0111"
    ATTRS{inhibited}=="0"
    ATTRS{name}=="usb-3-1 Logitech USB Optical Mouse"
    ATTRS{phys}=="usb-xhci-hcd.1-1/input0"
    ATTRS{power/control}=="auto"
    ATTRS{power/runtime_active_time}=="0"
    ATTRS{power/runtime_status}=="unsupported"
    ATTRS{power/runtime_suspended_time}=="0"
    ATTRS{properties}=="0"
    ATTRS{uniq}==""

  looking at parent device '/devices/platform/axi/1000120000.pcie/1f00300000.usb/xhci-hcd.1/usb3/3-1/3-1:1.0/0003:046D:C05A.0001':
    KERNELS=="0003:046D:C05A.0001"
    SUBSYSTEMS=="hid"
    DRIVERS=="hid-generic"
    ATTRS{country}=="00"
    ATTRS{power/control}=="auto"
    ATTRS{power/runtime_active_time}=="0"
    ATTRS{power/runtime_status}=="unsupported"
    ATTRS{power/runtime_suspended_time}=="0"

  looking at parent device '/devices/platform/axi/1000120000.pcie/1f00300000.usb/xhci-hcd.1/usb3/3-1/3-1:1.0':
    KERNELS=="3-1:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="usbhid"
    ATTRS{authorized}=="1"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bInterfaceClass}=="03"
    ATTRS{bInterfaceNumber}=="00"
    ATTRS{bInterfaceProtocol}=="02"
    ATTRS{bInterfaceSubClass}=="01"
    ATTRS{bNumEndpoints}=="01"
    ATTRS{supports_autosuspend}=="1"

  looking at parent device '/devices/platform/axi/1000120000.pcie/1f00300000.usb/xhci-hcd.1/usb3/3-1':
    KERNELS=="3-1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{authorized}=="1"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bDeviceClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bMaxPacketSize0}=="8"
    ATTRS{bMaxPower}=="100mA"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bcdDevice}=="6300"
    ATTRS{bmAttributes}=="a0"
    ATTRS{busnum}=="3"
    ATTRS{configuration}==""
    ATTRS{devnum}=="2"
    ATTRS{devpath}=="1"
    ATTRS{devspec}=="(null)"
    ATTRS{idProduct}=="c05a"
    ATTRS{idVendor}=="046d"
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="Logitech"
    ATTRS{maxchild}=="0"
    ATTRS{power/active_duration}=="39310"
    ATTRS{power/autosuspend}=="2"
    ATTRS{power/autosuspend_delay_ms}=="2000"
    ATTRS{power/connected_duration}=="39310"
    ATTRS{power/control}=="on"
    ATTRS{power/level}=="on"
    ATTRS{power/persist}=="1"
    ATTRS{power/runtime_active_time}=="39050"
    ATTRS{power/runtime_status}=="active"
    ATTRS{power/runtime_suspended_time}=="0"
    ATTRS{product}=="USB Optical Mouse"
    ATTRS{quirks}=="0x0"
    ATTRS{removable}=="unknown"
    ATTRS{remove}=="(not readable)"
    ATTRS{rx_lanes}=="1"
    ATTRS{speed}=="1.5"
    ATTRS{tx_lanes}=="1"
    ATTRS{urbnum}=="11"
    ATTRS{version}==" 2.00"

  looking at parent device '/devices/platform/axi/1000120000.pcie/1f00300000.usb/xhci-hcd.1/usb3':
    KERNELS=="usb3"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{authorized}=="1"
    ATTRS{authorized_default}=="1"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bMaxPower}=="0mA"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bcdDevice}=="0612"
    ATTRS{bmAttributes}=="e0"
    ATTRS{busnum}=="3"
    ATTRS{configuration}==""
    ATTRS{devnum}=="1"
    ATTRS{devpath}=="0"
    ATTRS{idProduct}=="0002"
    ATTRS{idVendor}=="1d6b"
    ATTRS{interface_authorized_default}=="1"
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="Linux 6.12.48 xhci-hcd"
    ATTRS{maxchild}=="2"
    ATTRS{power/active_duration}=="39530"
    ATTRS{power/autosuspend}=="0"
    ATTRS{power/autosuspend_delay_ms}=="0"
    ATTRS{power/connected_duration}=="39530"
    ATTRS{power/control}=="auto"
    ATTRS{power/level}=="auto"
    ATTRS{power/runtime_active_time}=="39489"
    ATTRS{power/runtime_status}=="active"
    ATTRS{power/runtime_suspended_time}=="0"
    ATTRS{product}=="xHCI Host Controller"
    ATTRS{quirks}=="0x0"
    ATTRS{removable}=="unknown"
    ATTRS{remove}=="(not readable)"
    ATTRS{rx_lanes}=="1"
    ATTRS{serial}=="xhci-hcd.1"
    ATTRS{speed}=="480"
    ATTRS{tx_lanes}=="1"
    ATTRS{urbnum}=="28"
    ATTRS{version}==" 2.00"

  looking at parent device '/devices/platform/axi/1000120000.pcie/1f00300000.usb/xhci-hcd.1':
    KERNELS=="xhci-hcd.1"
    SUBSYSTEMS=="platform"
    DRIVERS=="xhci-hcd"
    ATTRS{driver_override}=="(null)"
    ATTRS{power/control}=="on"
    ATTRS{power/runtime_active_time}=="39544"
    ATTRS{power/runtime_status}=="active"
    ATTRS{power/runtime_suspended_time}=="0"

  looking at parent device '/devices/platform/axi/1000120000.pcie/1f00300000.usb':
    KERNELS=="1f00300000.usb"
    SUBSYSTEMS=="platform"
    DRIVERS=="dwc3"
    ATTRS{driver_override}=="(null)"
    ATTRS{power/autosuspend_delay_ms}=="5000"
    ATTRS{power/control}=="on"
    ATTRS{power/runtime_active_time}=="39544"
    ATTRS{power/runtime_status}=="active"
    ATTRS{power/runtime_suspended_time}=="0"

  looking at parent device '/devices/platform/axi/1000120000.pcie':
    KERNELS=="1000120000.pcie"
    SUBSYSTEMS=="platform"
    DRIVERS=="brcm-pcie"
    ATTRS{driver_override}=="(null)"
    ATTRS{power/control}=="auto"
    ATTRS{power/runtime_active_time}=="0"
    ATTRS{power/runtime_status}=="unsupported"
    ATTRS{power/runtime_suspended_time}=="0"

  looking at parent device '/devices/platform/axi':
    KERNELS=="axi"
    SUBSYSTEMS=="platform"
    DRIVERS=="simple-pm-bus"
    ATTRS{driver_override}=="(null)"
    ATTRS{power/control}=="auto"
    ATTRS{power/runtime_active_time}=="0"
    ATTRS{power/runtime_status}=="unsupported"
    ATTRS{power/runtime_suspended_time}=="0"

  looking at parent device '/devices/platform':
    KERNELS=="platform"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{power/control}=="auto"
    ATTRS{power/runtime_active_time}=="0"
    ATTRS{power/runtime_status}=="unsupported"
    ATTRS{power/runtime_suspended_time}=="0"

Making use of the info in libinput/lavwc, maybe extending their matchers or adding custom udev rules might help

@6by9
Copy link
Contributor Author

6by9 commented Sep 23, 2025

Touch devices are fairly unique in the input subsystem in that you need to know which one is which in order to associate it with the appropriate display device. Plug in two mice or two keyboards and they normally apply to the entire desktop seat.

I must confess to having hoped initially to make this more contained in input subsystems that it touched, but USB HID device descriptors don't lend themselves to it.
The InterfaceProtocol has values defined for mice (2) and keyboards (1), but my keyboard registers two extra devices with type (0) as it appears the media and power controls don't fall within a keyboard definition. Trying to intercept just InterfaceProtocol 0 therefore still doesn't work.

Having talked to @cillian64 about it, it does appear that libinput can do something similar, thereby avoiding the maintenance hell of having to have device specific udev rules for every USB touch screen out there.

@6by9 6by9 closed this Sep 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants