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