遇到了个命令:
getevent -pl 2>&1 | sed -n '/^add/h/ABS_MT_TOUCH/{x;s/[^/]*//p}'
getevent -pl 2>&1
的输出是这样的:
HWMHA:/ $ getevent -pl 2>&1
add device 1: /dev/input/event5
name: "huawei,touchscreen"
events:
KEY (0001): KEY_F1 KEY_F2 KEY_F3 KEY_F4
KEY_F5 KEY_F7 KEY_F8 KEY_F9
KEY_F10 KEY_F11 KEY_F12 KEY_F19
KEY_F20 KEY_F21 KEY_F22 KEY_F23
BTN_TOOL_FINGER BTN_TOUCH
ABS (0003): ABS_X : value 40, min 0, max 1079, fuzz 0, flat 0, resolution 0
ABS_Y : value 210, min 0, max 1919, fuzz 0, flat 0, resolution 0
ABS_PRESSURE : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
ABS_MT_TOUCH_MAJOR : value 0, min 0, max 15, fuzz 0, flat 0, resolution 0
ABS_MT_WIDTH_MAJOR : value 0, min 0, max 100, fuzz 0, flat 0, resolution 0
ABS_MT_WIDTH_MINOR : value 0, min 0, max 100, fuzz 0, flat 0, resolution 0
ABS_MT_POSITION_X : value 0, min 0, max 1079, fuzz 0, flat 0, resolution 0
ABS_MT_POSITION_Y : value 0, min 0, max 1919, fuzz 0, flat 0, resolution 0
ABS_MT_TRACKING_ID : value 0, min 0, max 15, fuzz 0, flat 0, resolution 0
ABS_MT_PRESSURE : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
input props:
INPUT_PROP_DIRECT
could not get driver version for /dev/input/mouse0, Not a typewriter
add device 2: /dev/input/event2
name: "hisi_on"
events:
KEY (0001): KEY_POWER
input props:
<none>
add device 3: /dev/input/event1
name: "hisi_gpio_key"
events:
KEY (0001): KEY_VOLUMEDOWN KEY_VOLUMEUP
input props:
<none>
add device 4: /dev/input/event3
name: "fingerprint"
events:
KEY (0001): KEY_ENTER KEY_SEMICOLON KEY_GRAVE KEY_LEFTSHIFT
KEY_Z KEY_V KEY_N KEY_UP
KEY_LEFT KEY_RIGHT KEY_DOWN KEY_INSERT
KEY_DELETE KEY_MUTE KEY_EXIT
input props:
<none>
add device 5: /dev/input/event4
name: "hi3660_HI6403_CARD Headset Jack"
events:
KEY (0001): KEY_VOLUMEDOWN KEY_VOLUMEUP KEY_F14 KEY_MEDIA
SW (0005): SW_HEADPHONE_INSERT SW_MICROPHONE_INSERT
input props:
<none>
add device 6: /dev/input/event0
name: "soundtrigger_input_dev"
events:
KEY (0001): KEY_F14 KEY_F15 KEY_F16 KEY_F17
KEY_F18
input props:
<none>
could not get driver version for /dev/input/mice, Not a typewriter
那 sed -n '/^add/h/ABS_MT_TOUCH/{x;s/[^/]*//p}'
是干啥的呢?
s/[^/]*//p
是把替换过来的 add device 1: /dev/input/event5,把到第一个 / 位置的字符串替换为空,就变成了 /dev/input/event5