Chinaunix首页 | 论坛 | 博客
  • 博客访问: 848718
  • 博文数量: 156
  • 博客积分: 6553
  • 博客等级: 准将
  • 技术积分: 3965
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-22 18:36
文章存档

2012年(3)

2011年(43)

2010年(110)

分类: 嵌入式

2010-10-19 20:42:18

#include
#include
#include
#include
#include
#include
#include
#define TS_DEV "/dev/touchscreen/0"  //设备文件要看下/dev目录
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;
}
阅读(882) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~