天嵌 ARM开发社区

 找回密码
 注册
查看: 2146|回复: 2

应用层接收触摸屏上报的问题?

[复制链接]
zr_714 发表于 2011-1-17 18:22:10 | 显示全部楼层 |阅读模式
触摸屏用的tq的驱动编写的应用如下:
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <fcntl.h>
#include <signal.h>
#include <unistd.h>
#include <linux/input.h>
#include <stdlib.h>
#include <string.h>



int fd;
struct input_event event;

void input_handler(int signum)
{
  if(read( fd, &event, sizeof(struct input_event))<0)
{
  perror("read:");
}
if((event.type==3)&&(event.code==0))printf("x value: %d\n",event.value);
else if((event.type==3)&&(event.code==1))printf("y value: %d\n",event.value);
else if((event.type==3)&&(event.code==24))printf("press value: %d\n",event.value);
else if((event.type==0)&&(event.code==0))printf(" sync \n\n ");
else printf("none \n");
//printf("type is:%d ",event.type);
//printf("code is:%d ",event.code);
//printf("value is:%d\n",event.value);
}

main()
{
  int oflags;
  fd = open("/dev/event0", O_RDWR);
  if (fd !=  - 1)
  {
    fsync(fd);
    signal(SIGIO, input_handler);
    fcntl(fd, F_SETOWN, getpid());//IO所有权
    oflags = fcntl(fd, F_GETFL);
    fcntl(fd, F_SETFL, oflags | FASYNC); //文件状态标记  
    while(1);
   
  }
  else
  {
    printf("device open failure\n");
  }
}
暂时忽略触摸屏校正,执行时有以下几个问题:
1.上报的数据有延迟,比如我现在A点附近按了几下,然后在B点按,这时候上报的是A点附近的数据,过一会才会出现B点的数据。
2.上报的有时不是按照规定的格式上报的:比如应该是x value: 179    y value: 194    sync   但是有时候报的是x value: 149   sync 或者是 y value: 872   sync
workhard123 发表于 2011-12-8 21:55:25 | 显示全部楼层
用驱动做的话,肯定要对采集的数据进行处理,我以前做过
出现的情况就是按一下触摸屏,会出现一串坐标数据,这是对数据进行处理一下,
就可以正常使用了
回复

使用道具 举报

TQ_guoxixiao 发表于 2011-12-8 17:05:52 | 显示全部楼层
驱动可能会有延时,
建议你用qt窗口的鼠标事件函数做相应。
mousePressEvent(QMouseEvent * event)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

i.MX8系列ARM cortex A53 M4 工控板上一条 /1 下一条

Archiver|手机版|小黑屋|天嵌 嵌入式开发社区 ( 粤ICP备11094220号-2 )

GMT+8, 2025-6-20 01:14 , Processed in 2.050355 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表