10 #include <sys/ioctl.h>
16 static void __attribute__ ((noreturn))
18 fprintf(stderr, _("usage: getkeycodes\n"));
23 main(int argc, char **argv) {
28 set_progname(argv[0]);
30 setlocale(LC_ALL, "");
31 bindtextdomain(PACKAGE_NAME, LOCALEDIR);
32 textdomain(PACKAGE_NAME);
34 if (argc == 2 && !strcmp(argv[1], "-V"))
35 print_version_and_exit();
41 /* Old kernels don't support changing scancodes below SC_LIM. */
44 if (ioctl(fd, KDGETKEYCODE, &a)) {
47 for (sc0 = 1; sc0 <= 88; sc0++) {
50 if (ioctl(fd, KDGETKEYCODE, &a) || a.keycode != sc0)
54 printf(_("Plain scancodes xx (hex) versus keycodes (dec)\n"));
57 printf(_("0 is an error; "
58 "for 1-88 (0x01-0x58) scancode equals keycode\n"));
60 printf(_("for 1-%d (0x01-0x%02x) scancode equals keycode\n"),
64 for (sc = (sc0 & ~7); sc < 256; sc++) {
66 printf(_("\n\nEscaped scancodes e0 xx (hex)\n"));
69 printf("\n 0x%02x: ", sc);
71 printf("\ne0 %02x: ", sc-128);
81 if (ioctl(fd, KDGETKEYCODE, &a) == 0) {
82 printf(" %3d", a.keycode);
85 if (errno == EINVAL) {
89 perror("KDGETKEYCODE");
91 _("failed to get keycode for scancode 0x%x\n"), sc);