[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: kbd_mode
From: "=?ISO-8859-1?Q?Lo=EFc_Greni=E9?=" <loic.grenie () gmail ! com>
Date: 2007-10-12 16:18:40
Message-ID: 9b06e8d20710120918u5c04b54fv5d1908722ca78dc7 () mail ! gmail ! com
[Download RAW message or body]
2007/10/12, Bernhard Fischer <rep.dot.nop@gmail.com>:
> On Thu, Oct 11, 2007 at 09:49:42PM +0200, Lo=EFc Greni=E9 wrote:
> > This patch to add a kbd_mode applet.
>
> You forgot to actually attach it..
Sorry...
Lo=EFc
["kbd_mode.diff" (text/x-diff)]
Index: console-tools/Config.in
===================================================================
--- console-tools/Config.in (revision 20224)
+++ console-tools/Config.in (working copy)
@@ -31,6 +31,12 @@
This program dumps the kernel's keyboard translation table to
stdout, in binary format. You can then use loadkmap to load it.
+config KBD_MODE
+ bool "kbd_mode"
+ default n
+ help
+ This program reports and sets keyboard mode.
+
config LOADFONT
bool "loadfont"
default n
Index: console-tools/Kbuild
===================================================================
--- console-tools/Kbuild (revision 20224)
+++ console-tools/Kbuild (working copy)
@@ -10,6 +10,7 @@
lib-$(CONFIG_DEALLOCVT) += deallocvt.o
lib-$(CONFIG_DUMPKMAP) += dumpkmap.o
lib-$(CONFIG_SETCONSOLE) += setconsole.o
+lib-$(CONFIG_KBD_MODE) += kbd_mode.o
lib-$(CONFIG_LOADFONT) += loadfont.o
lib-$(CONFIG_LOADKMAP) += loadkmap.o
lib-$(CONFIG_OPENVT) += openvt.o
Index: include/usage.h
===================================================================
--- include/usage.h (revision 20224)
+++ include/usage.h (working copy)
@@ -1728,6 +1728,16 @@
" [[i|o]seq] [[i|o]key KEY] [[i|o]csum]\n" \
" [ttl TTL] [tos TOS] [[no]pmtudisc] [dev PHYS_DEV]"
+#define kbd_mode_trivial_usage \
+ "[-a|k|s|u]"
+#define kbd_mode_full_usage \
+ "Set or report the keyboard mode" \
+ "\n\nOptions:\n" \
+ " -a Set keyboard in default (ASCII) mode\n" \
+ " -k Set keyboard in mediumraw (keyboard) mode\n" \
+ " -s Set keyboard in raw (scancode) mode\n" \
+ " -u Set keyboard in unicode (utf-8) mode"
+
#define kill_trivial_usage \
"[-l] [-signal] process-id [process-id ...]"
#define kill_full_usage \
Index: include/applets.h
===================================================================
--- include/applets.h (revision 20224)
+++ include/applets.h (working copy)
@@ -201,6 +201,7 @@
USE_IPROUTE(APPLET(iproute, _BB_DIR_BIN, _BB_SUID_NEVER))
USE_IPRULE(APPLET(iprule, _BB_DIR_BIN, _BB_SUID_NEVER))
USE_IPTUNNEL(APPLET(iptunnel, _BB_DIR_BIN, _BB_SUID_NEVER))
+USE_KBD_MODE(APPLET(kbd_mode, __BB_DIR_USR_BIN, _BB_SUID_NEVER))
USE_KILL(APPLET(kill, _BB_DIR_BIN, _BB_SUID_NEVER))
USE_KILLALL(APPLET_ODDNAME(killall, kill, _BB_DIR_USR_BIN, _BB_SUID_NEVER, killall))
USE_KILLALL5(APPLET_ODDNAME(killall5, kill, _BB_DIR_USR_BIN, _BB_SUID_NEVER, killall5))
--- /dev/null 2007-10-12 09:43:29.342622800 +0200
+++ console-tools/kbd_mode.c 2007-10-11 21:36:59.000000000 +0200
@@ -0,0 +1,65 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Mini loadkmap implementation for busybox
+ *
+ * Copyright (C) 2007 Loïc Grenié <loic.grenie@gmail.com>
+ * written using Andries Brouwer <aeb@cwi.nl>'s kbd_mode from
+ * console-utils v0.2.3, licensed under GNU GPLv2
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ *
+ */
+
+#include <getopt.h>
+#include "libbb.h"
+#include <linux/kd.h>
+
+int kbd_mode_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int kbd_mode_main(int argc, char **argv)
+{
+ const char *opts = "saku", *opt = argv[1], *p;
+ int fd;
+
+ fd = get_console_fd();
+
+ if (opt == NULL) {
+ /* No arg */
+ const char *msg;
+ int mode;
+
+ ioctl(fd, KDGKBMODE, &mode);
+ switch(mode) {
+ case K_RAW:
+ msg = "raw (scancode)";
+ break;
+ case K_XLATE:
+ msg = "the default (ASCII)";
+ break;
+ case K_MEDIUMRAW:
+ msg = "mediumraw (keycode)";
+ break;
+ case K_UNICODE:
+ msg = "Unicode (UTF-8)";
+ break;
+ default:
+ msg = "some unknown";
+ break;
+ }
+ printf("The keyboard is in %s mode\n", msg);
+ }
+ else if (argc > 2 || *opt != '-' || (p = strchr(opts, opt[1])) == NULL ||
+ opt[2] != '\0') {
+ bb_show_usage();
+ return EXIT_FAILURE;
+ }
+ else {
+#if K_RAW != 0 || K_XLATE != 1 || K_MEDIUMRAW != 2 || K_UNICODE != 3
+#error "kbd_mode must be changed."
+#endif
+ /* The options are in the order of the various K_xxx */
+ ioctl(fd, KDSKBMODE, p - opts);
+ }
+
+ if (ENABLE_FEATURE_CLEAN_UP) close(fd);
+ return EXIT_SUCCESS;
+}
_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic