作者jserv (松鼠)
看板LinuxDev
标题Re: [问题] ubuntu 9.04 抓取hid (mouse) 的疑问..
时间Sun Aug 2 12:11:54 2009
※ 引述《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