Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1123 - (hide annotations) (download)
Wed Aug 18 21:56:57 2010 UTC (13 years, 8 months ago) by niro
File MIME type: text/plain
File size: 1018 byte(s)
-updated to busybox-1.17.1
1 niro 532 /* 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 niro 816 #include "libbb.h"
12 niro 532
13     /* From <linux/kd.h> */
14     struct kbkeycode {
15 niro 816 unsigned scancode, keycode;
16 niro 532 };
17     enum {
18     KDSETKEYCODE = 0x4B4D /* write kernel keycode table entry */
19     };
20    
21 niro 816 int setkeycodes_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
22     int setkeycodes_main(int argc, char **argv)
23 niro 532 {
24 niro 1123 int fd;
25 niro 532 struct kbkeycode a;
26    
27 niro 816 if (!(argc & 1) /* if even */ || argc < 2) {
28 niro 532 bb_show_usage();
29     }
30    
31 niro 816 fd = get_console_fd_or_die();
32 niro 532
33 niro 1123 while (argv[1]) {
34     int sc = xstrtoul_range(argv[1], 16, 0, 0xe07f);
35     if (sc >= 0xe000) {
36     sc -= 0xe000;
37     sc += 0x0080;
38 niro 532 }
39 niro 1123 a.scancode = sc;
40     a.keycode = xatou_range(argv[2], 0, 255);
41 niro 816 ioctl_or_perror_and_die(fd, KDSETKEYCODE, &a,
42     "can't set SCANCODE %x to KEYCODE %d",
43     sc, a.keycode);
44 niro 532 argv += 2;
45     }
46     return EXIT_SUCCESS;
47     }