Android手机下getevent/sendevent,源代码路径system/core/toolbox/下,sendevent.c getevent.c getevent.h
getevent
使用getevent获得/dev/input/eventX设备汇报的事件,这个命令还会输出所有event设备的基本信息,
add device 1: /dev/input/event2
name: "qpnp_pon"
add device 2: /dev/input/event0
name: "sensorprocessor"
could not get driver version for /dev/input/mice, Not a typewriter
add device 3: /dev/input/event5
name: "gpio-keys"
add device 4: /dev/input/event4
name: "msm8994-florida-snd-card Headset Jack"
add device 5: /dev/input/event3
name: "msm8994-florida-snd-card Button Jack"
add device 6: /dev/input/event1
name: "synaptics_dsx_i2c"
其中如上对应关系
device 6: /dev/input/event1:"synaptics_dsx_i2c" ===》显示屏touchscreen
device 3: /dev/input/event5:"gpio-keys" ===》键盘keypad
device 1: /dev/input/event2: "qpnp_pon" ===》按键pwrkey
Android可以使用sendevent来模拟触屏,键盘以及其他类型的event事件,
sendevent /dev/input/eventX type code value
/dev/input/eventX 对应一个event设备,可以通过getevent获得可用的event设备
type, code, value的定义可参看kernel/include/linux/input.h和kernel/include/uapi/input.h
input
/dev/input目录下的事件都是在驱动中调用input_register_device(struct input_dev *dev)产生的。root@:/dev/input # ll
ll
crw-rw---- root input 13, 64 1970-01-15 11:37 event0
crw-rw---- root input 13, 65 1970-01-15 11:37 event1
crw-rw---- root input 13, 66 1970-01-15 11:37 event2
crw-rw---- root input 13, 67 1970-01-15 11:37 event3
crw-rw---- root input 13, 68 1970-01-15 11:37 event4
crw-rw---- root input 13, 69 1970-01-15 11:37 event5
crw-rw---- root input 13, 63 1970-01-15 11:37 mice
与event对应的相关设备信息位于/proc/bus/input/devices,