温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

android event事件录制回放 --2 touch事件分析

发布时间:2020-07-31 23:52:54 来源:网络 阅读:1766 作者:wo153 栏目:移动开发


二、touch事件分析


1、机器touch设备的具体信息
android event事件录制回放  --2 touch事件分析android event事件录制回放  --2 touch事件分析
分析:此设备名字:mtk-tpd

          支持:key abs

          支持abs的type:0000 0001 0018...

          type0035支持的最大取值为480


2、touch 事件 

触摸事件的type:

#define SYN_REPORT 0

#define SYN_CONFIG 1

#define SYN_MT_REPORT 2

……………………… ...

#define ABS_MT_TOUCH_MAJOR 0x30 /* Major axis of touching ellipse */

#define ABS_MT_TOUCH_MINOR 0x31 /* Minor axis (omit if circular) */

#define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse */

#define ABS_MT_WIDTH_MINOR 0x33 /* Minor axis (omit if circular) */

#define ABS_MT_ORIENTATION 0x34 /* Ellipse orientation */

#define ABS_MT_POSITION_X 0x35 /* Center X ellipse position */

#define ABS_MT_POSITION_Y 0x36 /* Center Y ellipse position */

#define ABS_MT_TOOL_TYPE 0x37 /* Type of touching device */

#define ABS_MT_BLOB_ID 0x38 /* Group a set of packets as a blob */

区分手机设备单点还是多点:

int EventHub::open_device(const char *deviceName)

{

………………………

if (test_bit(ABS_MT_TOUCH_MAJOR, abs_bitmask)

&& test_bit(ABS_MT_POSITION_X, abs_bitmask)

&& test_bit(ABS_MT_POSITION_Y, abs_bitmask)) {

device->classes |= CLASS_TOUCHSCREEN | CLASS_TOUCHSCREEN_MT;

// LOGI("It is a multi-touch screen!");

//single-touch?

else if (test_bit(BTN_TOUCH, key_bitmask)

&& test_bit(ABS_X, abs_bitmask) 

&& test_bit(ABS_Y, abs_bitmask)) {

device->classes |= CLASS_TOUCHSCREEN;

// LOGI("It is a single-touch screen!");

}

……………… ..

}


对于一个Touch事件,不同机型会有不同的组成,你用getevent显示出来的也不一样。可以通过下面几点去组成一个touch事件:

1、是否支持BTN_TOUCH,通过判断该abs设备是否还支持key事件来判断是否需要BTN_TOUCH,像

android event事件录制回放  --2 touch事件分析

android event事件录制回放  --2 touch事件分析这个就是支持key事件的,而且持之BTN_TOUCH(014a :十进制为330)。对于这种设备,

在发送touchdown事件的时候需要添加 eventX 0001 014a 1的事件,对应在touchUp的时候需要添加 eventX 0001 014a 0。

当不支持BTN_TOUCH的时候,就要省去该事件语句

2、判断多点触摸的协议类型,根据判断是否支持ABS_MT_SLOT。

多点触摸协议可以参考http://blog.csdn.net/droidphone/article/details/8434768

文章中详细说明了多点触摸协议的两种类型,还有两种类型分别的事件语句组成

A:有状态类型 

ABS_MT_TRACKING_ID touchDown必须要有值,touchUp的时候值为-1

同步语句只要SYN_REPORT

B:无状态类型

ABS_MT_TRACKING_ID touchDown必须要有值,touchUp的时候值为0

同步语句要包括:SYN_REPORT 、SYN_MT_REPORT

3、对于touchDown,还必须包括:ABS_MT_POSITION_X

                           ABS_MT_POSITION_Y

                           SYN_REPORT

                           ABS_MT_TOUCH_MAJOR

                           ABS_MT_PRESSURE

                                         

4、对于touchMove,还必须包括: ABS_MT_POSITION_X

                                ABS_MT_POSITION_Y

                                SYN_REPORT

                                (无状态)ABS_MT_TRACKING_ID、SYN_MT_REPORT

                                ABS_MT_TOUCH_MAJOR

5、对于touchUP,还必须包括:

          有状态:ABS_MT_TRACKING_ID -1
                       BTN_TOUCH  0
                       SYN_REPORT
          无状态:ABS_MT_TRACKING_ID 0
                       ABS_MT_TOUCH_MAJOR 0
                       BTN_TOUCH  0
                       SYN_MT_REPORT
                       SYN_REPORT
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI