int keycode;
if ((keycode = evdev_get_keycode(fd, scancode, 1)) < 0) {
- if (keycode != -2)
- r = -1;
+ if (keycode == -2)
+ continue;
+ r = -1;
break;
}
f = fopen(filename, "r");
if (!f) {
perror(filename);
- r = -1;
- goto fail;
+ return -1;
}
while (!feof(f)) {
scancode, new_keycode, old_keycode);
}
fail:
+ fclose(f);
return r;
}
/* grab input device */
ioctl(fd, EVIOCGRAB, 1);
- puts("Press ESC to finish");
+ puts("Press ESC to finish, or Control-C if this device is not your primary keyboard");
has_scan = has_key = 0;
while (read_event(fd, &ev)) {