SHOW:
|
|
- or go back to the newest paste.
1 | #include <stdio.h> | |
2 | #include <string.h> | |
3 | #include <fcntl.h> | |
4 | #include <errno.h> | |
5 | #include <termios.h> | |
6 | #include <unistd.h> | |
7 | #include <xdo.h> | |
8 | #include <X11/Xlib.h> | |
9 | #include <X11/keysym.h> | |
10 | ||
11 | - | int open_serial(char *port); |
11 | + | |
12 | - | void close_serial(int fd); |
12 | + | |
13 | sleep(1); //wait 1 second | |
14 | printf("creating xdo...\n"); | |
15 | xdo_t* myXdo = xdo_new(NULL); | |
16 | printf("xdo created...\n"); | |
17 | ||
18 | printf("getting display...\n"); | |
19 | // Obtain the X11 display. | |
20 | Display *display = XOpenDisplay(0); | |
21 | if(display == NULL) | |
22 | { | |
23 | printf("could not open display, exiting...\n"); | |
24 | return -1; | |
25 | } | |
26 | ||
27 | printf("getting root window...\n"); | |
28 | // Window focus | |
29 | int revert; | |
30 | Window winFocus; | |
31 | ||
32 | while(1) | |
33 | { | |
34 | XGetInputFocus(display, &winFocus, &revert); | |
35 | - | int fd = open_serial("/dev/ttyACM0"); |
35 | + | xdo_keysequence_up(myXdo, winFocus, "A", 100); |
36 | - | if(fd == 0) |
36 | + | xdo_keysequence_down(myXdo, winFocus, "A", 100); |
37 | usleep(1000 * 1000); | |
38 | - | printf("serial error, exiting...\n"); |
38 | + | |
39 | - | return -1; |
39 | + | |
40 | printf("exiting...\n"); | |
41 | - | char buff; |
41 | + | |
42 | - | unsigned int rd; |
42 | + | |
43 | return 0; | |
44 | } |