test.c

来自「FS2410开发板点触屏驱动原码」· C语言 代码 · 共 37 行

C
37
字号
#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/TS"
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;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?