Skip to content

Commit 153283c

Browse files
init
0 parents  commit 153283c

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.out
2+
*.o

main.c

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#include <linux/input.h>
2+
#include <stdio.h>
3+
#include <unistd.h>
4+
#include <stdlib.h>
5+
#include <fcntl.h>
6+
7+
#define TOUCHPAD_FILE "/dev/input/event11"
8+
9+
void switchTabs(bool right)
10+
{
11+
12+
}
13+
14+
15+
void handleTrackPad()
16+
{
17+
int fd;
18+
bool twoFingers = false;
19+
struct input_event ie;
20+
if ((fd = open(TOUCHPAD_FILE, O_RDONLY)) == -1)
21+
{
22+
perror("Could not open the touchpad event file");
23+
exit(EXIT_FAILURE);
24+
}
25+
while (read(fd, &ie, sizeof(struct input_event)))
26+
{
27+
28+
switch (ie.code)
29+
{
30+
case BTN_TOOL_FINGER:
31+
/* code */
32+
printf("Finger\n");
33+
break;
34+
case BTN_TOOL_DOUBLETAP:
35+
/* code */
36+
printf("Double\n");
37+
twoFingers = !twoFingers;
38+
break;
39+
case ABS_X:
40+
if(twoFingers)
41+
printf("Switch Tabs Here %d\n ", ie.value);
42+
break;
43+
default:
44+
break;
45+
}
46+
}
47+
}
48+
49+
int main()
50+
{
51+
handleTrackPad();
52+
return 0;
53+
}

0 commit comments

Comments
 (0)