Skip to content

Commit 19c11c8

Browse files
committed
Some very likely wrong linux attempts
1 parent a9af2b1 commit 19c11c8

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

src/linux/linux_test.c

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,48 @@
22
#include <linux/uinput.h>
33
#include <unistd.h>
44
#include <fcntl.h>
5-
#include <stdio.h>
5+
66

77
void emit (int fd, int type, int code, int val) {
8-
struct input_event ie;
8+
struct input_event ie;
99

10-
ie.type = type;
11-
ie.code = code;
12-
ie.value = val;
13-
ie.time.tv_sec = 0;
14-
ie.time.tv_usec = 0;
10+
ie.type = type;
11+
ie.code = code;
12+
ie.value = val;
13+
ie.time.tv_sec = 0;
14+
ie.time.tv_usec = 0;
1515

16-
write(fd, &ie, sizeof(ie));
16+
write(fd, & ie, sizeof(ie));
1717
}
1818

1919
int linux_main (void) {
20-
struct uinput_setup usetup;
20+
struct uinput_setup usetup;
2121

22-
int fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);
22+
int fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);
2323

24-
ioctl(fd, UI_SET_EVBIT, EV_KEY);
25-
ioctl(fd, UI_SET_KEYBIT, KEY_SPACE);
24+
ioctl(fd, UI_SET_EVBIT, EV_KEY);
25+
ioctl(fd, UI_SET_KEYBIT, KEY_SPACE);
2626

27-
memset(&usetup, 0, sizeof(usetup));
28-
usetup.id.bustype = BUS_USB;
29-
usetup.id.vendor = 0x1234;
30-
usetup.id.product = 0x5678;
31-
strcpy(usetup.name, "Example device");
27+
memset(& usetup, 0, sizeof(usetup));
28+
usetup.id.bustype = BUS_USB;
29+
usetup.id.vendor = 0x1234;
30+
usetup.id.product = 0x5678;
31+
strcpy(usetup.name, "Example Device");
3232

33-
ioctl(fd, UI_DEV_SETUP, &usetup);
34-
ioctl(fd, UI_DEV_CREATE);
33+
ioctl(fd, UI_DEV_SETUP, & usetup);
34+
ioctl(fd, UI_DEV_CREATE);
3535

36-
sleep(1);
36+
sleep(1);
3737

38-
emit(fd, EV_KEY, KEY_SPACE, 1);
39-
emit(fd, EV_SYN, SYN_REPORT, 0);
40-
emit(fd, EV_KEY, KEY_SPACE, 0);
41-
emit(fd, EV_SYN, SYN_REPORT, 0);
38+
emit(fd, EV_KEY, KEY_SPACE, 1);
39+
emit(fd, EV_SYN, SYN_REPORT, 0);
40+
emit(fd, EV_KEY, KEY_SPACE, 0);
41+
emit(fd, EV_SYN, SYN_REPORT, 0);
4242

43-
sleep(1);
43+
sleep(1);
4444

45-
ioctl(fd, UI_DEV_DESTROY);
46-
close(fd);
45+
ioctl(fd, UI_DEV_DESTROY);
4746

48-
return 0;
49-
}
47+
close(fd);
48+
return 0;
49+
}

0 commit comments

Comments
 (0)