1 /* vi: set sw=4 ts=4: */
5 * Copyright (C) 1994-1998 Andries E. Brouwer <aeb@cwi.nl>
7 * Adjusted for BusyBox by Erik Andersen <andersen@codepoet.org>
9 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
15 #include <sys/ioctl.h>
19 /* From <linux/kd.h> */
21 unsigned int scancode, keycode;
24 KDSETKEYCODE = 0x4B4D /* write kernel keycode table entry */
28 setkeycodes_main(int argc, char** argv)
34 if (argc % 2 != 1 || argc < 2) {
38 fd = get_console_fd();
41 a.keycode = atoi(argv[2]);
42 a.scancode = sc = strtol(argv[1], &ep, 16);
44 bb_error_msg_and_die("error reading SCANCODE: '%s'", argv[1]);
46 if (a.scancode > 127) {
50 if (a.scancode > 255 || a.keycode > 127) {
51 bb_error_msg_and_die("SCANCODE or KEYCODE outside bounds");
53 if (ioctl(fd,KDSETKEYCODE,&a)) {
54 perror("KDSETKEYCODE");
55 bb_error_msg_and_die("failed to set SCANCODE %x to KEYCODE %d", sc, a.keycode);