Advertisement
Guest User

phh

a guest
Apr 6th, 2009
464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #define __KERNEL_STRICT_NAMES
  2. #define _GNU_SOURCE
  3. #include <linux/input.h>
  4. #include <stdio.h>
  5. #include <sys/types.h>
  6. #include <sys/stat.h>
  7. #include <fcntl.h>
  8. #include <sys/ioctl.h>
  9. #include <unistd.h>
  10. #include <stdlib.h>
  11. #include <string.h>
  12.  
  13. int main() {
  14. struct input_event evenement;
  15. int fd=open("/dev/input/event11", O_RDONLY);
  16. if(!fd)
  17. return -1;
  18. ioctl(fd, EVIOCGRAB,1);
  19. while(1) {
  20. if(read(fd, &evenement, sizeof(evenement))<0)
  21. return -1;
  22. switch(evenement.code) {
  23. default:
  24. printf("time (s): %d\ntype: %d\ncode: %d\nvalue: %d\n", evenement.time.tv_sec,
  25. evenement.type,
  26. evenement.code,
  27. evenement.value);
  28. break;
  29. }
  30. }
  31. return 0;
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement