嵌入式爱好者

T507修改usb触摸驱动的报点函数

2023-6-30 16:25| 发布者: 听我说| 查看: 262| 评论: 0

类目: 知识库  >  T507系列产品     文档编号: 1042

T507usb触摸驱动的源码位置:/OKT507-linux-sdk/kernel/linux-4.9/drivers/hid/hid-multitouch.c

报点函数:
                if (active) {
                        /* this finger is in proximity of the sensor */
                        int wide = (s->w > s->h);
                        /* divided by two to match visual scale of touch */
                        int major = max(s->w, s->h) >> 1;
                        int minor = min(s->w, s->h) >> 1;

                        input_event(input, EV_ABS, ABS_MT_POSITION_X, s->x);
                        input_event(input, EV_ABS, ABS_MT_POSITION_Y, s->y);
                        input_event(input, EV_ABS, ABS_MT_TOOL_X, s->cx);
                        input_event(input, EV_ABS, ABS_MT_TOOL_Y, s->cy);

                        input_event(input, EV_ABS, ABS_MT_DISTANCE,
                                !s->touch_state);
                        input_event(input, EV_ABS, ABS_MT_ORIENTATION, wide);
                        input_event(input, EV_ABS, ABS_MT_PRESSURE, s->p);
                        input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, major);
                        input_event(input, EV_ABS, ABS_MT_TOUCH_MINOR, minor);
                }

触摸驱动的主要作用就是采点 报点,通过修改触摸驱动的报点函数也可以修正一些触摸偏移。

例如,报点位置和实际触摸位置不一致,y轴坐标偏移了两倍,可以在报点时把y轴坐标值除以2:
input_event(input, EV_ABS, ABS_MT_POSITION_Y, (s->y)/2);
input_event(input, EV_ABS, ABS_MT_TOOL_Y, (s->cy)/2);

例如,想在驱动层翻转一下X轴,可在X坐标前减去水平分辨率:
input_event(input, EV_ABS, ABS_MT_POSITION_X, 1920-s->x);

已解决

未解决

只是看看

最新评论

QQ|小黑屋| 飞凌嵌入式 ( 冀ICP备12004394号-1 )

GMT+8, 2024-11-23 19:06

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

返回顶部