int fd = -1;
char name[256]= "Unknown";
if ((fd = open(argv[1], O_RDONLY)) < 0) {
perror("evdev open");
exit(1);
}
if(ioctl(fd, EVIOCGNAME(sizeof(name)), name) < 0) {
perror("evdev ioctl");
}
printf("The device on %s says its name is %s\n",
argv[1], name);
close(fd);