1 /* vi: set sw=4 ts=4: */
3 * Mini loadkmap implementation for busybox
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
9 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
16 int kbd_mode_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
17 int kbd_mode_main(int argc, char **argv)
19 static const char opts[] = "saku";
21 const char *opt = argv[1];
25 fd = get_console_fd();
26 if (fd < 0) /* get_console_fd() already complained */
31 const char *msg = "unknown";
34 ioctl(fd, KDGKBMODE, &mode);
37 msg = "raw (scancode)";
40 msg = "default (ASCII)";
43 msg = "mediumraw (keycode)";
46 msg = "Unicode (UTF-8)";
49 printf("The keyboard is in %s mode\n", msg);
51 else if (argc > 2 /* more than 1 arg */
52 || *opt != '-' /* not an option */
53 || (p = strchr(opts, opt[1])) == NULL /* not an option we expect */
54 || opt[2] != '\0' /* more than one option char */
57 /* return EXIT_FAILURE; - not reached */
60 #if K_RAW != 0 || K_XLATE != 1 || K_MEDIUMRAW != 2 || K_UNICODE != 3
61 #error kbd_mode must be changed
63 /* The options are in the order of the various K_xxx */
64 ioctl(fd, KDSKBMODE, p - opts);
67 if (ENABLE_FEATURE_CLEAN_UP)