1 Make the showkey's "-a" option default instead of "-k"
3 --- a/console-tools/showkey.c
4 +++ b/console-tools/showkey.c
6 //usage: "[-a | -k | -s]"
7 //usage:#define showkey_full_usage "\n\n"
8 //usage: "Show keys pressed\n"
9 -//usage: "\n -a Display decimal/octal/hex values of the keys"
10 -//usage: "\n -k Display interpreted keycodes (default)"
11 +//usage: "\n -a Display decimal/octal/hex values of the keys (default)"
12 +//usage: "\n -k Display interpreted keycodes"
13 //usage: "\n -s Display raw scan-codes"
16 @@ -54,8 +54,8 @@ int showkey_main(int argc, char **argv)
17 int showkey_main(int argc UNUSED_PARAM, char **argv)
20 - OPT_a = (1<<0), // display the decimal/octal/hex values of the keys
21 - OPT_k = (1<<1), // display only the interpreted keycodes (default)
22 + OPT_a = (1<<0), // display the decimal/octal/hex values of the keys (default)
23 + OPT_k = (1<<1), // display only the interpreted keycodes
24 OPT_s = (1<<2), // display only the raw scan-codes
27 @@ -71,20 +71,7 @@ int showkey_main(int argc UNUSED_PARAM,
29 #define press_keys "Press any keys, program terminates %s:\r\n\n"
31 - if (option_mask32 & OPT_a) {
32 - // just read stdin char by char
35 - printf(press_keys, "on EOF (ctrl-D)");
37 - // read and show byte values
38 - while (1 == read(STDIN_FILENO, &c, 1)) {
39 - printf("%3u 0%03o 0x%02x\r\n", c, c, c);
40 - if (04 /*CTRL-D*/ == c)
45 + if (option_mask32 & OPT_k || option_mask32 & OPT_s) {
46 // we assume a PC keyboard
47 xioctl(STDIN_FILENO, KDGKBMODE, &kbmode);
48 printf("Keyboard mode was %s.\r\n\n",
49 @@ -141,6 +128,19 @@ int showkey_main(int argc UNUSED_PARAM,
51 // restore keyboard mode
52 xioctl(STDIN_FILENO, KDSKBMODE, (void *)(ptrdiff_t)kbmode);
55 + // just read stdin char by char
58 + printf(press_keys, "on EOF (ctrl-D)");
60 + // read and show byte values
61 + while (1 == read(STDIN_FILENO, &c, 1)) {
62 + printf("%3u 0%03o 0x%02x\r\n", c, c, c);
63 + if (04 /*CTRL-D*/ == c)
68 // restore console settings