main.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <linux/input.h>
int main(int argc, char **argv)
{
int fd = -1;
struct input_event ev = {0};
fd = open("/dev/input/event2", O_RDONLY);
if (fd > 0) {
while (read(fd, &ev, sizeof(struct input_event))) {
if (ev.type == EV_KEY) {
printf("code:%d, value:%d\n", ev.code, ev.value);
}
}
close(fd);
}
return 0;
}
Key Code
UP 544 DOWN 545 LEFT 546 RIGHT 547 A 305 B 304 X 307 Y 308 L1 310 L2 312 R1 311 R2 313 SELECT 314 START 315 MENU 704