touchTest/parseDevicesTest.c
changeset 4645 0375d020e7e3
child 4646 eea1bf53effa
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/touchTest/parseDevicesTest.c	Mon May 31 00:24:37 2010 -0400
     1.3 @@ -0,0 +1,50 @@
     1.4 +#include <stdio.h>
     1.5 +#include <stdlib.h>
     1.6 +#include <linux/input.h>
     1.7 +
     1.8 +
     1.9 +int main(int agrc,char **argv)
    1.10 +{
    1.11 +  FILE *fd;
    1.12 +  fd = fopen("/proc/bus/input/devices","r");
    1.13 +  
    1.14 +  char c;
    1.15 +  int i = 0;
    1.16 +  char line[256];
    1.17 +  char tstr[256];
    1.18 +  int vendor = -1,product = -1,event = -1;
    1.19 +  while(!feof(fd)) {
    1.20 +    fgets(line,256,fd);
    1.21 +    //printf("%s",line);
    1.22 +    if(line[0] == '\n') {
    1.23 +      if(vendor == 1386){
    1.24 +	printf("Wacom... Assuming it is a touch device\n");
    1.25 +	sprintf(tstr,"/dev/input/event%i",event);
    1.26 +	printf("At location: %s\n",tstr);
    1.27 +		
    1.28 +	
    1.29 +      }
    1.30 +      vendor = -1;
    1.31 +      product = -1;
    1.32 +      event = -1;      
    1.33 +    }
    1.34 +    else if(line[0] == 'I') {
    1.35 +      i = 1;
    1.36 +      while(line[i]) {
    1.37 +	sscanf(&line[i],"Vendor=%x",&vendor);
    1.38 +	sscanf(&line[i],"Product=%x",&product);
    1.39 +	i++;
    1.40 +      }
    1.41 +    }
    1.42 +    else if(line[0] == 'H') {
    1.43 +      i = 1;
    1.44 +      while(line[i]) {
    1.45 +	sscanf(&line[i],"event%d",&event);
    1.46 +	i++;
    1.47 +      }
    1.48 +    }
    1.49 +  }
    1.50 +  
    1.51 +  close(fd);
    1.52 +  return 0;
    1.53 +}