Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.95 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <unistd.h>
  5. #include <errno.h>
  6. #include <fcntl.h>
  7. #include <dirent.h>
  8. #include <linux/input.h>
  9. #include <sys/types.h>
  10. #include <sys/stat.h>
  11. #include <sys/select.h>
  12. #include <sys/time.h>
  13. #include <termios.h>
  14. #include <signal.h>
  15.  
  16. int main(int argc, char* argv[])
  17. {
  18.     struct input_event ev[64];
  19.     int fevdev = -1;
  20.     int result = 0;
  21.     int size = sizeof(struct input_event);
  22.     int rd;
  23.     int value;
  24.     char name[256] = "Unknown";
  25.     char *device = "/dev/input/event16";
  26.  
  27.     fevdev = open(device, O_RDONLY);
  28.     ioctl(fevdev, EVIOCGRAB, 1);
  29.  
  30.     while (1)
  31.     {
  32.         read(fevdev, ev, size * 64);
  33.  
  34.         value = ev[0].value;
  35.  
  36.         printf ("code - %d \n", ev[1].code);
  37.         printf ("type - %d \n", ev[1].type);
  38.         printf ("value - %d \n", ev[1].value);
  39.         printf ("\n");
  40.     }
  41.  
  42.     ioctl(fevdev, EVIOCGRAB, 0);
  43.     close(fevdev);
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement