作者eleghost (Work Smart)
看板C_and_CPP
標題[問題] linux 抓取 mouse event
時間Wed Jul 1 21:58:07 2009
我使用 VMware, Ubuntu 9.04 (2.6.28)...
現在要再user space上面抓取 usb mouse 的event, 譬如說滑鼠移動...
或是按滑鼠按鍵的event, 請問這可以透過 ioctl 的kernel內建opcode
達成嗎? 還是要去改寫 預設 mouse的driver才可以?
謝謝!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.117.196.92
1F:推 cole945:比較直接的方法是..你可以讀/dev/input/ 下的dev node.. 07/02 01:33
2F:→ cole945:每一個event,像是click/move都是一個 strcut input_event 07/02 01:34
3F:→ cole945:的結構.. 至於哪個是mouse, 你應該要查一下/proc/bus/inp 07/02 01:35
4F:→ cole945:/prob/bus/input/(應該是這個路徑吧)下面好像有個devices 07/02 01:35
5F:→ cole945:的檔案,你打開來看就知道哪個是mouse了.. 07/02 01:36
6F:→ eleghost:我現在是可以知道他是在 /dev/input/event6, 07/02 21:44
7F:→ eleghost:可是當我要對他抓資訊時, 他都會回error.. 07/02 21:44
8F:→ eleghost:我使用ioctl(fd, HIDIOCVERSION ...), 無法抓到version 07/02 21:45
9F:→ eleghost:這樣子我不清楚我的是我開錯device, 還是usb mouse本身不 07/02 21:45
10F:→ eleghost:支援, 還是其他原因? 謝謝 07/02 21:45