Line | |
---|
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 |
|
---|
12 | //#include <sys/ioctl.h>
|
---|
13 | #include "libbb.h"
|
---|
14 |
|
---|
15 | /* From <linux/kd.h> */
|
---|
16 | struct kbkeycode {
|
---|
17 | unsigned int scancode, keycode;
|
---|
18 | };
|
---|
19 | enum {
|
---|
20 | KDSETKEYCODE = 0x4B4D /* write kernel keycode table entry */
|
---|
21 | };
|
---|
22 |
|
---|
23 | int setkeycodes_main(int argc, char** argv);
|
---|
24 | int setkeycodes_main(int argc, char** argv)
|
---|
25 | {
|
---|
26 | int fd, sc;
|
---|
27 | struct kbkeycode a;
|
---|
28 |
|
---|
29 | if (argc % 2 != 1 || argc < 2) {
|
---|
30 | bb_show_usage();
|
---|
31 | }
|
---|
32 |
|
---|
33 | fd = get_console_fd();
|
---|
34 |
|
---|
35 | while (argc > 2) {
|
---|
36 | a.keycode = xatoul_range(argv[2], 0, 127);
|
---|
37 | a.scancode = sc = xstrtoul_range(argv[1], 16, 0, 255);
|
---|
38 | if (a.scancode > 127) {
|
---|
39 | a.scancode -= 0xe000;
|
---|
40 | a.scancode += 128;
|
---|
41 | }
|
---|
42 | ioctl_or_perror_and_die(fd, KDSETKEYCODE, &a,
|
---|
43 | "failed to set SCANCODE %x to KEYCODE %d",
|
---|
44 | sc, a.keycode);
|
---|
45 | argc -= 2;
|
---|
46 | argv += 2;
|
---|
47 | }
|
---|
48 | return EXIT_SUCCESS;
|
---|
49 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.