X11

如何在不使用製造商字元串的情況下獲取觸摸屏的 xinput 設備 ID?

  • October 20, 2021

在以下設備的情況下,當提供的 ID 參數為 7 時,Chromium 僅顯示正確的觸摸屏行為。請注意,xinput ID 在重新啟動期間會發生變化,所以我不能一直使用 7。

我知道我可以將製造商字元串列入白名單,但我想要一些可靠的東西,它始終有效,並且不依賴於製造商字元串保持不變。

設備 1:

Touchscreen Hardware on device 1 (reported by xinput):
? Virtual core pointer id=2 [master pointer (3)]
? ? Virtual core XTEST pointer id=4 [slave pointer (2)]
? ? ADS7846 Touchscreen id=9 [slave pointer (2)]
? ? NHD Newhaven Display id=7 [slave pointer (2)]
? Virtual core keyboard id=3 [master keyboard (2)]
? Virtual core XTEST keyboard id=5 [slave keyboard (3)]
? 30370000.snvs:snvs-powerkey id=6 [slave keyboard (3)]
? Dell Dell USB Entry Keyboard id=8 [slave keyboard (3)]
/dev/input/touchscreen0 -> /dev/input/event1
udevadm info --query=property --name=/dev/input/event1
DEVLINKS=/dev/input/by-id/usb-NHD_Newhaven_Display-event-if00 /dev/input/by-path/platform-ci_hdrc.0-usb-0:1:1.0-event /dev/input/touchscreen0
DEVNAME=/dev/input/event1
DEVPATH=/devices/soc0/soc/30800000.aips-bus/30b10000.usb/ci_hdrc.0/usb1/1-1/1-1:1.0/0003:0461:0022.005C/input/input93/event1
ID_BUS=usb
ID_INPUT=1
ID_INPUT_TOUCHSCREEN=1
ID_MODEL=Newhaven_Display
ID_MODEL_ENC=Newhavenx20Displayx20
ID_MODEL_ID=0022
ID_PATH=platform-ci_hdrc.0-usb-0:1:1.0
ID_PATH_TAG=platform-ci_hdrc_0-usb-0_1_1_0
ID_REVISION=0100
ID_SERIAL=NHD_Newhaven_Display
ID_TYPE=hid
ID_USB_DRIVER=usbhid
ID_USB_INTERFACES=:030102:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=NHD
ID_VENDOR_ENC=NHD
ID_VENDOR_ID=0461
LIBINPUT_CALIBRATION_MATRIX=1.066870 -0.005907 -0.026620 0.007245 -1.136364 1.046200
LIBINPUT_DEVICE_GROUP=3/461/22:usb-ci_hdrc.0-1
MAJOR=13
MINOR=65
SUBSYSTEM=input
USEC_INITIALIZED=514876494495

設備 2:

Touchscreen Hardware on device 2 (reported by xinput):
? Virtual core pointer id=2 [master pointer (3)]
? Virtual core XTEST pointer id=4 [slave pointer (2)]
? Silicon Integrated System Co. SiS HID Touch Controller Mouse id=8 [slave pointer (2)]
? Silicon Integrated System Co. SiS HID Touch Controller Touchscreen id=7 [slave pointer (2)]
? ADS7846 Touchscreen id=9 [slave pointer (2)]
? Virtual core keyboard id=3 [master keyboard (2)]
? Virtual core XTEST keyboard id=5 [slave keyboard (3)]
? 30370000.snvs:snvs-powerkey id=6 [slave keyboard (3)]
/dev/input/touchscreen0 -> /dev/input/event3 (event1 seems like the correct touchscreen though,
based on the udevadm output)
udevadm info --query=property --name=/dev/input/event1
DEVLINKS=/dev/input/by-path/platform-ci_hdrc.0-usb-0:1:1.0-event /dev/input/touchscreen0 /dev/input/by-id/usb-Silicon_Integrated_System_Co._SiS_HID_Touch_Controller-event-if00
DEVNAME=/dev/input/event1
DEVPATH=/devices/soc0/soc/30800000.aips-bus/30b10000.usb/ci_hdrc.0/usb1/1-1/1-1:1.0/0003:04E7:1080.0001/input/input1/event1
ID_BUS=usb
ID_INPUT=1
ID_INPUT_HEIGHT_MM=136
ID_INPUT_TOUCHSCREEN=1
ID_INPUT_WIDTH_MM=215
ID_MODEL=SiS_HID_Touch_Controller
ID_MODEL_ENC=SiSx20HIDx20Touchx20Controller
ID_MODEL_ID=1080
ID_PATH=platform-ci_hdrc.0-usb-0:1:1.0
ID_PATH_TAG=platform-ci_hdrc_0-usb-0_1_1_0
ID_REVISION=0100
ID_SERIAL=Silicon_Integrated_System_Co._SiS_HID_Touch_Controller
ID_TYPE=hid
ID_USB_DRIVER=usbhid
ID_USB_INTERFACES=:030000:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=Silicon_Integrated_System_Co.
ID_VENDOR_ENC=Siliconx20Integratedx20Systemx20Co.
ID_VENDOR_ID=04e7
LIBINPUT_CALIBRATION_MATRIX=1.066870 -0.005907 -0.026620 0.007245 -1.136364 1.046200
LIBINPUT_DEVICE_GROUP=3/4e7/1080:usb-ci_hdrc.0-1
MAJOR=13
MINOR=65
SUBSYSTEM=input
USEC_INITIALIZED=8612683

編輯:

這是 xinput list –long 的輸出。(我刪除了不相關的設備):

⎜   ↳ ADS7846 Touchscreen                       id=7    [slave  pointer  (2)]
       Reporting 4 classes:
               Class originated from: 7. Type: XIButtonClass
               Buttons supported: 5
               Button labels: "Button Unknown" "Button Unknown" "Button Unknown" "Button Wheel Up" "Button Wheel Down"
               Button state:
               Class originated from: 7. Type: XIValuatorClass
               Detail for Valuator 0:
                 Label: Abs X
                 Range: 0.000000 - 4095.000000
                 Resolution: 0 units/m
                 Mode: absolute
                 Current value: 512.000000
               Class originated from: 7. Type: XIValuatorClass
               Detail for Valuator 1:
                 Label: Abs Y
                 Range: 0.000000 - 4095.000000
                 Resolution: 0 units/m
                 Mode: absolute
                 Current value: 384.000000
               Class originated from: 7. Type: XIValuatorClass
               Detail for Valuator 2:
                 Label: Abs Pressure
                 Range: 0.000000 - 255.000000
                 Resolution: 0 units/m
                 Mode: absolute
                 Current value: 0.000000
⎜   ↳ NHD Newhaven Display                      id=8    [slave  pointer  (2)]
       Reporting 3 classes:
               Class originated from: 8. Type: XIButtonClass
               Buttons supported: 5
               Button labels: "Button Unknown" "Button Unknown" "Button Unknown" "Button Wheel Up" "Button Wheel Down"
               Button state:
               Class originated from: 8. Type: XIValuatorClass
               Detail for Valuator 0:
                 Label: Abs X
                 Range: 0.000000 - 10000.000000
                 Resolution: 0 units/m
                 Mode: absolute
                 Current value: 4379.000000
               Class originated from: 8. Type: XIValuatorClass
               Detail for Valuator 1:
                 Label: Abs Y
                 Range: 0.000000 - 10000.000000
                 Resolution: 0 units/m
                 Mode: absolute
                 Current value: 7896.000000

我最終做的是對所有 /dev/input/event* 節點執行以下命令:

udevadm info --query=property --name=<event-node>

由於我正在搜尋一個通過 USB 連接的觸摸屏設備,因此我在輸出中搜尋了輸出包含以下內容的情況:

ID_INPUT_TOUCHSCREEN = 1
ID_BUS = usb

然後我必須對所有 xinput ID 使用以下命令(您可以使用 xinput list –id-only 獲取 ID 列表):

xinput list-props <ID> | grep <touchscreen-input-node>

這給了我提供鉻的 –touch-devices 參數所需的 ID。

引用自:https://unix.stackexchange.com/questions/671817