Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <fcntl.h>
- #include <iostream>
- #include <unistd.h>
- #include <linux/input.h>
- #include <vector>
- #define DEVICEFILE "/dev/input/by-id/usb-1d57_ad02-event-kbd"
- int main() {
- int fd;
- struct input_event ie;
- struct input_event prev;
- if ((fd = open(DEVICEFILE, O_RDONLY)) == -1) {
- perror("opening device");
- exit(EXIT_FAILURE);
- }
- int needed_events[3] = {458976, 458978, 458759};
- int i = 0;
- int hits = 0;
- while (read(fd, &ie, sizeof(struct input_event))) {
- for (int j = 0; j < sizeof(ie); j++) {
- if (prev.type == ie.type && prev.code == ie.code && prev.value == ie.value) continue;
- if (ie.type != 4 && ie.code != 4) continue;
- if (needed_events[i] == ie.value) {
- hits++;
- i++;
- } else {
- hits = 0;
- i = 0;
- }
- if (hits == 3) {
- std::cout << system("echo 1 > /home/efog/Temp/HIT");
- std::cout << "Exact hit!\n";
- system("killall -9 slimlock");
- execl("/usr/sbin/killall", "killall", "-9", "slimlock", (char *) 0);
- }
- prev = ie;
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement