import local busybox-power tree (1.18.5power2)
[busybox-power] / debian / patches / showkey-default-option.patch
1 Make the showkey's "-a" option default instead of "-k"
2
3 By Dennis Groenen <dennis_groenen@hotmail.com> - 2011-05-27
4 ---
5
6 --- a/console-tools/showkey.c
7 +++ b/console-tools/showkey.c
8 @@ -46,8 +46,8 @@ int showkey_main(int argc, char **argv) 
9  int showkey_main(int argc UNUSED_PARAM, char **argv)
10  {
11         enum {
12 -               OPT_a = (1<<0), // display the decimal/octal/hex values of the keys
13 -               OPT_k = (1<<1), // display only the interpreted keycodes (default)
14 +               OPT_a = (1<<0), // display the decimal/octal/hex values of the keys (default)
15 +               OPT_k = (1<<1), // display only the interpreted keycodes
16                 OPT_s = (1<<2), // display only the raw scan-codes
17         };
18  
19 @@ -63,20 +63,7 @@ int showkey_main(int argc UNUSED_PARAM, 
20  
21  #define press_keys "Press any keys, program terminates %s:\r\n\n"
22  
23 -       if (option_mask32 & OPT_a) {
24 -               // just read stdin char by char
25 -               unsigned char c;
26 -
27 -               printf(press_keys, "on EOF (ctrl-D)");
28 -
29 -               // read and show byte values
30 -               while (1 == read(STDIN_FILENO, &c, 1)) {
31 -                       printf("%3u 0%03o 0x%02x\r\n", c, c, c);
32 -                       if (04 /*CTRL-D*/ == c)
33 -                               break;
34 -               }
35 -
36 -       } else {
37 +       if (option_mask32 & OPT_k || option_mask32 & OPT_s) {
38                         // we assume a PC keyboard
39                         xioctl(STDIN_FILENO, KDGKBMODE, &kbmode);
40                         printf("Keyboard mode was %s.\r\n\n",
41 @@ -133,6 +120,19 @@ int showkey_main(int argc UNUSED_PARAM, 
42  
43                 // restore keyboard mode
44                 xioctl(STDIN_FILENO, KDSKBMODE, (void *)(ptrdiff_t)kbmode);
45 +
46 +       } else {
47 +               // just read stdin char by char
48 +               unsigned char c;
49 +
50 +               printf(press_keys, "on EOF (ctrl-D)");
51 +
52 +               // read and show byte values
53 +               while (1 == read(STDIN_FILENO, &c, 1)) {
54 +                       printf("%3u 0%03o 0x%02x\r\n", c, c, c);
55 +                       if (04 /*CTRL-D*/ == c)
56 +                               break;
57 +               }
58         }
59  
60         // // restore console settings
61 --- a/include/usage.src.h
62 +++ b/include/usage.src.h
63 @@ -3488,8 +3488,8 @@ INSERT
64  #define showkey_full_usage "\n\n" \
65         "Show keys pressed\n" \
66       "\nOptions:" \
67 -     "\n       -a      Display decimal/octal/hex values of the keys" \
68 -     "\n       -k      Display interpreted keycodes (default)" \
69 +     "\n       -a      Display decimal/octal/hex values of the keys (default)" \
70 +     "\n       -k      Display interpreted keycodes" \
71       "\n       -s      Display raw scan-codes" \
72  
73  #define slattach_trivial_usage \