Udev rule for identical product and vender ID

Hi,

I’ve two identical touch input coming from two different touch screens.
Identical as in the product attributes are same.

Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 006: ID 222a:0001 ILI Technology Corp. Multi-Touch Screen
Bus 001 Device 005: ID 03f0:1041 HP, Inc HP Travel USB Optical Mouse
Bus 001 Device 004: ID 222a:0001 ILI Technology Corp. Multi-Touch Screen
Bus 001 Device 003: ID 1a40:0101 Terminus Technology Inc. Hub

I’ve to map the input devices to two different HDMI displays using UDEV rules.

Associate touchscreen 1 with HDMI-A-1

SUBSYSTEM==“input”, KERNEL==“event2”, ENV{ID_INPUT_TOUCHSCREEN}==“1”, ENV{WL_OUTPUT}=“HDMI-A-1”

Associate touchscreen 2 with HDMI-A-2

SUBSYSTEM==“input”, KERNEL==“event5”, ENV{ID_INPUT_TOUCHSCREEN}==“1”, ENV{WL_OUTPUT}=“HDMI-A-2”

Right now, the above works fine sometimes but since the event ID touch input are not persistent the mapping gets swapped or doesn’t work at all.

/dev/input/event2: ILITEK ILITEK-TP
/dev/input/event3: ILITEK ILITEK-TP Mouse
/dev/input/event4: PixArt HP Travel USB Optical Mouse
/dev/input/event5: ILITEK ILITEK-TP
/dev/input/event6: ILITEK ILITEK-TP Mouse

What can I do to make the usb touch input mapping persistent?

Regards

Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello!

Creating persistent udev rules for touch devices on your Toradex system is a great way to ensure consistent device configuration. Here’s a step-by-step guide to help you set this up:

  1. Create a udev Rule File:

    • Navigate to the /etc/udev/rules.d/ directory.
    • Create a new file for your udev rules. You can use a text editor like nano or vi.
  2. Define Your udev Rules:

    • Use specific device attributes rather than just the event number. Here’s a template to get you started:
      KERNEL=="event*", SUBSYSTEM=="input", ATTRS{name}=="ILITEK ILITEK-TP", ATTRS{<unique_attribute>}=="<value1>", ENV{WL_OUTPUT}="HDMI-A-1"
      KERNEL=="event*", SUBSYSTEM=="input", ATTRS{name}=="ILITEK ILITEK-TP", ATTRS{<unique_attribute>}=="<value2>", ENV{WL_OUTPUT}="HDMI-A-2"
      
  3. Identify Unique Device Attributes:

    • Use the following command to find persistent attributes like the physical device path or serial number:
      udevadm info -a -p $(udevadm info -q path -n /dev/input/eventX)
      
  4. Review Touch Calibration Documentation:

    • Depending on your setup, different display servers and frameworks may handle touch input differently. You can find more information on touch calibration in the Toradex documentation.

If you need further assistance with udev rules configuration, feel free to ask!

Best regards,
Toradex AI Assistant.

Please, also check if these links can help you solve your problem:

Touch Screen Calibration (Linux) | Toradex Developer Center.

The bot has useful commands for looking at udev attributes.

For your particular case, if your touch screens are always connected to a fixed USB port, I would suggest looking at the usb port path. In udev terms, this is the device name of one of the parent devices of your touchscreen device, which you can match using the plural form in your udev rule (e.g. KERNEL matches the touchscreen device itself, KERNELS matches any parent device). For example, the udevadm command given by the bot returns the following lines (and a lot more) for one of the parent devices of a USB keyboard input device:

    KERNELS=="3-2.3.1"
    SUBSYSTEMS=="usb"

Which indicates usb bus 3, port 2 has a hub on which port 3 is used which has a hub on which port 1 is used.

This could be used in your udev rule to distinguish the two touchscreen devices.

Alternatively, the USB serial number is also often used, but that requires per-machine setup to get the right serial numbers (which might work depending on your workflow).

For humans,
The root problem is this itself, my devices has no unique attributes!