This repository has been archived by the owner on Feb 11, 2021. It is now read-only.
/
parseDevicesTest.c
67 lines (59 loc) · 1.25 KB
1
2
3
#include <stdio.h>
#include <stdlib.h>
#include <linux/input.h>
4
#include <fcntl.h>
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
int main(int agrc,char **argv)
{
FILE *fd;
fd = fopen("/proc/bus/input/devices","r");
char c;
int i = 0;
char line[256];
char tstr[256];
int vendor = -1,product = -1,event = -1;
while(!feof(fd)) {
fgets(line,256,fd);
//printf("%s",line);
if(line[0] == '\n') {
if(vendor == 1386){
printf("Wacom... Assuming it is a touch device\n");
sprintf(tstr,"/dev/input/event%i",event);
printf("At location: %s\n",tstr);
26
int inFile = open(tstr,O_RDONLY);
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
unsigned long bits[4];
int abs[5];
ioctl(inFile,EVIOCGABS(ABS_X),abs);
int minx,maxx,miny,maxy,minp,maxp;
minx = abs[1];
maxx = abs[2];
ioctl(inFile,EVIOCGABS(ABS_Y),abs);
miny = abs[1];
maxy = abs[2];
ioctl(inFile,EVIOCGABS(ABS_PRESSURE),abs);
minp = abs[1];
maxp = abs[2];
close(inFile);
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
}
vendor = -1;
product = -1;
event = -1;
}
else if(line[0] == 'I') {
i = 1;
while(line[i]) {
sscanf(&line[i],"Vendor=%x",&vendor);
sscanf(&line[i],"Product=%x",&product);
i++;
}
}
else if(line[0] == 'H') {
i = 1;
while(line[i]) {
sscanf(&line[i],"event%d",&event);
i++;
}
}
}
close(fd);
return 0;
}