雨中徒步八英里 2018-11-18 08:04 采纳率: 0%
浏览 2817
已采纳

linux系统下读取触摸坐标值相反

问题描述:
迅为4412itop精英版10.1寸电容屏。
分辨率是1024*600。
最小linux系统下想通过读取/dev/input/event2事件
获取触摸坐标值,已经顺利的读出值。
1.但是手指在0-1023像素点间移动时,读取到的却是2-597范围。
2.在0-599像素点间移动时,读取到的却是7-1016范围。

内核部分源码如下
下面对input_x和Input_y的赋值应该怎样修改……
#endif
if (pre_touch || touch_num)
{
s32 pos = 0;
u16 touch_index = 0;
u8 report_num = 0;
coor_data = &point_data[3];

    if(touch_num)
    {
        id = coor_data[pos] & 0x0F;

    #if GTP_WITH_PEN
        id = coor_data[pos];  //input_set_abs_params
        if ((id & 0x80))  
        {
            GTP_DEBUG("Pen touch DOWN(Slot)!");
            input_x  = coor_data[pos + 1] | (coor_data[pos + 2] << 8);
            input_y  = coor_data[pos + 3] | (coor_data[pos + 4] << 8);
            input_w  = coor_data[pos + 5] | (coor_data[pos + 6] << 8);

            gtp_pen_down(input_x, input_y, input_w, 0);
            pre_pen = 1;
            pre_touch = 0;
            pen_active = 1;
        }    
    #endif

        touch_index |= (0x01<<id);
    }

    GTP_DEBUG("id = %d,touch_index = 0x%x, pre_touch = 0x%x\n",id, touch_index,pre_touch);
    for (i = 0; i < GTP_MAX_TOUCH; i++)
    {
    #if GTP_WITH_PEN
        if (pre_pen == 1)
        {
            break;
        }
    #endif

        if ((touch_index & (0x01<<i)))
        {
            input_x  = coor_data[pos + 1] | (coor_data[pos + 2] << 8);
            input_y  = coor_data[pos + 3] | (coor_data[pos + 4] << 8);
            input_w  = coor_data[pos + 5] | (coor_data[pos + 6] << 8);

            gtp_touch_down(ts, id, input_x, input_y, input_w);
            pre_touch |= 0x01 << i;

            report_num++;
            if (report_num < touch_num)
            {
                pos += 8;
                id = coor_data[pos] & 0x0F;
                touch_index |= (0x01<<id);
            }
        }
        else
        {
            gtp_touch_up(ts, i);
            pre_touch &= ~(0x01 << i);
        }
    }
}

#else

if (touch_num)
{
    for (i = 0; i < touch_num; i++)
    {
        coor_data = &point_data[i * 8 + 3];

        id = coor_data[0] & 0x0F;
        input_x  = coor_data[1] | (coor_data[2] << 8);
        input_y  = coor_data[3] | (coor_data[4] << 8);
        input_w  = coor_data[5] | (coor_data[6] << 8);

    #if GTP_WITH_PEN
        id = coor_data[0];
        if (id & 0x80)
        {
            GTP_DEBUG("Pen touch DOWN!");
            gtp_pen_down(input_x, input_y, input_w, 0);
            pre_pen = 1;
            pen_active = 1;
            break;
        }
        else
    #endif
        {
            gtp_touch_down(ts, id, input_x, input_y, input_w);
        }
    }
}
else if (pre_touch)
{
#if GTP_WITH_PEN
    if (pre_pen == 1)
    {
        GTP_DEBUG("Pen touch UP!");
        gtp_pen_up(0);
        pre_pen = 0;
        pen_active = 1;
    }
    else
#endif
    {
        GTP_DEBUG("Touch Release!");
        gtp_touch_up(ts, 0);
    }
}

pre_touch = touch_num;

#endif

  • 写回答

2条回答 默认 最新

  • 雨中徒步八英里 2019-04-01 17:55
    关注

    自己写了个触摸屏校准程序,解决了.......

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用