使用getevent在Android中调试输入子系统
背景
在调试安卓设备按键,想使用hexdump,但是发现没有找到,反而找到了这个更好用的工具。
以下是我的调试片段
# getevent -l /dev/input/event0
EV_KEY KEY_ENTER DOWN
EV_SYN SYN_REPORT 00000000
EV_KEY KEY_ENTER UP
EV_SYN SYN_REPORT 00000000
EV_KEY KEY_UP DOWN
EV_SYN SYN_REPORT 00000000
EV_KEY KEY_UP UP
EV_SYN SYN_REPORT 00000000
EV_KEY KEY_BACK DOWN
EV_SYN SYN_REPORT 00000000
前言
修改来自:Android getevent用法详解
getevent 指令用于获取 input 输入事件,比如获取按键上报信息、获取触摸屏上报信息等。
程序的实现:system/core/toolbox/getevent.c
用法
getevent -h:查看 getevent 帮助信息
# 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:显示当前有那些输入设备,数量与 /dev/input 目录下相同。
由于会将对应的设备节点以及设备描述打印出来,因此非常方便调试人员后续选择对应的设备。
此时,接收任何一切输入
# getevent -l
add device 1: /dev/input/event6
name: "msm8909-snd-card Headset Jack"
add device 2: /dev/input/event5
name: "msm8909-snd-card Button Jack"
add device 3: /dev/input/event2
name: "qpnp_pon"
add device 4: /dev/input/event1
name: "gpiokey-pulley"
could not get driver version for /dev/input/mice, Not a typewriter
add device 5: /dev/input/event3
name: "gpio-keys"
add device 6: /dev/input/event0
name: "aw9523-keys"
add device 7: /dev/input/event4
name: "accelerometer"
/dev/input/event0: EV_KEY KEY_UP DOWN
/dev/input/event0: EV_SYN SYN_REPORT 00000000
/dev/input/event0: EV_KEY KEY_UP UP
/dev/input/event0: EV_SYN SYN_REPORT 00000000
/dev/input/event0: EV_KEY KEY_LEFT DOWN
/dev/input/event0: EV_SYN SYN_REPORT 00000000
/dev/input/event0: EV_KEY KEY_LEFT UP
/dev/input/event0: EV_SYN SYN_REPORT 00000000
/dev/input/event2: EV_KEY KEY_POWER UP
/dev/input/event2: EV_SYN SYN_REPORT 00000000
/dev/input/event3: EV_KEY KEY_F1 DOWN
/dev/input/event3: EV_SYN SYN_REPORT 00000000
/dev/input/event3: EV_KEY KEY_F1 UP
/dev/input/event3: EV_SYN SYN_REPORT 00000000
/dev/input/event3: EV_KEY KEY_F1 DOWN
/dev/input/event3: EV_SYN SYN_REPORT 00000000
# ls /dev/input/
event0 event1 event2 event3 event4 event5 event6 mice
读取指定的设备 读取 event3 数据(触摸屏)
# getevent /dev/input/event3
0003 0039 00000004
0003 0035 00002324
0003 0036 00001a9f
0001 014a 00000001
0003 0000 00002324
0003 0001 00001a9f
0000 0000 00000000
0003 0039 ffffffff
0001 014a 00000000
0000 0000 00000000
-t:显示时间戳
# getevent -t /dev/input/event3
[ 1141.248434] 0003 0039 0000000e
[ 1141.248434] 0003 0035 00002cd4
[ 1141.248434] 0003 0036 00001a09
[ 1141.248434] 0001 014a 00000001
[ 1141.248434] 0003 0000 00002cd4
[ 1141.248434] 0003 0001 00001a09
[ 1141.248434] 0000 0000 00000000
[ 1141.322181] 0003 0039 ffffffff
[ 1141.322181] 0001 014a 00000000
[ 1141.322181] 0000 0000 00000000
-n:不换行打印
# getevent -n /dev/input/event3
0003 0039 000000020003 0035 00002f000003 0036 00001a4e0001 014a 000000010003 0000 00002f000003 0001 00001a4e0000 0000 000000000003 0039 ffffffff0001 014a 000000000000 0000 000000000003 0039 000000030003 0035 00002e880003 0036 000019b80001 014a 000000010003 0000 00002e880003 0001 000019b80000 0000 000000000003 0039 ffffffff0001 014a 000000000000 0000 000000000003 0039 000000040003 0035 00002d700003 0036 00001a000001 014a 000000010003 0000 00002d700003 0001 00001a000000 0000 000000000003 0039 ffffffff0001 014a 000000000000 0000 000000000003 0039 000000050003 0035 00002d080003 0036 000019a50001 014a 000000010003 0000 00002d080003 0001 000019a50000 0000 000000000003 0039 ffffffff0001 014a 000000000000
-s:显示指定位的开关状态
# getevent -s5 /dev/input/event3
0000
-S:显示所有位的开关状态
# getevent -S /dev/input/event3
getevent -S /dev/input/event3
0000
-v:根据 mask 值显示相关信息,执行后会一直显示上报数据
errs=1, dev=2, name=4, info=8, vers=16, pos. events=32, props=64
默认显示 dev| name| info| vers = 30;
# getevent -v /dev/input/event3
add device 1: /dev/input/event3
bus: 0003
vendor 222a
product 004d
version 0110
name: "ILITEK Multi-Touch-V3020"
location: "usb-ff540000.usb-1.3/input0"
id: ""
version: 1.0.1
# getevent -v30 /dev/input/event3
add device 1: /dev/input/event3
bus: 0003
vendor 222a
product 004d
version 0110
name: "ILITEK Multi-Touch-V3020"
location: "usb-ff540000.usb-1.3/input0"
id: ""
version: 1.0.1
# getevent -v2 /dev/input/event3
add device 1: /dev/input/event3
# getevent -v8 /dev/input/event3
getevent -v8 /dev/input/event3
bus: 0003
vendor 222a
product 004d
version 0110
location: "usb-ff540000.usb-1.3/input0"
id: ""
# getevent -v16 /dev/input/event3
version: 1.0.1
# getevent -v32 /dev/input/event3
events:
KEY (0001): 014a
ABS (0003): 0000 : value 12008, min 0, max 16384, fuzz 0, flat 0, resolution 31
0001 : value 5790, min 0, max 9600, fuzz 0, flat 0, resolution 32
002f : value 0, min 0, max 9, fuzz 0, flat 0, resolution 0
0035 : value 0, min 0, max 16384, fuzz 0, flat 0, resolution 31
0036 : value 0, min 0, max 9600, fuzz 0, flat 0, resolution 32
0039 : value 0, min 0, max 65535, fuzz 0, flat 0, resolution 0
-d:如果设备可用,显示设备隐藏的描述信息
-p:显示设备支持的事件类型和编码方式
# getevent -p /dev/input/event3
add device 1: /dev/input/event3
name: "ILITEK Multi-Touch-V3020"
events:
KEY (0001): 014a
ABS (0003): 0000 : value 13084, min 0, max 16384, fuzz 0, flat 0, resolution 31
0001 : value 5284, min 0, max 9600, fuzz 0, flat 0, resolution 32
002f : value 0, min 0, max 9, fuzz 0, flat 0, resolution 0
0035 : value 0, min 0, max 16384, fuzz 0, flat 0, resolution 31
0036 : value 0, min 0, max 9600, fuzz 0, flat 0, resolution 32
0039 : value 0, min 0, max 65535, fuzz 0, flat 0, resolution 0
input props:
INPUT_PROP_DIRECT
-i:显示设备的所有信息和支持的事件,比 -p 显示更多信息
# getevent -i /dev/input/event3
-l:以文本形式输出事件类型和名称,比 -t 更清楚直观
# getevent -l /dev/input/event3
getevent -l /dev/input/event3
// 事件类型 事件码 事件值
EV_ABS ABS_MT_TRACKING_ID 0000000f
EV_ABS ABS_MT_POSITION_X 00002bbc
EV_ABS ABS_MT_POSITION_Y 00001b6d
EV_KEY BTN_TOUCH DOWN
EV_ABS ABS_X 00002bbc
EV_ABS ABS_Y 00001b6d
EV_SYN SYN_REPORT 00000000
EV_ABS ABS_MT_TRACKING_ID ffffffff
EV_KEY BTN_TOUCH UP
EV_SYN SYN_REPORT 00000000
-q:暂时不会使用
-c:打印固定数量的事件并退出
# getevent -c 10 /dev/input/event3
getevent -c 10 /dev/input/event3
0003 0039 00000012
0003 0035 000038a4
0003 0036 000008f5
0001 014a 00000001
0003 0000 000038a4
0003 0001 000008f5
0000 0000 00000000
0003 0039 ffffffff
0001 014a 00000000
0000 0000 00000000
-r:显示事件上报速率
// 检测触摸屏报点速率
# getevent -r /dev/input/event3
getevent -r /dev/input/event3
0003 0039 00000015
0003 0035 000030d8
0003 0036 00001954
0001 014a 00000001
0003 0000 000030d8
0003 0001 00001954
0000 0000 00000000 rate 0
0003 0039 ffffffff
0001 014a 00000000
0000 0000 00000000 rate 9
参数可以组合使用,一次性查看需要的输入信息
# getevent -tlr /dev/input/event3
[ 2514.550104] EV_ABS ABS_MT_TRACKING_ID 0000001c
[ 2514.550104] EV_ABS ABS_MT_POSITION_X 00002dac
[ 2514.550104] EV_ABS ABS_MT_POSITION_Y 000018ca
[ 2514.550104] EV_KEY BTN_TOUCH DOWN
[ 2514.550104] EV_ABS ABS_X 00002dac
[ 2514.550104] EV_ABS ABS_Y 000018ca
[ 2514.550104] EV_SYN SYN_REPORT 00000000 rate 0
[ 2514.638845] EV_ABS ABS_MT_TRACKING_ID ffffffff
[ 2514.638845] EV_KEY BTN_TOUCH UP
[ 2514.638845] EV_SYN SYN_REPORT 00000000 rate 11
使用getevent在Android中调试输入子系统的更多相关文章
- Android 中调试手段 打印函数调用栈信息
下面来简单介绍下 android 中的一种调试方法. 在 android 的 app 开发与调试中,经常需要用到打 Log 的方式来查看函数调用点. 这里介绍一种方法来打印当前栈中的函数调用关系 St ...
- Android中TextView输入字数统计和限制
在Android开发应用的时候,文本编辑框中最多输入140个字,经常会显示还剩多少字以限制用户输入的字数, EditText content;//定义一个文本输入框 TextView hasnum;/ ...
- Android中密码输入内容可见性切换
今天在做项目的时候遇到了一个关于密码输入框可见性切换问题,上网搜了搜,这里面门道还不小,做一个记录吧,下次遇到就好解决了. 首先写了一个简单的测试工程: <LinearLayout xmlns: ...
- Android中验证输入是否为汉字及手机号,邮箱验证,IP地址可用port号验证
1,验证是否为汉字 // 验证昵称 private boolean verifyNickname() { String nickname = edt_username.getText().toStri ...
- Android中验证输入是否为汉字、手机号及邮箱
1,验证是否为汉字 Code// 验证昵称 private boolean verifyNickname() { String nickname = edt_username.getText().to ...
- inux 驱动程序开发中输入子系统总共能产生哪些事件类型(EV_KEY,EV_ABS,EV_REL)
inux 驱动程序开发中, 输入子系统总共能产生哪些事件类型?,以及分别是什么意思?详见如下: Linux中输入设备的事件类型有EV_SYN 0x00 同步事件EV_KEY 0x01 按键事件,如KE ...
- 嵌入式Linux驱动学习之路(十六)输入子系统
以前写的一些输入设备的驱动都是采用字符设备处理的.问题由此而来,Linux开源社区的大神们看到了这大量输入设备如此分散不堪,有木有可以实现一种机制,可以对分散的.不同类别的输入设备进行统一的驱动,所以 ...
- Linux输入子系统(转)
Linux输入子系统(Input Subsystem) 1.1.input子系统概述 输入设备(如按键,键盘,触摸屏,鼠标等)是典型的字符设备,其一般的工作机制是低层在按键,触摸等动作发生时产生一个中 ...
- Linux输入子系统(一) _驱动编码
输入设备都有共性:中断驱动+字符IO,基于分层的思想,Linux内核将这些设备的公有的部分提取出来,基于cdev提供接口,设计了输入子系统,所有使用输入子系统构建的设备都使用主设备号13,同时输入子系 ...
- 10. linux输入子系统/input 设备【转】
转自:https://www.cnblogs.com/crmn/articles/6696819.html 按键事件信息之上报绝对事件信息之上报相对事件信息之上报功能键驱动编写多点触控事件的上报 只产 ...
随机推荐
- RustDesk 自建服务器部署和使用教程
RustDesk 是一个强大的开源远程桌面软件,是中国开发者的作品,它使用 Rust 编程语言构建,提供安全.高效.跨平台的远程访问体验.可以说是目前全球最火的开源远程桌面软件了,GitHub 星星数 ...
- 让智慧物联赋能高效生产, AIRIOT助力数字化油田转型升级
近年来,中国石油行业为了推进工业化和信息化深度融合,充分结合勘探开发.生产科研和经营管理的实际需求,积极通过信息化建设促进油田业务转型升级.在勘探开发与管理的领域中,油气生产物联网系统是一个极其重 ...
- java启动参考
启动参数 mvn clean package -Dmaven.test.skip=true -Ptest - java - -server - -Xms2G - -Xmx2G - -Xss256K - ...
- go高并发之路——缓存击穿
缓存击穿,Redis中的某个热点key不存在或者过期,但是此时有大量的用户访问该key.比如xxx直播间优惠券抢购.xxx商品活动,这时候大量用户会在某个时间点一同访问该热点事件.但是可能由于某种原因 ...
- rabbit 的下载与安装
因为RabbitMQ是用erlang语言开发的,所以我们在安装RabbitMQ前必须要安装erlang支持. erlang的下载地址:https://www.erlang.org/downloads ...
- C# 借助NPOI 完成 xls 转换为xlsx
背景:MinExcel开源类库,导数据的库,占用内存很低,通过io,不通过内存保存,不支持 xls格式的文件,支持csv和xlsx,所以要想使用这个库,就得把xls格式转换为xlsx.只复制了数据 合 ...
- 三元运算符 JAVA12
Java 提供了一个特别的三元运算符(也叫三目运算符) 表示:条件运算符的符号表示为"? :",使用该运算符时需要有三个操作数,因此称其为三目运算符. 举例一 int x,y,z; ...
- golang kmp算法实现
// 不多逼逼直接上代码.原理的话可以参考下面的链接.讲的非常清晰package main import "fmt" func genNext(s string) []int { ...
- Android 12(S) MultiMedia Learning(九)MediaCodec
这一节来学习MediaCodec的工作原理,相关代码路径: http://aospxref.com/android-12.0.0_r3/xref/frameworks/av/media/libstag ...
- 从Newtonsoft.Json迁移到 System.Text.Json不简单
一.写在前面# System.Text.Json 是 .NET Core 3 及以上版本内置的 Json 序列化组件,刚推出的时候经常看到踩各种坑的吐槽,现在经过几个版本的迭代优化,提升了易用性,修复 ...