Changeset 2725 in MondoRescue for branches/2.2.9/mindi-busybox/console-tools/setkeycodes.c
- Timestamp:
- Feb 25, 2011, 9:26:54 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mindi-busybox/console-tools/setkeycodes.c
r1765 r2725 7 7 * Adjusted for BusyBox by Erik Andersen <andersen@codepoet.org> 8 8 * 9 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.9 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 10 10 */ 11 12 //#include <sys/ioctl.h>13 11 #include "libbb.h" 14 12 15 13 /* From <linux/kd.h> */ 16 14 struct kbkeycode { 17 unsigned intscancode, keycode;15 unsigned scancode, keycode; 18 16 }; 19 17 enum { … … 21 19 }; 22 20 23 int setkeycodes_main(int argc, char ** argv);24 int setkeycodes_main(int argc, char **argv)21 int setkeycodes_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 22 int setkeycodes_main(int argc, char **argv) 25 23 { 26 int fd , sc;24 int fd; 27 25 struct kbkeycode a; 28 26 29 if ( argc % 2 != 1|| argc < 2) {27 if (!(argc & 1) /* if even */ || argc < 2) { 30 28 bb_show_usage(); 31 29 } 32 30 33 fd = get_console_fd ();31 fd = get_console_fd_or_die(); 34 32 35 while (argc > 2) { 36 a.keycode = xatoul_range(argv[2], 0, 127); 37 a.scancode = sc = xstrtoul_range(argv[1], 16, 0, 255); 38 if (a.scancode > 127) { 39 a.scancode -= 0xe000; 40 a.scancode += 128; 33 while (argv[1]) { 34 int sc = xstrtoul_range(argv[1], 16, 0, 0xe07f); 35 if (sc >= 0xe000) { 36 sc -= 0xe000; 37 sc += 0x0080; 41 38 } 39 a.scancode = sc; 40 a.keycode = xatou_range(argv[2], 0, 255); 42 41 ioctl_or_perror_and_die(fd, KDSETKEYCODE, &a, 43 " failed toset SCANCODE %x to KEYCODE %d",42 "can't set SCANCODE %x to KEYCODE %d", 44 43 sc, a.keycode); 45 argc -= 2;46 44 argv += 2; 47 45 }
Note:
See TracChangeset
for help on using the changeset viewer.