getevent 指令用于获取 input 输入事件,比如获取按键上报信息、获取触摸屏上报信息等。
指令源码路径:/system/core/toolbox/getevent.c
getevent -h:查看 getevent 帮助信息
# getevent -hUsage: getevent [-t] [-n] [-s switchmask] [-S] [-v [mask]] [-d] [-p] [-i] [-l] [-q] [-c count] [-r] [device]-t: show time stamps-n: don't print newlines-s: print switch states for given bits-S: print all switch states-v: verbosity mask (errs=1, dev=2, name=4, info=8, vers=16, pos. events=32, props=64)-d: show HID descriptor, if available-p: show possible events (errs, dev, name, pos. events)-i: show all device info and possible events-l: label event types and names in plain text-q: quiet (clear verbosity mask)-c: print given number of events then exit-r: print rate events are received
getevent:显示当前有那些输入设备,数量与 /dev/input 目录下相同
注意:每次重启,event文件节点和重启前的可能不同。
# getevent
add device 1: /dev/input/event1 #说明:这是LonBon自定义的按键
name: "LonBon Key"
add device 2: /dev/input/event0
name: "Nexell Keypad"
could not get driver version for /dev/input/mouse0, Not a typewriter
add device 3: /dev/input/event2
name: "USB OPTICAL MOUSE "
add device 4: /dev/input/event3 #说明:这是Goodix的触摸屏
name: "Goodix-TS"
could not get driver version for /dev/input/mice, Not a typewriter
查看触摸屏上报的数据:
# getevent /dev/input/event3
0003 0039 00000000 #触按触摸屏就会有数据上报
0003 0035 0000016b
0003 0036 000002d6
0003 0030 00000026
0003 0032 00000026
-v:根据 mask 值显示相关信息,执行后会一直显示上报数据
errs=1, dev=2, name=4, info=8, vers=16, pos. events=32, props=64
默认显示 dev| name| info| vers = 30;
root@s5p4418_lonbon:/data/dropbear # getevent -v /dev/input/event3
add device 1: /dev/input/event3
bus: 0018
vendor dead
product beef
version 28bb
name: "Goodix-TS"
location: "H▒▒ވ▒▒"
id: ""
version: 1.0.1
root@s5p4418_lonbon:/data/dropbear # getevent -v1 /dev/input/event3
root@s5p4418_lonbon:/data/dropbear # getevent -v30 /dev/input/event3
add device 1: /dev/input/event3
bus: 0018
vendor dead
product beef
version 28bb
name: "Goodix-TS"
location: "H▒▒ވ▒▒"
id: ""
version: 1.0.1
root@s5p4418_lonbon:/data/dropbear # getevent -v2 /dev/input/event3
add device 1: /dev/input/event3
root@s5p4418_lonbon:/data/dropbear # getevent -v4 /dev/input/event3
name: "Goodix-TS"
root@s5p4418_lonbon:/data/dropbear # getevent -v8 /dev/input/event3
bus: 0018
vendor dead
product beef
version 28bb
location: "H▒▒ވ▒▒"
id: ""
root@s5p4418_lonbon:/data/dropbear # getevent -v16 /dev/input/event3
version: 1.0.1
root@s5p4418_lonbon:/data/dropbear # getevent -v32 /dev/input/event3
events:
ABS (0003): 002f : value 0, min 0, max 15, fuzz 0, flat 0, resolution 0
0030 : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
0032 : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
0035 : value 0, min 0, max 800, fuzz 0, flat 0, resolution 0
0036 : value 0, min 0, max 1280, fuzz 0, flat 0, resolution 0
0039 : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
root@s5p4418_lonbon:/data/dropbear # getevent -v64 /dev/input/event3
input props:
INPUT_PROP_DIRECT
-d:如果设备可用,显示设备隐藏的描述信息
-p:显示设备支持的事件类型和编码方式
root@s5p4418_lonbon:/data/dropbear # getevent -p /dev/input/event3
add device 1: /dev/input/event3
name: "Goodix-TS"
events:
ABS (0003): 002f : value 0, min 0, max 15, fuzz 0, flat 0, resolution 0
0030 : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
0032 : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
0035 : value 0, min 0, max 800, fuzz 0, flat 0, resolution 0
0036 : value 0, min 0, max 1280, fuzz 0, flat 0, resolution 0
0039 : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
input props:
INPUT_PROP_DIRECT
-i:显示设备的所有信息和支持的事件,比 -p 显示更多信息
root@s5p4418_lonbon:/data/dropbear # getevent -i /dev/input/event3
add device 1: /dev/input/event3
bus: 0018
vendor dead
product beef
version 28bb
name: "Goodix-TS"
location: "H"
id: ""
version: 1.0.1
events:
ABS (0003): 002f : value 0, min 0, max 15, fuzz 0, flat 0, resolution 0
0030 : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
0032 : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
0035 : value 0, min 0, max 800, fuzz 0, flat 0, resolution 0
0036 : value 0, min 0, max 1280, fuzz 0, flat 0, resolution 0
0039 : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
input props:
INPUT_PROP_DIRECT
-l:以文本形式输出事件类型和名称,比 -t 更清楚直观
root@s5p4418_lonbon:/data/dropbear # getevent -l /dev/input/event3
事件类型type 事件码cdode 值 value
EV_ABS ABS_MT_TRACKING_ID 00000000
EV_ABS ABS_MT_POSITION_X 00000258
EV_ABS ABS_MT_POSITION_Y 00000332
EV_SYN SYN_REPORT 00000000
EV_ABS ABS_MT_TRACKING_ID ffffffff
EV_SYN SYN_REPORT 00000000
EV_ABS ABS_MT_TRACKING_ID 00000000
EV_ABS ABS_MT_POSITION_X 0000022a
EV_ABS ABS_MT_POSITION_Y 000002c3
EV_ABS ABS_MT_TOUCH_MAJOR 0000002f
-c:打印固定数量的事件并退出
-r:显示事件上报速率
参数可以组合使用,一次性查看需要的触摸屏信息
常用组合:
- getevent -i /dev/input/event3 && getevent -tl /dev/input/event3
root@s5p4418_lonbon:/data/dropbear # getevent -i /dev/input/event3 && getevent -tl /dev/input/event3 add device 1: /dev/input/event3 bus: 0018 vendor dead product beef version 28bb name: "Goodix-TS" location: "▒?▒▒▒▒" id: "" version: 1.0.1 events: ABS (0003): 002f : value 0, min 0, max 15, fuzz 0, flat 0, resolution 0 0030 : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0 0032 : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0 0035 : value 0, min 0, max 800, fuzz 0, flat 0, resolution 0 0036 : value 0, min 0, max 1280, fuzz 0, flat 0, resolution 0 0039 : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0 input props: INPUT_PROP_DIRECT [ 290.167572] EV_ABS ABS_MT_TRACKING_ID 00000000 [ 290.167598] EV_ABS ABS_MT_POSITION_X 0000029e [ 290.167605] EV_ABS ABS_MT_POSITION_Y 0000034f [ 290.167611] EV_ABS ABS_MT_TOUCH_MAJOR 00000022 [ 290.167615] EV_ABS ABS_MT_WIDTH_MAJOR 00000022 [ 290.167642] EV_SYN SYN_REPORT 00000000
