Android 本身有一个genevnet 和 sendevent 工具用来从内核获取event事件和向内核发送event事件,具体可以参考 Android 下收发input事件的工具 getevent 和 sendevent
o get_evnet 是一个可以获得注册成input设备上报event的调试工具。
o usage: get_event /dev/input/eventX, X is 0, 1, 2,3, 4, 5,6
o 附件为其源代码, 可以采用静态编译,然后通过adb push进 手机, 进行调试。
arm-linux-gcc -static get_event.c -o get_evnet
-> 获得 红外gp2ap 的上报 event
shell@android:/ # get_event /dev/input/event0Input driver version is 1.0.1
Input device ID: bus 0x0 vendor 0x0 product 0x0 version 0x0
Input device name: gp2ap
Supported events:
Event type 0 (Sync)
Event type 3 (Absolute)
Event code 25 (Distance)
Value -1
Min 0
Max 1
Event code 40 (Misc)
Value 0
Min 0
Max 65535
Testing ... (interrupt to exit)
-> 获得touchscreen 的上报 event
130|shell@android:/ # get_event /dev/input/event1Input driver version is 1.0.1
Input device ID: bus 0x18 vendor 0x0 product 0x1 version 0x1005
Input device name: mx_ts
Supported events:
Event type 0 (Sync)
Event type 1 (Key)
Event code 102 (Home)
Event code 103 (Up)
Event code 105 (Left)
Event code 106 (Right)
Event code 107 (End)
Event code 108 (Down)
Event code 129 (Again)
Event code 158 (Back)
Event code 325 (ToolFinger)
Event code 330 (Touch)
Event type 3 (Absolute)
Event code 0 (X)
Value 0
Min 0
Max 1334
Event code 1 (Y)
Value 0
Min 0
Max 2214
Event code 24 (Pressure)
Value 0
Min 0
Max 255
Event code 47 (?)
Value 0
Min 0
Max 9
Event code 48 (ABS_MT_TOUCH_MAJOR)
Value 0
Min 0
Max 15
Event code 53 (ABS_MT_POSITION_X)
Value 0
Min 0
Max 1334
Event code 54 (ABS_MT_POSITION_Y)
Value 0
Min 0
Max 2214
Event code 57 (ABS_MT_TRACKING_ID)
Value 0
Min 0
Max 65535
Event code 58 (ABS_MT_PRESSURE)
Value 0
Min 0
Max 255
Testing ... (interrupt to exit)
Event: time 1325376099.794968, type 3 (Absolute), code 57 (ABS_MT_TRACKING_ID), value 0
Event: time 1325376099.794990, type 1 (Key), code 330 (Touch), value 1
Event: time 1325376099.794999, type 1 (Key), code 325 (ToolFinger), value 1
Event: time 1325376099.795009, type 3 (Absolute), code 53 (ABS_MT_POSITION_X), value 738
Event: time 1325376099.795018, type 3 (Absolute), code 54 (ABS_MT_POSITION_Y), value 1487
Event: time 1325376099.795027, type 3 (Absolute), code 58 (ABS_MT_PRESSURE), value 84
Event: time 1325376099.795036, type 3 (Absolute), code 48 (ABS_MT_TOUCH_MAJOR), value 4
Event: time 1325376099.795090, -------------- Report Sync ------------
Event: time 1325376099.903355, type 3 (Absolute), code 57 (ABS_MT_TRACKING_ID), value -1
Event: time 1325376099.903432, -------------- Report Sync ------------
-> 获得物理按键key 的上报 event
130|shell@android:/ # get_event /dev/input/event2Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100
Input device name: gpio-keys
Supported events:
Event type 0 (Sync)
Event type 1 (Key)
Event code 102 (Home)
Event code 114 (VolumeDown)
Event code 115 (VolumeUp)
Event code 116 (Power)
Testing ... (interrupt to exit)
Event: time 1325376161.600192, type 1 (Key), code 115 (VolumeUp), value 1
Event: time 1325376161.600214, -------------- Report Sync ------------
Event: time 1325376161.794925, type 1 (Key), code 115 (VolumeUp), value 0
Event: time 1325376161.794933, -------------- Report Sync ------------
Event: time 1325376162.645193, type 1 (Key), code 102 (Home), value 1
Event: time 1325376162.645215, -------------- Report Sync ------------
Event: time 1325376162.794977, type 1 (Key), code 102 (Home), value 0
Event: time 1325376162.794995, -------------- Report Sync ------------
Event: time 1325376164.970050, type 1 (Key), code 114 (VolumeDown), value 1
Event: time 1325376164.970072, -------------- Report Sync ------------
Event: time 1325376164.975038, type 1 (Key), code 114 (VolumeDown), value 0
Event: time 1325376164.975058, -------------- Report Sync ------------
Event: time 1325376165.000110, type 1 (Key), code 114 (VolumeDown), value 1
Event: time 1325376165.000135, -------------- Report Sync ------------
Event: time 1325376165.005173, type 1 (Key), code 114 (VolumeDown), value 0
Event: time 1325376165.005190, -------------- Report Sync ------------
Event: time 1325376166.700714, type 1 (Key), code 116 (Power), value 1
Event: time 1325376166.700737, -------------- Report Sync ------------
Event: time 1325376167.005092, type 1 (Key), code 116 (Power), value 0
Event: time 1325376167.005110, -------------- Report Sync ------------
-> 获得headset 的上报 event
130|shell@android:/ # get_event /dev/input/event3Input driver version is 1.0.1
Input device ID: bus 0x0 vendor 0x0 product 0x0 version 0x0
Input device name: Headset
Supported events:
Event type 0 (Sync)
Event type 1 (Key)
Event code 226 (Media)
Event code 259