Android getevent命令分析Input事件

getevent命令使用格式:(adb shell,getevent -h获取)
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
其中,getevent -p 和 getevent -i 都可显示所有注册的Input设备和相关信息,-i的信息
更为详细。
getevent -p:
add device 3: /dev/input/event5
  name:     "hwmdata"
  events:
    REL (0002): 0001  0002
  input props:
    <none>
add device 4: /dev/input/event3
  name:     "ACCDET"
  events:
    KEY (0001): 0072  0073  00a4  0246
  input props:
    <none>
add device 5: /dev/input/event2
  name:     "GSENSOR"
  events:
    KEY (0001): 00fd
  input props:
    <none>
getevent -i:
add device 3: /dev/input/event5
  bus:      0000
  vendor    0000
  product   0000
  version   0000
  name:     "hwmdata"
  location: ""
  id:       ""
  version:  1.0.1
  events:
    REL (0002): 0001  0002
  input props:
    <none>
add device 4: /dev/input/event3
  bus:      0019
  vendor    0000
  product   0000
  version   0000
  name:     "ACCDET"
  location: ""
  id:       ""
  version:  1.0.1
  events:
    KEY (0001): 0072  0073  00a4  0246
  input props:
    <none>
add device 5: /dev/input/event2
  bus:      0019
  vendor    0000
  product   0000
  version   0000
  name:     "GSENSOR"
  location: ""
  id:       ""
  version:  1.0.1
  events:
    KEY (0001): 00fd
  input props:
    <none>
getevent 设备节点,显示该设备event事件的相关信息,如getevent /dev/input/event4:(power键事件)
格式type  code  value
0001 0074 00000001
0000 0000 00000000
0001 0074 00000000
0000 0000 00000000

其中,type定义如下:
/*  
 * 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)

常用的是EV_KEY, EV_REL, EV_ABS, EV_SYN分别对应按键, 相对坐标, 绝对坐标, 同步事件。
EV_SYN则表示一组完整事件完成上报,需要处理。
EV_SYN的code定义事件分发的类型,其对应的code如下:
/*  
 * Synchronization events.  
 */  
#define SYN_REPORT      0  
#define SYN_CONFIG      1  
#define SYN_MT_REPORT   2  
#define SYN_DROPPED     3
getvent -l 设备节点,更能清晰显示出event事件的信息,即getevent -l /dev/input/event4:
EV_KEY       KEY_POWER            DOWN
EV_SYN       SYN_REPORT           00000000
EV_KEY       KEY_POWER            UP
EV_SYN       SYN_REPORT           00000000

上面的信息可知,该事件为点击power键事件。
getevent -r 设备节点,可以显示event上报速率,即getvent -r /dev/input/event4:
0001 0074 00000001
0000 0000 00000000 rate 0
0001 0074 00000000
0000 0000 00000000 rate 5
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值