Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define __KERNEL_STRICT_NAMES
- #define _GNU_SOURCE
- #include <linux/input.h>
- #include <stdio.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <sys/ioctl.h>
- #include <unistd.h>
- #include <stdlib.h>
- #include <string.h>
- int main() {
- struct input_event evenement;
- int fd=open("/dev/input/event11", O_RDONLY);
- if(!fd)
- return -1;
- ioctl(fd, EVIOCGRAB,1);
- while(1) {
- if(read(fd, &evenement, sizeof(evenement))<0)
- return -1;
- switch(evenement.code) {
- default:
- printf("time (s): %d\ntype: %d\ncode: %d\nvalue: %d\n", evenement.time.tv_sec,
- evenement.type,
- evenement.code,
- evenement.value);
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement