![문자 장치(마우스, 키보드, 터치스크린 등) 디버그 및 입력 데이터 읽기](https://linux55.com/image/15413/%EB%AC%B8%EC%9E%90%20%EC%9E%A5%EC%B9%98(%EB%A7%88%EC%9A%B0%EC%8A%A4%2C%20%ED%82%A4%EB%B3%B4%EB%93%9C%2C%20%ED%84%B0%EC%B9%98%EC%8A%A4%ED%81%AC%EB%A6%B0%20%EB%93%B1)%20%EB%94%94%EB%B2%84%EA%B7%B8%20%EB%B0%8F%20%EC%9E%85%EB%A0%A5%20%EB%8D%B0%EC%9D%B4%ED%84%B0%20%EC%9D%BD%EA%B8%B0.png)
저는 적외선을 사용하는 프로젝트를 진행 중입니다.멀티 터치 프레임USB 케이블을 통해 PC에 연결하면 물체(예: 손/손가락)가 통과할 때마다 마우스 역할을 합니다.
제가 하고 싶은 것은 지나가는 물체의 좌표를 출력하는 것입니다. 장치가 PC와 어떻게 통신하는지 이해할 수 있다면 (가능한 경우) 좌표의 x 및 y 값을 인쇄하는 프로그램을 작성할 수 있을 것이라고 생각했습니다. 이러한 유형의 장치를 문자 장치라고도 하며 이를 디버깅하고 컴퓨터로 보내는 입력을 읽을 수 있는 방법이 있는지 궁금했습니다. (내 손이 있는 위치의 x 및 y 좌표에 대한 입력을 보낸다고 가정합니다. 간다) 이렇게 하면 마우스 커서가 그곳으로 이동합니다.
이것은 내 전공 분야가 아니며, 나는 컴퓨터 엔지니어이기 때문에 어떻게 시작해야 할지 모르겠습니다. 어떤 조언이라도 대단히 감사하겠습니다. 미리 감사드립니다..
lsusb
출력 은 다음 과 같습니다 .
mohammedaabdu@Mohammed-HP-Pavilion-Gaming-Notebook:~$ lsusb -D /dev/bus/usb/001/008
Device: ID 1870:010d Nexio Co., Ltd
Couldn't open device, some information will be missing
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x1870 Nexio Co., Ltd
idProduct 0x010d
bcdDevice 5.a1
iManufacturer 1
iProduct 2
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x0029
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xc0
Self Powered
MaxPower 500mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.11
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 736
Report Descriptors:
** UNAVAILABLE **
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 1
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 1
이것은 dmesg 출력입니다:
[ 7907.643318] usb 1-1: new full-speed USB device number 5 using xhci_hcd
[ 7907.792675] usb 1-1: New USB device found, idVendor=1870, idProduct=010d, bcdDevice= 5.a1
[ 7907.792681] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 7907.792684] usb 1-1: Product: Nexio HID Multi-Touch ATI0320-10
[ 7907.792687] usb 1-1: Manufacturer: Nexio Touch Device (HS)
[ 7907.798615] input: Nexio Touch Device (HS) Nexio HID Multi-Touch ATI0320-10 Touchscreen as /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/0003:1870:010D.0002/input/input22
[ 7907.855645] input: Nexio Touch Device (HS) Nexio HID Multi-Touch ATI0320-10 Mouse as /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/0003:1870:010D.0002/input/input23
[ 7907.856502] input: Nexio Touch Device (HS) Nexio HID Multi-Touch ATI0320-10 as /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/0003:1870:010D.0002/input/input24
[ 7907.857637] hid-generic 0003:1870:010D.0002: input,hiddev1,hidraw1: USB HID v1.11 Mouse [Nexio Touch Device (HS) Nexio HID Multi-Touch ATI0320-10] on usb-0000:00:14.0-1/input0
[ 7908.181472] input: Nexio Touch Device (HS) Nexio HID Multi-Touch ATI0320-10 as /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/0003:1870:010D.0002/input/input26
[ 7908.182031] input: Nexio Touch Device (HS) Nexio HID Multi-Touch ATI0320-10 as /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/0003:1870:010D.0002/input/input28
[ 7908.182632] hid-multitouch 0003:1870:010D.0002: input,hiddev1,hidraw1: USB HID v1.11 Mouse [Nexio Touch Device (HS) Nexio HID Multi-Touch ATI0320-10] on usb-0000:00:14.0-1/input0
답변1
이미 마우스처럼 동작하는 경우 마우스 이벤트에서 직접 좌표를 가져올 수 있습니다.
이를 수행하는 방법에는 여러 가지가 있습니다. 예를 들어 라이브러리가 있는 Python 프로그램파이썬-libinput.
xev
이벤트도 표시됩니다.
또는 루트로서 evtest
에서 읽고 있는 내용을 사람이 읽을 수 있는 버전으로 인쇄합니다 /dev/ìnput/eventX
.
일부 하드웨어는 시스템에 여러 장치(예: 마우스 및 키보드)로 나타납니다.
xinput --list
어떤 입력 장치가 있는지 알려줍니다. 어느 장치가 올바른지 확실하지 않은 경우 플러그를 뽑았다가 다시 연결하여 차이점을 확인할 수 있습니다.
이러한 경우 원시 데이터가 아닌 원시 이벤트에 액세스하게 됩니다.
이제 시작해야 합니다. 그것에 관한 많은 문서가 있습니다 libinput
.