简介
LInux下面的触摸事件由输入子系统一上报数据,触摸板会上报的数据一般有三种
#define EV_SYN 0x00#define EV_KEY 0x01#define EV_ABS 0x03

struct input_event {struct timeval time; //时间__u16 type; //类__u16 code; //类下事件的值__s32 value; //0-松开, 1-按下,2-重复};struct timeval {__kernel_time_t tv_sec; //秒__kernel_suseconds_t tv_usec; //微秒};
由上,我们可以观察到,hexdump的数据格式
# 格式lineNumbers tv_sec tv_usec type code value
触摸事件数据分析
type 以及 code 对应得宏定义
input-event-codes.h
触摸松开的数据上报
[root@imx6ull:~]# hexdump /dev/input/event1-------------------------------------------------------- # 按下不动产生的数据,第一组数据0000000 b96f 5e5d 4907 0006 0003 0039 003b 00000000010 b96f 5e5d 4907 0006 0003 0035 0521 00000000020 b96f 5e5d 4907 0006 0003 0036 04d4 00000000030 b96f 5e5d 4907 0006 0001 014a 0001 00000000040 b96f 5e5d 4907 0006 0003 0000 0521 00000000050 b96f 5e5d 4907 0006 0003 0001 04d4 00000000060 b96f 5e5d 4907 0006 0000 0000 0000 0000----------------------------------------------------------# 松开产生的数据,第二组数据0000070 b975 5e5d 05d7 0008 0003 0039 ffff ffff0000080 b975 5e5d 05d7 0008 0001 014a 0000 00000000090 b975 5e5d 05d7 0008 0000 0000 0000 0000
分析按下产生的数据
只关注 type 以及 code,这两个value的变化过程。
# typeEV_ABS * 3 -> EV_KEY -> EV_ABS * 2 -> EV_SYN0003 -> 0003 -> 0003 -> 0001 -> 0003 -> 0003 -> 0000# codeABS_MT_TRACKING_ID -> ABS_MT_POSITION_X -> ABS_MT_POSITION_Y -> BTN_TOUCH -> ABS_X -> ABS_Y -> SYN_REPORT0039 -> 0035 -> 0036 -> 014a -> 0000 -> 0001 -> 0000
分析屏幕松开生成的数据
# typeEV_ABS -> EV_KEY -> -> EV_SYN0003 -> 0001 -> 0000# codeABS_MT_TRACKING_ID -> BTN_TOUCH -> SYN_REPORT0039 -> 014a -> 0000
若是我们现在只关注点击事件,那么只需要关注 是否有 BTN_TOUCH 类型的数据产生就好了。
