多点触摸与单点触摸接口主要区别【转】

本文深入探讨了触摸事件处理机制,详细介绍了如何通过输入接口(input)模块实现单点触摸和多点触摸事件的上发过程。文章首先解释了关键函数的用法,如input_report_key和input_report_abs,接着阐述了多点触摸在2.36.28/29版本中被引入的背景和必要性。进一步地,文章详细列举了与多点触摸相关的命令定义,包括坐标轴、触碰类型、压力等参数,并展示了如何在不同场景下实现多点触摸事件的同步。最后,文章对新增的多点触摸命令在源代码中的具体实现进行了说明,为读者提供了宝贵的实践指导。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

转自:http://blog.youkuaiyun.com/eleven_yy/article/details/7723079

上发单点触摸事件

input_report_key(input,ABS_MT_TRACKING_ID,0);

input_report_key(input, BTN_TOUCH, 1);

input_report_abs(input, ABS_MT_POSITION_X, ts->tc.x1);

input_report_abs(input, ABS_MT_POSITION_Y, ts->tc.y1);

input_sync(input);

上发多点触摸事件

input_report_key(input,ABS_MT_TRACKING_ID,0); // ABS_MT_TRACKING_ID 用来区分是第几指上报上来的坐标

input_report_key(input, BTN_TOUCH, 1);

input_report_abs(input, ABS_MT_POSITION_X, ts->tc.x1);

input_report_abs(input, ABS_MT_POSITION_Y, ts->tc.y1);

input_mt_sync(input);

 

input_report_key(input,ABS_MT_TRACKING_ID,1);

input_report_key(input, BTN_TOUCH, 1);

input_report_abs(input, ABS_MT_POSITION_X, ts->tc.x2);

input_report_abs(input, ABS_MT_POSITION_Y, ts->tc.y2);

input_mt_sync(input);

input_sync(input);

 

在 2.36.28/29 的 input 模块 中增加多点触摸的接口

 

增加多点触摸的命令定义:

linuxsrc/include/input.h

 


#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 */

#define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */

#define ABS_MT_PRESSURE 0x3a /* Pressure on contact area */

 

 

 

/*

* MT_TOOL types

*/

#define MT_TOOL_FINGER 0

#define MT_TOOL_PEN 1

 


在同一文件中增加相应的处理函数:

static inline void input_mt_sync(struct input_dev *dev)

{

input_event(dev, EV_SYN, SYN_MT_REPORT, 0);

}

在linuxsrc/driver/input/input.c 中增加定义

/*

* EV_ABS events which should not be cached are listed here.

*/

static unsigned int input_abs_bypass_init_data[] __initdata = {

ABS_MT_TOUCH_MAJOR,

ABS_MT_TOUCH_MINOR,

ABS_MT_WIDTH_MAJOR,

ABS_MT_WIDTH_MINOR,

ABS_MT_ORIENTATION,

ABS_MT_POSITION_X,

ABS_MT_POSITION_Y,

ABS_MT_TOOL_TYPE,

ABS_MT_BLOB_ID,

ABS_MT_TRACKING_ID,

ABS_MT_PRESSURE,

0

};

转载于:https://www.cnblogs.com/sky-heaven/p/5107993.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值