#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <fcntl.h>
#include <linux/input.h>
#include <math.h>
#define TS_DEV "/dev/input/event0"
static int ts_fd = -1;
static int init_device()
{
if((ts_fd = open(TS_DEV, O_RDONLY)) < 0)
{
printf("Error open %s\n", TS_DEV);
return -1;
}
return ts_fd;
}
int main()
{
int i,x,y;
int x_abs=0;
int y_abs=0;
struct input_event data;
if(init_device() < 0)
return -1;
while(1)
{
read(ts_fd, &data, sizeof(data));
if(data.type == EV_ABS&&data.code == ABS_X)
{
x=data.value;
}
else if(data.type == EV_ABS&&data.code == ABS_Y)
{
y=data.value;
}
if(abs(x-x_abs)>10||abs(y-y_abs)>10)
{
x_abs=x;
y_abs=y;
printf("x=%d,y=%d\n",x_abs,y_abs);
}
}
return 0;
}
在 2440 上是能读出 坐标的;
但6410 不行;
如果 改成这个"/dev/touchscreen" 也不行 应该是结构体 不同了,不知怎么好?