1 Make the showkey's "-a" option default instead of "-k"
3 By Dennis Groenen <tj.groenen@gmail.com> - 2011-08-19
6 --- a/console-tools/showkey.c
7 +++ b/console-tools/showkey.c
9 //usage: "[-a | -k | -s]"
10 //usage:#define showkey_full_usage "\n\n"
11 //usage: "Show keys pressed\n"
12 -//usage: "\n -a Display decimal/octal/hex values of the keys"
13 -//usage: "\n -k Display interpreted keycodes (default)"
14 +//usage: "\n -a Display decimal/octal/hex values of the keys (default)"
15 +//usage: "\n -k Display interpreted keycodes"
16 //usage: "\n -s Display raw scan-codes"
19 @@ -54,8 +54,8 @@ int showkey_main(int argc, char **argv)
20 int showkey_main(int argc UNUSED_PARAM, char **argv)
23 - OPT_a = (1<<0), // display the decimal/octal/hex values of the keys
24 - OPT_k = (1<<1), // display only the interpreted keycodes (default)
25 + OPT_a = (1<<0), // display the decimal/octal/hex values of the keys (default)
26 + OPT_k = (1<<1), // display only the interpreted keycodes
27 OPT_s = (1<<2), // display only the raw scan-codes
30 @@ -71,20 +71,7 @@ int showkey_main(int argc UNUSED_PARAM,
32 #define press_keys "Press any keys, program terminates %s:\r\n\n"
34 - if (option_mask32 & OPT_a) {
35 - // just read stdin char by char
38 - printf(press_keys, "on EOF (ctrl-D)");
40 - // read and show byte values
41 - while (1 == read(STDIN_FILENO, &c, 1)) {
42 - printf("%3u 0%03o 0x%02x\r\n", c, c, c);
43 - if (04 /*CTRL-D*/ == c)
48 + if (option_mask32 & OPT_k || option_mask32 & OPT_s) {
49 // we assume a PC keyboard
50 xioctl(STDIN_FILENO, KDGKBMODE, &kbmode);
51 printf("Keyboard mode was %s.\r\n\n",
52 @@ -141,6 +128,19 @@ int showkey_main(int argc UNUSED_PARAM,
54 // restore keyboard mode
55 xioctl(STDIN_FILENO, KDSKBMODE, (void *)(ptrdiff_t)kbmode);
58 + // just read stdin char by char
61 + printf(press_keys, "on EOF (ctrl-D)");
63 + // read and show byte values
64 + while (1 == read(STDIN_FILENO, &c, 1)) {
65 + printf("%3u 0%03o 0x%02x\r\n", c, c, c);
66 + if (04 /*CTRL-D*/ == c)
71 // restore console settings