diff options
| author | Erik Andersen <andersen@codepoet.org> | 2000-04-28 01:26:31 +0000 |
|---|---|---|
| committer | Erik Andersen <andersen@codepoet.org> | 2000-04-28 01:26:31 +0000 |
| commit | abc199eb0cc485e42107595ca2d877c7724aced0 (patch) | |
| tree | 29d3292f7b8aa24d7e4df627cdc071961a8fb6b9 /setkeycodes.c | |
| parent | 4f3f757d56fbf420ea5030dcf7ea971b3da3ab47 (diff) | |
| download | busybox-w32-abc199eb0cc485e42107595ca2d877c7724aced0.tar.gz busybox-w32-abc199eb0cc485e42107595ca2d877c7724aced0.tar.bz2 busybox-w32-abc199eb0cc485e42107595ca2d877c7724aced0.zip | |
Forgot this file...
-Erik
Diffstat (limited to 'setkeycodes.c')
| -rw-r--r-- | setkeycodes.c | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/setkeycodes.c b/setkeycodes.c new file mode 100644 index 000000000..e933e14bc --- /dev/null +++ b/setkeycodes.c | |||
| @@ -0,0 +1,76 @@ | |||
| 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 <andersee@debian.org> | ||
| 8 | * | ||
| 9 | * This program is free software; you can redistribute it and/or modify | ||
| 10 | * it under the terms of the GNU General Public License as published by | ||
| 11 | * the Free Software Foundation; either version 2 of the License, or | ||
| 12 | * (at your option) any later version. | ||
| 13 | * | ||
| 14 | * This program is distributed in the hope that it will be useful, | ||
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 17 | * General Public License for more details. | ||
| 18 | * | ||
| 19 | * You should have received a copy of the GNU General Public License | ||
| 20 | * along with this program; if not, write to the Free Software | ||
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 22 | * | ||
| 23 | */ | ||
| 24 | |||
| 25 | #include "internal.h" | ||
| 26 | #include <stdio.h> | ||
| 27 | #include <stdlib.h> | ||
| 28 | #include <fcntl.h> | ||
| 29 | #include <sys/ioctl.h> | ||
| 30 | #include <linux/kd.h> | ||
| 31 | |||
| 32 | static const char setkeycodes_usage[] = | ||
| 33 | "setkeycodes SCANCODE KEYCODE ...\n" | ||
| 34 | #ifndef BB_FEATURE_TRIVIAL_HELP | ||
| 35 | "\nSet entries into the kernel's scancode-to-keycode map,\n" | ||
| 36 | "allowing unusual keyboards to generate usable keycodes.\n\n" | ||
| 37 | "SCANCODE may be either xx or e0xx (hexadecimal),\n" | ||
| 38 | "and KEYCODE is given in decimal\n" | ||
| 39 | #endif | ||
| 40 | ; | ||
| 41 | |||
| 42 | extern int | ||
| 43 | setkeycodes_main(int argc, char** argv) | ||
| 44 | { | ||
| 45 | char *ep; | ||
| 46 | int fd, sc; | ||
| 47 | struct kbkeycode a; | ||
| 48 | |||
| 49 | if (argc % 2 != 1 || argc < 2) { | ||
| 50 | usage(setkeycodes_usage); | ||
| 51 | } | ||
| 52 | |||
| 53 | fd = get_console_fd("/dev/console"); | ||
| 54 | |||
| 55 | while (argc > 2) { | ||
| 56 | a.keycode = atoi(argv[2]); | ||
| 57 | a.scancode = sc = strtol(argv[1], &ep, 16); | ||
| 58 | if (*ep) { | ||
| 59 | fatalError("error reading SCANCODE: '%s'\n", argv[1]); | ||
| 60 | } | ||
| 61 | if (a.scancode > 127) { | ||
| 62 | a.scancode -= 0xe000; | ||
| 63 | a.scancode += 128; | ||
| 64 | } | ||
| 65 | if (a.scancode > 255 || a.keycode > 127) { | ||
| 66 | fatalError("SCANCODE or KEYCODE outside bounds\n"); | ||
| 67 | } | ||
| 68 | if (ioctl(fd,KDSETKEYCODE,&a)) { | ||
| 69 | perror("KDSETKEYCODE"); | ||
| 70 | fatalError("failed to set SCANCODE %x to KEYCODE %d\n", sc, a.keycode); | ||
| 71 | } | ||
| 72 | argc -= 2; | ||
| 73 | argv += 2; | ||
| 74 | } | ||
| 75 | exit( TRUE); | ||
| 76 | } | ||
