1、查看输入设备节点信息
adb shell cat /proc/bus/input/devices
I: Bus=0019 Vendor=0000 Product=0000 Version=0000
N: Name="ACCDET"
P: Phys=
S: Sysfs=/devices/virtual/input/input0
U: Uniq=
H: Handlers=gpufreq_ib event0
B: PROP=0
B: EV=3
B: KEY=40 0 0 0 0 0 0 1000000000 c000000000000 0
I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="fpsensor"
P: Phys=
S: Sysfs=/devices/virtual/input/input1
U: Uniq=
H: Handlers=gpufreq_ib event1
B: PROP=0
B: EV=3
B: KEY=40008000 800010 0
I: Bus=0019 Vendor=2454 Product=6500 Version=0010
N: Name="mtk-kpd"
P: Phys=
S: Sysfs=/devices/soc/10003000.keypad/input/input2
U: Uniq=
H: Handlers=gpufreq_ib event2
B: PROP=0
B: EV=3
B: KEY=1c004000000000 0
I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="hwmdata"
P: Phys=
S: Sysfs=/devices/virtual/input/input3
U: Uniq=
H: Handlers=gpufreq_ib event3
B: PROP=0
B: EV=5
B: REL=6
I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="m_alsps_input"
P: Phys=
S: Sysfs=/devices/virtual/input/input4
U: Uniq=
H: Handlers=gpufreq_ib event4
B: PROP=0
B: EV=d
B: REL=6
B: ABS=101
I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="m_acc_input"
P: Phys=
S: Sysfs=/devices/virtual/input/input5
U: Uniq=
H: Handlers=gpufreq_ib event5
B: PROP=0
B: EV=d
B: REL=c1
B: ABS=107
I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="m_mag_input"
P: Phys=
S: Sysfs=/devices/virtual/input/input6
U: Uniq=
H: Handlers=gpufreq_ib event6
B: PROP=0
B: EV=d
B: REL=3c9
B: ABS=17f
I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="mtk-tpd"
P: Phys=
S: Sysfs=/devices/virtual/input/input7
U: Uniq=
H: Handlers=gpufreq_ib event7
B: PROP=2
B: EV=b
B: KEY=400 0 0 100040000800 0 0
B: ABS=263000001000003
I: Bus=0019 Vendor=0001 Product=0001 Version=0100
N: Name="mtk-tpd-kpd"
P: Phys=
S: Sysfs=/devices/virtual/input/input8
U: Uniq=
H: Handlers=gpufreq_ib event8
B: PROP=0
B: EV=3
B: KEY=100040000800 0 0
通过这些信息可以大概知道,哪个输入设备对应哪个节点,然后再用下面的命令来查看具体的输入事件的内容。
2、查看输入事件的内容。
adb shell getevent -t /dev/input/event2
[ 5315.440691] 0001 0074 00000001
[ 5315.440691] 0000 0000 00000000
[ 5316.270721] 0001 0074 00000000
[ 5316.270721] 0000 0000 00000000
[ 5415.035780] 0001 0073 00000001
[ 5415.035780] 0000 0000 00000000
[ 5415.298666] 0001 0073 00000000
[ 5415.298666] 0000 0000 00000000
[ 5417.784254] 0001 0072 00000001
[ 5417.784254] 0000 0000 00000000
[ 5417.899389] 0001 0072 00000000
[ 5417.899389] 0000 0000 00000000
上面是电源键、音量上键和音量下键按下并抬起时由内核生成的原始事件信息。可以看出按键的输入事件类型编码为0001,电源键的扫描码为0074、音量上键0073、音量下键0072,值00000001表示按下、00000000表示抬起。但这些值会随着设备类型及厂商的不同而有所区别。
当然,也可以通过sendevent往设备节点中写入输入事件,但尝试数次都没有成功,具体原因不明,如有知道者,还请分享。
adb shell sendevent /dev/input/event2 1 116 1
adb shell sendevent /dev/input/event2 1 116 0