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

转自:http://blog.csdn.net/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

};

posted @ 2016-01-07 01:35  Sky&Zhang  阅读(1535)  评论(0编辑  收藏  举报