※ 引述《eleghost (Work Smart)》之銘言:
: 請問, 我的系統是ubuntu9.04 , 然後我現在要利用ioctl
: 抓到hid mouse的event(左鍵, 右鍵, 滾輪等)
: 可是我現在不知道當usb mouse插入時, 在/dev/input/ 下是對印哪個
: device...也沒有log可以判斷, 請問該怎麼做呢? 謝謝!
比方說 USB mouse 插入到 PC 的 USB slot 時,dmesg 會取得類似以下的訊息:
[130905.079131] input: HID 04b3:3107 as
/devices/pci0000:00/0000:00:1d.0/usb2/2-2/2-2:1.0/input/input10
[130905.079460] generic-usb 0003:04B3:3107.0001: input,hidraw0: USB HID
v11.10 Mouse [HID 04b3:3107] on usb-0000:00:1d.0-2/input0
[130905.079500] usbcore: registered new interface driver usbhid
[130905.079555] usbhid: v2.6:USB HID core driver
接著去 /sys 找尋: (dmesg 第一行)
# ls -l /sys"/devices/pci0000:00/0000:00:1d.0/usb2/2-2/2-2:1.0/input/input10"
drwxr-xr-x 2 root root 0 2009-08-02 12:04 capabilities
lrwxrwxrwx 1 root root 0 2009-08-02 12:08 device -> ../../../2-2:1.0
drwxr-xr-x 3 root root 0 2009-08-02 12:04 event10
drwxr-xr-x 2 root root 0 2009-08-02 12:07 id
-r--r--r-- 1 root root 4096 2009-08-02 12:07 modalias
drwxr-xr-x 3 root root 0 2009-08-02 12:04 mouse2
若系統安裝 udev,那麼 /dev/input 目錄底下就會自動生成 input10 與 mouse2 這
兩個 device file
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.57.131.211