annotate touchTest/parseDevicesTest.c @ 4645:0375d020e7e3

Auto-detects Wacom touch devices.
author Jim Grandpre <jim.tla@gmail.com>
date Mon, 31 May 2010 00:24:37 -0400
parents
children eea1bf53effa
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>
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
4
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 int main(int agrc,char **argv)
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
7 {
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
8 FILE *fd;
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
9 fd = fopen("/proc/bus/input/devices","r");
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
10
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
11 char c;
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
12 int i = 0;
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
13 char line[256];
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
14 char tstr[256];
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
15 int vendor = -1,product = -1,event = -1;
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
16 while(!feof(fd)) {
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
17 fgets(line,256,fd);
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
18 //printf("%s",line);
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
19 if(line[0] == '\n') {
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
20 if(vendor == 1386){
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
21 printf("Wacom... Assuming it is a touch device\n");
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
22 sprintf(tstr,"/dev/input/event%i",event);
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
23 printf("At location: %s\n",tstr);
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
24
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
25
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
26 }
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
27 vendor = -1;
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
28 product = -1;
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
29 event = -1;
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
30 }
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
31 else if(line[0] == 'I') {
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
32 i = 1;
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
33 while(line[i]) {
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
34 sscanf(&line[i],"Vendor=%x",&vendor);
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
35 sscanf(&line[i],"Product=%x",&product);
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
36 i++;
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
37 }
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
38 }
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
39 else if(line[0] == 'H') {
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
40 i = 1;
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
41 while(line[i]) {
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
42 sscanf(&line[i],"event%d",&event);
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
43 i++;
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
44 }
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
45 }
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
46 }
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 close(fd);
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
49 return 0;
0375d020e7e3 Auto-detects Wacom touch devices.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
50 }