touchTest/parseDevicesTest.c
changeset 4645 0375d020e7e3
child 4646 eea1bf53effa
equal deleted inserted replaced
4644:fb500b3e1717 4645:0375d020e7e3
       
     1 #include <stdio.h>
       
     2 #include <stdlib.h>
       
     3 #include <linux/input.h>
       
     4 
       
     5 
       
     6 int main(int agrc,char **argv)
       
     7 {
       
     8   FILE *fd;
       
     9   fd = fopen("/proc/bus/input/devices","r");
       
    10   
       
    11   char c;
       
    12   int i = 0;
       
    13   char line[256];
       
    14   char tstr[256];
       
    15   int vendor = -1,product = -1,event = -1;
       
    16   while(!feof(fd)) {
       
    17     fgets(line,256,fd);
       
    18     //printf("%s",line);
       
    19     if(line[0] == '\n') {
       
    20       if(vendor == 1386){
       
    21 	printf("Wacom... Assuming it is a touch device\n");
       
    22 	sprintf(tstr,"/dev/input/event%i",event);
       
    23 	printf("At location: %s\n",tstr);
       
    24 		
       
    25 	
       
    26       }
       
    27       vendor = -1;
       
    28       product = -1;
       
    29       event = -1;      
       
    30     }
       
    31     else if(line[0] == 'I') {
       
    32       i = 1;
       
    33       while(line[i]) {
       
    34 	sscanf(&line[i],"Vendor=%x",&vendor);
       
    35 	sscanf(&line[i],"Product=%x",&product);
       
    36 	i++;
       
    37       }
       
    38     }
       
    39     else if(line[0] == 'H') {
       
    40       i = 1;
       
    41       while(line[i]) {
       
    42 	sscanf(&line[i],"event%d",&event);
       
    43 	i++;
       
    44       }
       
    45     }
       
    46   }
       
    47   
       
    48   close(fd);
       
    49   return 0;
       
    50 }