Magellan Linux

Contents of /trunk/mkinitrd-magellan/busybox/console-tools/setkeycodes.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 816 - (show annotations) (download)
Fri Apr 24 18:33:46 2009 UTC (15 years ago) by niro
File MIME type: text/plain
File size: 1066 byte(s)
-updated to busybox-1.13.4
1 /* vi: set sw=4 ts=4: */
2 /*
3 * setkeycodes
4 *
5 * Copyright (C) 1994-1998 Andries E. Brouwer <aeb@cwi.nl>
6 *
7 * Adjusted for BusyBox by Erik Andersen <andersen@codepoet.org>
8 *
9 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
10 */
11
12 //#include <sys/ioctl.h>
13 #include "libbb.h"
14
15 /* From <linux/kd.h> */
16 struct kbkeycode {
17 unsigned scancode, keycode;
18 };
19 enum {
20 KDSETKEYCODE = 0x4B4D /* write kernel keycode table entry */
21 };
22
23 int setkeycodes_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
24 int setkeycodes_main(int argc, char **argv)
25 {
26 int fd, sc;
27 struct kbkeycode a;
28
29 if (!(argc & 1) /* if even */ || argc < 2) {
30 bb_show_usage();
31 }
32
33 fd = get_console_fd_or_die();
34
35 while (argc > 2) {
36 a.keycode = xatou_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;
41 }
42 ioctl_or_perror_and_die(fd, KDSETKEYCODE, &a,
43 "can't set SCANCODE %x to KEYCODE %d",
44 sc, a.keycode);
45 argc -= 2;
46 argv += 2;
47 }
48 return EXIT_SUCCESS;
49 }