www.pudn.com > touch.rar > tstest.c
#include#include #include /* for data reading from /dev/ts */ typedef struct { unsigned short pressure; unsigned short x; unsigned short y; unsigned short pad; } TS_EVENT; /* * tstest application code, the start code of Linux touch screen application * compile : * $/usr/local/arm/2.95.3/bin/arm-linux-gcc -o tstest tstest.c * $cp tstest /tftpboot/examples * run in target: * #mount 192.168.1.180:/tftpboot/ /mnt/nfs * #cd /mnt/nfs/examples * #./tstest */ int main(int argc, char **argv) { static int ts = -1; static int mousex = 0; static int mousey = 0; static TS_EVENT ts_event; // touch screen printf("touch screen test program\n"); printf("please touch the screen\n"); ts = open ("/dev/ts", O_RDONLY); if (ts < 0) { fprintf (stderr, "Can not open touch screen!\n"); exit(1); } while(1) { read (ts, &ts_event, sizeof (TS_EVENT)); if (ts_event.pressure > 0) { printf ("mouse down: ts_event.x = %d, ts_event.y = %d\n", ts_event.x, ts_event.y); } } }