annotate touchTest/parseDevicesTest.c @ 4670:ad4f32e874ee

Added preliminary touch code to SDL_cocoakeyboard.m
author jimtla
date Sat, 24 Jul 2010 22:28:38 +0400
parents eea1bf53effa
children
rev   line source
4645
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
1 #include <stdio.h>
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
2 #include <stdlib.h>
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
3 #include <linux/input.h>
4646
eea1bf53effa Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents: 4645
diff changeset
4 #include <fcntl.h>
4645
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
5
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
6
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
7 int main(int agrc,char **argv)
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
8 {
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
9 FILE *fd;
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
10 fd = fopen("/proc/bus/input/devices","r");
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
11
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
12 char c;
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
13 int i = 0;
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
14 char line[256];
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
15 char tstr[256];
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
16 int vendor = -1,product = -1,event = -1;
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
17 while(!feof(fd)) {
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
18 fgets(line,256,fd);
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
19 //printf("%s",line);
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
20 if(line[0] == '\n') {
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
21 if(vendor == 1386){
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
22 printf("Wacom... Assuming it is a touch device\n");
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
23 sprintf(tstr,"/dev/input/event%i",event);
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
24 printf("At location: %s\n",tstr);
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
25
4646
eea1bf53effa Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents: 4645
diff changeset
26 int inFile = open(tstr,O_RDONLY);
4645
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
27
4646
eea1bf53effa Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents: 4645
diff changeset
28 unsigned long bits[4];
eea1bf53effa Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents: 4645
diff changeset
29 int abs[5];
eea1bf53effa Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents: 4645
diff changeset
30 ioctl(inFile,EVIOCGABS(ABS_X),abs);
eea1bf53effa Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents: 4645
diff changeset
31 int minx,maxx,miny,maxy,minp,maxp;
eea1bf53effa Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents: 4645
diff changeset
32 minx = abs[1];
eea1bf53effa Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents: 4645
diff changeset
33 maxx = abs[2];
eea1bf53effa Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents: 4645
diff changeset
34 ioctl(inFile,EVIOCGABS(ABS_Y),abs);
eea1bf53effa Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents: 4645
diff changeset
35 miny = abs[1];
eea1bf53effa Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents: 4645
diff changeset
36 maxy = abs[2];
eea1bf53effa Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents: 4645
diff changeset
37 ioctl(inFile,EVIOCGABS(ABS_PRESSURE),abs);
eea1bf53effa Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents: 4645
diff changeset
38 minp = abs[1];
eea1bf53effa Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents: 4645
diff changeset
39 maxp = abs[2];
eea1bf53effa Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents: 4645
diff changeset
40
eea1bf53effa Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents: 4645
diff changeset
41
eea1bf53effa Added include/touch.h Now reading in resolution of touch pad.
Jim Grandpre <jim.tla@gmail.com>
parents: 4645
diff changeset
42 close(inFile);
4645
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
43 }
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
44 vendor = -1;
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
45 product = -1;
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
46 event = -1;
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
47 }
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
48 else if(line[0] == 'I') {
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
49 i = 1;
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
50 while(line[i]) {
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
51 sscanf(&line[i],"Vendor=%x",&vendor);
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
52 sscanf(&line[i],"Product=%x",&product);
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
53 i++;
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
54 }
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
55 }
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
56 else if(line[0] == 'H') {
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
57 i = 1;
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
58 while(line[i]) {
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
59 sscanf(&line[i],"event%d",&event);
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
60 i++;
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
61 }
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
62 }
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
63 }
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
64
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
65 close(fd);
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
66 return 0;
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
67 }