Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <unistd.h>
- #include <fcntl.h>
- #include <stdio.h>
- #include <linux/input.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- int main(int argc, char *argv[])
- {
- int fd;
- struct input_event ev;
- fd = open("/dev/input/event4", O_RDONLY);
- if (fd < 0)
- {
- perror("Cannot open file");
- return 1;
- }
- while(1)
- {
- if (read(fd, &ev, sizeof(struct input_event)) < 0)
- {
- perror("Cannot read");
- return 1;
- }
- if(ev.type== EV_KEY) {
- printf("Eventtype: %d\n"
- "\tcode: %d\n"
- "\tValue: %d\n" , ev.type, ev.code, ev.value);
- fflush(stdout);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement