Android getevent 工具

getevent 工具可在设备上运行,并可提供关于输入设备和内核输入事件的实时转储的信息。

此工具非常实用,可确保设备驱动程序报告各个输入设备的一系列预期功能并生成输入事件的所需信息流。

显示设备功能

使用带有 adb 命令的 -p 选项来查看设备报告的所有键和轴。

adb shell
su
getevent -p

以下示例是我的华为手机列出了特定键盘所支持的 Linux 键码和其他事件。

HWPRA-H:/ $ getevent -p                                                        
add device 1: /dev/input/event1
  name:     "hisi_on"
  events:
    KEY (0001): 0074 
  input props:
    <none>
add device 2: /dev/input/event0
  name:     "hisi_gpio_key"
  events:
    KEY (0001): 0072  0073 
  input props:
    <none>
add device 3: /dev/input/event2
  name:     "fingerprint"
  events:
    KEY (0001): 001c  0027  0029  002a  002c  002f  0031  0067 
                0069  006a  006c  006e  006f  0071  00ae 
  input props:
    <none>
add device 4: /dev/input/event4
  name:     "cyttsp5_mt"
  events:
    KEY (0001): 003b  003c  003d  003e  003f  0040  0041  0042 
                0043  0044  0057  0058  0074 
    ABS (0003): 002f  : value 0, min 0, max 31, fuzz 0, flat 0, resolution 0
                0030  : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
                0031  : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
                0034  : value 0, min -297, max 127, 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 1919, 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 255, fuzz 0, flat 0, resolution 0
  input props:
    INPUT_PROP_DIRECT
add device 5: /dev/input/event3
  name:     "HI6250_hi6555c_CARD Headset Jack"
  events:
    KEY (0001): 0072  0073  00e2 
    SW  (0005): 0002  0004 
  input props:
    <none>
could not get driver version for /dev/input/mice, Not a typewriter

使用 -i 选项可获取更多信息,包括 HID 映射表和调试信息。

使用 -l 选项可显示所有事件代码的文字标签。

HWPRA-H:/ $ getevent -lpi                                                      
add device 1: /dev/input/event1
  bus:      0000
  vendor    0000
  product   0000
  version   0000
  name:     "hisi_on"
  location: "hisi_on/input0"
  id:       ""
  version:  1.0.1
  events:
    KEY (0001): KEY_POWER            
  input props:
    <none>
add device 2: /dev/input/event0
  bus:      0019
  vendor    0000
  product   0000
  version   0000
  name:     "hisi_gpio_key"
  location: ""
  id:       ""
  version:  1.0.1
  events:
    KEY (0001): KEY_VOLUMEDOWN        KEY_VOLUMEUP         
  input props:
    <none>
add device 3: /dev/input/event2
  bus:      0000
  vendor    0000
  product   0000
  version   0000
  name:     "fingerprint"
  location: ""
  id:       ""
  version:  1.0.1
  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 4: /dev/input/event4
  bus:      0000
  vendor    0000
  product   0000
  version   0000
  name:     "cyttsp5_mt"
  location: "0-001c/input0"
  id:       ""
  version:  1.0.1
  events:
    KEY (0001): KEY_F1                KEY_F2                KEY_F3                KEY_F4               
                KEY_F5                KEY_F6                KEY_F7                KEY_F8               
                KEY_F9                KEY_F10               KEY_F11               KEY_F12              
                KEY_POWER            
    ABS (0003): ABS_MT_SLOT           : value 0, min 0, max 31, fuzz 0, flat 0, resolution 0
                ABS_MT_TOUCH_MAJOR    : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
                ABS_MT_TOUCH_MINOR    : value 0, min 0, max 255, fuzz 0, flat 0, resolution 0
                ABS_MT_ORIENTATION    : value 0, min -297, max 127, 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 65535, 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
add device 5: /dev/input/event3
  bus:      0000
  vendor    0000
  product   0000
  version   0000
  name:     "HI6250_hi6555c_CARD Headset Jack"
  location: "ALSA"
  id:       ""
  version:  1.0.1
  events:
    KEY (0001): KEY_VOLUMEDOWN        KEY_VOLUMEUP          KEY_MEDIA            
    SW  (0005): SW_HEADPHONE_INSERT   SW_MICROPHONE_INSERT 
  input props:
    <none>
could not get driver version for /dev/input/mice, Not a typewriter

显示实时事件

以下示例显示了使用 Linux 多点触控输入协议“B”的触摸屏的双指多点触控手势。-l 选项可显示文字标签,而 -t 选项则可显示时间戳。

adb shell su -- getevent -lt

示例:

HWPRA-H:/ $ getevent -lt                                                       
add device 1: /dev/input/event1
  name:     "hisi_on"
add device 2: /dev/input/event0
  name:     "hisi_gpio_key"
add device 3: /dev/input/event2
  name:     "fingerprint"
add device 4: /dev/input/event4
  name:     "cyttsp5_mt"
add device 5: /dev/input/event3
  name:     "HI6250_hi6555c_CARD Headset Jack"
could not get driver version for /dev/input/mice, Not a typewriter
[  148267.677826] /dev/input/event1: EV_KEY       KEY_POWER            DOWN                
[  148267.677826] /dev/input/event1: EV_SYN       SYN_REPORT           00000000            
[  148267.939404] /dev/input/event1: EV_KEY       KEY_POWER            UP                  
[  148267.939404] /dev/input/event1: EV_SYN       SYN_REPORT           00000000            
[  148269.742895] /dev/input/event4: EV_ABS       ABS_MT_TRACKING_ID   00004add            
[  148269.742895] /dev/input/event4: EV_ABS       ABS_MT_POSITION_X    0000023c            
[  148269.742895] /dev/input/event4: EV_ABS       ABS_MT_POSITION_Y    00000653            
[  148269.742895] /dev/input/event4: EV_ABS       ABS_MT_PRESSURE      00000065            
[  148269.742895] /dev/input/event4: EV_SYN       SYN_REPORT           00000000            
[  148269.794925] /dev/input/event4: EV_ABS       ABS_MT_POSITION_X    00000248            
[  148269.794925] /dev/input/event4: EV_ABS       ABS_MT_POSITION_Y    00000635            
[  148269.794925] /dev/input/event4: EV_ABS       ABS_MT_PRESSURE      00000072            
[  148269.794925] /dev/input/event4: EV_SYN       SYN_REPORT           00000000            
[  148269.803988] /dev/input/event4: EV_ABS       ABS_MT_POSITION_X    0000024e            
[  148269.803988] /dev/input/event4: EV_ABS       ABS_MT_POSITION_Y    0000061e            
[  148269.803988] /dev/input/event4: EV_ABS       ABS_MT_PRESSURE      00000073            
[  148269.803988] /dev/input/event4: EV_SYN       SYN_REPORT           00000000            
[  148269.812637] /dev/input/event4: EV_ABS       ABS_MT_POSITION_X    00000251            
[  148269.812637] /dev/input/event4: EV_ABS       ABS_MT_POSITION_Y    0000060a            
[  148269.812637] /dev/input/event4: EV_ABS       ABS_MT_PRESSURE      00000076            
[  148269.812637] /dev/input/event4: EV_SYN       SYN_REPORT           00000000            
[  148269.821469] /dev/input/event4: EV_ABS       ABS_MT_POSITION_X    00000256            
[  148269.821469] /dev/input/event4: EV_ABS       ABS_MT_POSITION_Y    000005ec            
[  148269.821469] /dev/input/event4: EV_ABS       ABS_MT_PRESSURE      00000077            
[  148269.821469] /dev/input/event4: EV_SYN       SYN_REPORT           00000000            
[  148269.830535] /dev/input/event4: EV_ABS       ABS_MT_POSITION_X    0000025b            
[  148269.830535] /dev/input/event4: EV_ABS       ABS_MT_POSITION_Y    000005cd            
[  148269.830535] /dev/input/event4: EV_ABS       ABS_MT_PRESSURE      00000079            
[  148269.830535] /dev/input/event4: EV_SYN       SYN_REPORT           00000000            
[  148269.839488] /dev/input/event4: EV_ABS       ABS_MT_POSITION_X    0000025f            
[  148269.839488] /dev/input/event4: EV_ABS       ABS_MT_POSITION_Y    000005ad            
[  148269.839488] /dev/input/event4: EV_ABS       ABS_MT_PRESSURE      0000007b            
[  148269.839488] /dev/input/event4: EV_SYN       SYN_REPORT           00000000            
[  148269.848362] /dev/input/event4: EV_ABS       ABS_MT_POSITION_X    00000265            
[  148269.848362] /dev/input/event4: EV_ABS       ABS_MT_POSITION_Y    0000058e            
[  148269.848362] /dev/input/event4: EV_ABS       ABS_MT_PRESSURE      0000007c            
[  148269.848362] /dev/input/event4: EV_SYN       SYN_REPORT           00000000            
[  148269.857377] /dev/input/event4: EV_ABS       ABS_MT_POSITION_X    0000026a            
[  148269.857377] /dev/input/event4: EV_ABS       ABS_MT_POSITION_Y    00000571            
[  148269.857377] /dev/input/event4: EV_ABS       ABS_MT_PRESSURE      00000080            
[  148269.857377] /dev/input/event4: EV_SYN       SYN_REPORT           00000000            
[  148269.866292] /dev/input/event4: EV_ABS       ABS_MT_POSITION_X    0000026e            
[  148269.866292] /dev/input/event4: EV_ABS       ABS_MT_POSITION_Y    00000553            
[  148269.866292] /dev/input/event4: EV_SYN       SYN_REPORT           00000000            
[  148269.875210] /dev/input/event4: EV_ABS       ABS_MT_POSITION_X    00000272            
[  148269.875210] /dev/input/event4: EV_ABS       ABS_MT_POSITION_Y    00000535            
[  148269.875210] /dev/input/event4: EV_SYN       SYN_REPORT           00000000            
[  148269.884144] /dev/input/event4: EV_ABS       ABS_MT_POSITION_X    00000277            
[  148269.884144] /dev/input/event4: EV_ABS       ABS_MT_POSITION_Y    00000518            
[  148269.884144] /dev/input/event4: EV_SYN       SYN_REPORT           00000000            
[  148269.893041] /dev/input/event4: EV_ABS       ABS_MT_POSITION_X    0000027a            
[  148269.893041] /dev/input/event4: EV_ABS       ABS_MT_POSITION_Y    000004fc            
[  148269.893041] /dev/input/event4: EV_SYN       SYN_REPORT           00000000            
[  148269.902004] /dev/input/event4: EV_ABS       ABS_MT_POSITION_X    0000027e            
[  148269.902004] /dev/input/event4: EV_ABS       ABS_MT_POSITION_Y    000004de            
[  148269.902004] /dev/input/event4: EV_SYN       SYN_REPORT           00000000            
[  148269.910921] /dev/input/event4: EV_ABS       ABS_MT_POSITION_X    00000284            
[  148269.910921] /dev/input/event4: EV_ABS       ABS_MT_POSITION_Y    000004c1            
[  148269.910921] /dev/input/event4: EV_SYN       SYN_REPORT           00000000            
[  148269.919913] /dev/input/event4: EV_ABS       ABS_MT_POSITION_X    00000288            
[  148269.919913] /dev/input/event4: EV_ABS       ABS_MT_POSITION_Y    000004a4            
[  148269.919913] /dev/input/event4: EV_ABS       ABS_MT_PRESSURE      0000007d            
[  148269.919913] /dev/input/event4: EV_SYN       SYN_REPORT           00000000            
[  148269.928727] /dev/input/event4: EV_ABS       ABS_MT_POSITION_X    0000028c            
[  148269.928727] /dev/input/event4: EV_ABS       ABS_MT_POSITION_Y    00000486            
[  148269.928727] /dev/input/event4: EV_SYN       SYN_REPORT           00000000            
[  148269.937538] /dev/input/event4: EV_ABS       ABS_MT_POSITION_X    00000291            
[  148269.937538] /dev/input/event4: EV_ABS       ABS_MT_POSITION_Y    00000469            
[  148269.937538] /dev/input/event4: EV_SYN       SYN_REPORT           00000000            
[  148269.946524] /dev/input/event4: EV_ABS       ABS_MT_POSITION_X    00000296            
[  148269.946524] /dev/input/event4: EV_ABS       ABS_MT_POSITION_Y    0000044d            
[  148269.946524] /dev/input/event4: EV_ABS       ABS_MT_PRESSURE      00000081            
[  148269.946524] /dev/input/event4: EV_SYN       SYN_REPORT           00000000            
[  148269.955401] /dev/input/event4: EV_ABS       ABS_MT_POSITION_X    00000298            
[  148269.955401] /dev/input/event4: EV_ABS       ABS_MT_POSITION_Y    0000042e            
[  148269.955401] /dev/input/event4: EV_SYN       SYN_REPORT           00000000            
[  148269.964314] /dev/input/event4: EV_ABS       ABS_MT_POSITION_X    0000029d            
[  148269.964314] /dev/input/event4: EV_ABS       ABS_MT_POSITION_Y    00000410            
[  148269.964314] /dev/input/event4: EV_SYN       SYN_REPORT           00000000            
[  148269.973228] /dev/input/event4: EV_ABS       ABS_MT_POSITION_X    000002a0            
[  148269.973228] /dev/input/event4: EV_ABS       ABS_MT_POSITION_Y    000003f3            
[  148269.973228] /dev/input/event4: EV_ABS       ABS_MT_PRESSURE      00000083            
[  148269.973228] /dev/input/event4: EV_SYN       SYN_REPORT           00000000            
[  148269.982233] /dev/input/event4: EV_ABS       ABS_MT_POSITION_Y    000003de            
[  148269.982233] /dev/input/event4: EV_ABS       ABS_MT_PRESSURE      00000084            
[  148269.982233] /dev/input/event4: EV_SYN       SYN_REPORT           00000000            
[  148269.991177] /dev/input/event4: EV_ABS       ABS_MT_POSITION_X    000002a4            
[  148269.991177] /dev/input/event4: EV_ABS       ABS_MT_POSITION_Y    000003c4            
[  148269.991177] /dev/input/event4: EV_ABS       ABS_MT_PRESSURE      00000082            
[  148269.991177] /dev/input/event4: EV_SYN       SYN_REPORT           00000000            
[  148270.000113] /dev/input/event4: EV_ABS       ABS_MT_POSITION_X    000002a6            
[  148270.000113] /dev/input/event4: EV_ABS       ABS_MT_POSITION_Y    000003b0            
[  148270.000113] /dev/input/event4: EV_SYN       SYN_REPORT           00000000            
[  148270.009064] /dev/input/event4: EV_ABS       ABS_MT_POSITION_X    000002a9            
[  148270.009064] /dev/input/event4: EV_ABS       ABS_MT_POSITION_Y    000003a4            
[  148270.009064] /dev/input/event4: EV_SYN       SYN_REPORT           00000000            

猜你喜欢

转载自blog.csdn.net/manjianchao/article/details/79569124
今日推荐