#include <sys/types.h>
#include <sys/ipc.h>
#include <stdio.h>
#include <fcntl.h>
#include <pthread.h>
#include <unistd.h>
#include <sys/ioctl.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/touchscreen/0" //设备文件要看下/dev目录
static int ts_fd=-1;
static int ts_fd=-1;
typedef struct {
unsigned short pressure;
unsigned short x;
unsigned short y;
unsigned short pad;
} TS_RET;//注意这个结构体
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;
}
{
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;
}