aboutsummaryrefslogtreecommitdiff
path: root/console-tools
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-10-20 00:17:34 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-10-20 00:17:34 +0000
commitaa7a888e423fc85daa8af0ac3aabe8fc7af86312 (patch)
tree9eb65800fef6933a416ee2bc3a57610bbc205136 /console-tools
parent85ff862753be5b7b5d3855681f9234c131659b8a (diff)
downloadbusybox-w32-aa7a888e423fc85daa8af0ac3aabe8fc7af86312.tar.gz
busybox-w32-aa7a888e423fc85daa8af0ac3aabe8fc7af86312.tar.bz2
busybox-w32-aa7a888e423fc85daa8af0ac3aabe8fc7af86312.zip
kbd_mode: new applet by Loïc Grenié <loic.grenie@gmail.com>
kbd_mode_main - 189 +189 packed_usage 22745 22833 +88 applets 3132 3144 +12 static.opts 7 12 +5 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 3/0 up/down: 294/0) Total: 294 bytes text data bss dec hex filename 777210 1000 9532 787742 c051e busybox_old 777575 1000 9532 788107 c068b busybox_unstripped
Diffstat (limited to 'console-tools')
-rw-r--r--console-tools/Config.in6
-rw-r--r--console-tools/Kbuild1
-rw-r--r--console-tools/kbd_mode.c71
3 files changed, 78 insertions, 0 deletions
diff --git a/console-tools/Config.in b/console-tools/Config.in
index f82d4ce13..bd9dfb381 100644
--- a/console-tools/Config.in
+++ b/console-tools/Config.in
@@ -31,6 +31,12 @@ config DUMPKMAP
31 This program dumps the kernel's keyboard translation table to 31 This program dumps the kernel's keyboard translation table to
32 stdout, in binary format. You can then use loadkmap to load it. 32 stdout, in binary format. You can then use loadkmap to load it.
33 33
34config KBD_MODE
35 bool "kbd_mode"
36 default n
37 help
38 This program reports and sets keyboard mode.
39
34config LOADFONT 40config LOADFONT
35 bool "loadfont" 41 bool "loadfont"
36 default n 42 default n
diff --git a/console-tools/Kbuild b/console-tools/Kbuild
index a55bc087c..cf3825ec6 100644
--- a/console-tools/Kbuild
+++ b/console-tools/Kbuild
@@ -10,6 +10,7 @@ lib-$(CONFIG_CLEAR) += clear.o
10lib-$(CONFIG_DEALLOCVT) += deallocvt.o 10lib-$(CONFIG_DEALLOCVT) += deallocvt.o
11lib-$(CONFIG_DUMPKMAP) += dumpkmap.o 11lib-$(CONFIG_DUMPKMAP) += dumpkmap.o
12lib-$(CONFIG_SETCONSOLE) += setconsole.o 12lib-$(CONFIG_SETCONSOLE) += setconsole.o
13lib-$(CONFIG_KBD_MODE) += kbd_mode.o
13lib-$(CONFIG_LOADFONT) += loadfont.o 14lib-$(CONFIG_LOADFONT) += loadfont.o
14lib-$(CONFIG_LOADKMAP) += loadkmap.o 15lib-$(CONFIG_LOADKMAP) += loadkmap.o
15lib-$(CONFIG_OPENVT) += openvt.o 16lib-$(CONFIG_OPENVT) += openvt.o
diff --git a/console-tools/kbd_mode.c b/console-tools/kbd_mode.c
new file mode 100644
index 000000000..0000ea180
--- /dev/null
+++ b/console-tools/kbd_mode.c
@@ -0,0 +1,71 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Mini loadkmap implementation for busybox
4 *
5 * Copyright (C) 2007 Loïc Grenié <loic.grenie@gmail.com>
6 * written using Andries Brouwer <aeb@cwi.nl>'s kbd_mode from
7 * console-utils v0.2.3, licensed under GNU GPLv2
8 *
9 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
10 *
11 */
12
13#include <getopt.h>
14#include "libbb.h"
15#include <linux/kd.h>
16
17int kbd_mode_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
18int kbd_mode_main(int argc, char **argv)
19{
20 static const char opts[] = "saku";
21
22 const char *opt = argv[1];
23 const char *p;
24 int fd;
25
26 fd = get_console_fd();
27 if (fd < 0) /* get_console_fd() already complained */
28 return EXIT_FAILURE;
29
30 if (opt == NULL) {
31 /* No arg */
32 const char *msg = "unknown";
33 int mode;
34
35 ioctl(fd, KDGKBMODE, &mode);
36 switch(mode) {
37 case K_RAW:
38 msg = "raw (scancode)";
39 break;
40 case K_XLATE:
41 msg = "default (ASCII)";
42 break;
43 case K_MEDIUMRAW:
44 msg = "mediumraw (keycode)";
45 break;
46 case K_UNICODE:
47 msg = "Unicode (UTF-8)";
48 break;
49 }
50 printf("The keyboard is in %s mode\n", msg);
51 }
52 else if (argc > 2 /* more than 1 arg */
53 || *opt != '-' /* not an option */
54 || (p = strchr(opts, opt[1])) == NULL /* not an option we expect */
55 || opt[2] != '\0' /* more than one option char */
56 ) {
57 bb_show_usage();
58 /* return EXIT_FAILURE; - not reached */
59 }
60 else {
61#if K_RAW != 0 || K_XLATE != 1 || K_MEDIUMRAW != 2 || K_UNICODE != 3
62#error kbd_mode must be changed
63#endif
64 /* The options are in the order of the various K_xxx */
65 ioctl(fd, KDSKBMODE, p - opts);
66 }
67
68 if (ENABLE_FEATURE_CLEAN_UP)
69 close(fd);
70 return EXIT_SUCCESS;
71}