android getevent sendevent input 接收发送事件
安卓笔记侠
共 8465字,需浏览 17分钟
·
2020-11-18 11:49
getevent
yifeng:/ $ getevent -help
Usage: 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
yifeng:/ $ getevent
add device 1: /dev/input/event7
name: "uinput_nav"
add device 2: /dev/input/event6
name: "sdm660-snd-card Button Jack"
add device 3: /dev/input/event5
name: "sdm660-snd-card Headset Jack"
add device 4: /dev/input/event3
name: "uinput-goodix"
could not get driver version for /dev/input/mice, Not a typewriter
add device 5: /dev/input/event1
name: "ant_check-input"
add device 6: /dev/input/event4
name: "gpio-keys"
add device 7: /dev/input/event0
name: "qpnp_pon"
add device 8: /dev/input/event2
name: "NVTCapacitiveTouchScreen"
......
add device 8: /dev/input/event2
name: "NVTCapacitiveTouchScreen"
events:
KEY (0001): 008f 014a
ABS (0003): 002f : value 0, min 0, max 9, fuzz 0, flat 0, resolution 0
0035 : value 0, min 0, max 1079, fuzz 0, flat 0, resolution 0
0036 : value 0, min 0, max 2339, fuzz 0, flat 0, resolution 0
0039 : value 0, min 0, max 65535, fuzz 0, flat 0, resolution 0
003a : value 0, min 0, max 1000, fuzz 0, flat 0, resolution 0
input props:
INPUT_PROP_DIRECT
adb shell dumpsys window displays
adb shell wm size
/dev/input/event4: 0001 0073 00000001
/dev/input/event4: 0000 0000 00000000
/dev/input/event4: 0001 0073 00000000
/dev/input/event4: 0000 0000 00000000
/*
* Event types
*/
#define EV_SYN 0x00
#define EV_KEY 0x01
#define EV_REL 0x02
#define EV_ABS 0x03
#define EV_MSC 0x04
#define EV_SW 0x05
#define EV_LED 0x11
#define EV_SND 0x12
#define EV_REP 0x14
#define EV_FF 0x15
#define EV_PWR 0x16
#define EV_FF_STATUS 0x17
#define EV_MAX 0x1f
#define EV_CNT (EV_MAX+1)
#define KEY_VOLUMEDOWN 114
#define KEY_VOLUMEUP 115
yifeng:/ $ getevent -l
......
/dev/input/event4: EV_KEY KEY_VOLUMEUP DOWN
/dev/input/event4: EV_SYN SYN_REPORT 00000000
/dev/input/event4: EV_KEY KEY_VOLUMEUP UP
/dev/input/event4: EV_SYN SYN_REPORT 00000000
/dev/input/event2: 0003 0039 0000008b
/dev/input/event2: 0003 0035 000003c2
/dev/input/event2: 0003 0036 00000134
/dev/input/event2: 0003 003a 000003e8
/dev/input/event2: 0001 014a 00000001
/dev/input/event2: 0000 0000 00000000
/dev/input/event2: 0003 003a 00000000
/dev/input/event2: 0003 0039 ffffffff
/dev/input/event2: 0001 014a 00000000
/dev/input/event2: 0000 0000 00000000
#define ABS_MT_SLOT 0x2f /* MT slot being modified */
#define ABS_MT_TOUCH_MAJOR 0x30 /* Major axis of touching ellipse */
#define ABS_MT_TOUCH_MINOR 0x31 /* Minor axis (omit if circular) */
#define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse */
#define ABS_MT_WIDTH_MINOR 0x33 /* Minor axis (omit if circular) */
#define ABS_MT_ORIENTATION 0x34 /* Ellipse orientation */
#define ABS_MT_POSITION_X 0x35 /* Center X ellipse position */
#define ABS_MT_POSITION_Y 0x36 /* Center Y ellipse position */
#define ABS_MT_TOOL_TYPE 0x37 /* Type of touching device */
#define ABS_MT_BLOB_ID 0x38 /* Group a set of packets as a blob */
#define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */
#define ABS_MT_PRESSURE 0x3a /* Pressure on contact area */
#define ABS_MT_DISTANCE 0x3b /* Contact hover distance */
/dev/input/event2: EV_ABS ABS_MT_TRACKING_ID 0000008a
/dev/input/event2: EV_ABS ABS_MT_POSITION_X 000003b3
/dev/input/event2: EV_ABS ABS_MT_POSITION_Y 0000014c
/dev/input/event2: EV_ABS ABS_MT_PRESSURE 000003e8
/dev/input/event2: EV_KEY BTN_TOUCH DOWN
/dev/input/event2: EV_SYN SYN_REPORT 00000000
/dev/input/event2: EV_ABS ABS_MT_PRESSURE 00000000
/dev/input/event2: EV_ABS ABS_MT_TRACKING_ID ffffffff
/dev/input/event2: EV_KEY BTN_TOUCH UP
/dev/input/event2: EV_SYN SYN_REPORT 00000000
sendevent
yifeng:/ $ sendevent --help
usage: sendevent DEVICE TYPE CODE VALUE
Sends a Linux input event.
sendevent /dev/input/event2 0003 0039 00000095
sendevent /dev/input/event2 0003 0035 0000039b
sendevent /dev/input/event2 0003 0036 0000014a
sendevent /dev/input/event2 0003 003a 000003e8
sendevent /dev/input/event2 0001 014a 00000001
sendevent /dev/input/event2 0000 0000 00000000
sendevent /dev/input/event2 0003 003a 00000000
sendevent /dev/input/event2 0003 0039 ffffffff
sendevent /dev/input/event2 0001 014a 00000000
sendevent /dev/input/event2 0000 0000 00000000
chmod 777 /dev/input/event2
input
yifeng:/ $ input
Usage: input [
input text "hello world"
input tap 100 500
注意事项
yifeng:/ $ getevent
could not open /dev/input/event7, Permission denied
could not open /dev/input/event6, Permission denied
could not open /dev/input/event5, Permission denied
could not open /dev/input/event3, Permission denied
could not open /dev/input/mice, Permission denied
could not open /dev/input/event1, Permission denied
could not open /dev/input/event4, Permission denied
could not open /dev/input/event0, Permission denied
could not open /dev/input/event2, Permission denied
yifeng:/ $ input text "hello world"
Killed
长按识别二维码,即可关注我
评论