• «
  • 1
  • 2
  • »
  • Pages: 1/2     Go
主题 : 触摸屏设备使用 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 4209
精华: 0
发帖: 10
金钱: 70 两
威望: 46 点
综合积分: 20 分
注册时间: 2009-03-04
最后登录: 2017-09-13
楼主  发表于: 2009-05-07 13:56

 触摸屏设备使用

友善的2.6.29启动时显示触摸屏驱动加载,input:s3c2410 TouchScreen as /devices/virtual/input/input0
这个路径是什么意思。我要使用触摸屏,如何创建驱动设备文件?
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
1楼  发表于: 2009-05-07 14:22
那是内核input模块的sysfs路径,你不需要关心。
如果你用友善之臂提供的root_qtopia文件系统,设备节点文件已经由mdev创建好了: /dev/input/event0;

如果你用的文件系统里没有mdev这种自动创建设备节点的东西,可以通过下面的命令手动创建
mknod /dev/input/event0 c 13 64
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 侠客
UID: 3939
精华: 0
发帖: 63
金钱: 550 两
威望: 463 点
综合积分: 126 分
注册时间: 2009-02-17
最后登录: 2012-08-31
2楼  发表于: 2009-05-07 14:50
#include <sys/types.h>
#include <sys/ipc.h>
#include <stdio.h>
#include <fcntl.h>
#include <pthread.h>
#include <unistd.h>
#include <sys/ioctl.h>

#define TS_DEV "/dev/input/event0"
static int ts_fd=-1;

typedef struct {
  unsigned short pressure;
  unsigned short x;
  unsigned short y;
  unsigned short pad;
} TS_RET;

int main()
{
    TS_RET data;
    
    if((ts_fd=open(TS_DEV,O_RDONLY))<0)
    {
        printf("Error opening %s device!\n",TS_DEV);
        return -1;
    }
    
    while(1)
    {
        read(ts_fd,&data,sizeof(data));
        printf("x=%d,y=%d,pressure=%d\n",data.x,data.y,data.pressure);
    }
    
    return 0;
}
这样的测试程序可以吗,我试过怎么不行呢,按下触摸屏后串口终端打印出来的信息一直没有变化
级别: 侠客
UID: 3939
精华: 0
发帖: 63
金钱: 550 两
威望: 463 点
综合积分: 126 分
注册时间: 2009-02-17
最后登录: 2012-08-31
3楼  发表于: 2009-05-07 14:54
像这样的/dev/input/event0
/dev/leds
/dev/buttons
是怎么创建的,和什么在关呢
这个阶段正是我事业的上升期,我怎么能走得开呢?
级别: 精灵王
UID: 3197
精华: 3
发帖: 770
金钱: 6995 两
威望: 5398 点
综合积分: 1600 分
注册时间: 2008-12-30
最后登录: 2010-12-31
4楼  发表于: 2009-05-07 15:17
qtopia系统已经打开并使用触摸屏设备了,它是不能被同时打开的,可以关闭qtopia系统试试。
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
5楼  发表于: 2009-05-07 16:43
引用第2楼zzh2008于2009-05-07 14:50发表的  :
#include <sys/types.h>
#include <sys/ipc.h>
#include <stdio.h>
#include <fcntl.h>
#include <pthread.h>
.......

不要在友善之臂提供的2.6.29的内核上用这个测试程序,内核里的触摸屏驱动是基于input框架的,这个测试程序是针对老的没有框架的触摸屏驱动的,两者不兼容。

你可以:
1. 不要启动Qtopia。
2. 通过tslib的接口操作触摸屏。

至于如何通过tslib的接口读取触摸屏驱动,可以参考tslib里的ts_calibrate源代码
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
6楼  发表于: 2009-05-07 16:45
引用第3楼zzh2008于2009-05-07 14:54发表的  :
像这样的/dev/input/event0
/dev/leds
/dev/buttons
是怎么创建的,和什么在关呢

busybox的mdev,详细信息可以参考我写的这篇帖子http://www.aiothome.com/bbs/read.php?tid-1702.html
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 新手上路
UID: 8391
精华: 0
发帖: 5
金钱: 50 两
威望: 25 点
综合积分: 10 分
注册时间: 2009-08-21
最后登录: 2009-12-20
7楼  发表于: 2009-08-21 16:40
请问我在用sdl做GUI,请问我如何屏蔽掉QT?还有就是我在程序中也把触摸屏上的坐标转换为LCD上,这个坐标变化用什么公式计算的啊?我用MINI2440+3.5寸的板子
级别: 侠客
UID: 8515
精华: 0
发帖: 62
金钱: 535 两
威望: 233 点
综合积分: 124 分
注册时间: 2009-08-26
最后登录: 2014-06-25
8楼  发表于: 2009-09-22 14:49

 回 5楼(kasim) 的帖子

你好,请教下min2440 linux2.6.29 QT对触摸的支持,可以直接修改QT库,而不使用tslib吗?
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
9楼  发表于: 2009-09-22 15:19

 Re:回 5楼(kasim) 的帖子

引用第8楼xiongbiaowh于2009-09-22 14:49发表的 回 5楼(kasim) 的帖子 :
你好,请教下min2440 linux2.6.29 QT对触摸的支持,可以直接修改QT库,而不使用tslib吗?

可以,直接操作触摸屏对应的/dev/input/eventX设备节点就可以了。
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
  • «
  • 1
  • 2
  • »
  • Pages: 1/2     Go