source: MondoRescue/branches/2.2.9/mindi-busybox/console-tools/setkeycodes.c@ 2861

Last change on this file since 2861 was 2725, checked in by Bruno Cornec, 13 years ago
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
File size: 1010 bytes
RevLine 
[821]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 *
[2725]9 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
[821]10 */
[1765]11#include "libbb.h"
[821]12
13/* From <linux/kd.h> */
14struct kbkeycode {
[2725]15 unsigned scancode, keycode;
[821]16};
17enum {
18 KDSETKEYCODE = 0x4B4D /* write kernel keycode table entry */
19};
20
[2725]21int setkeycodes_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
22int setkeycodes_main(int argc, char **argv)
[821]23{
[2725]24 int fd;
[1765]25 struct kbkeycode a;
[821]26
[2725]27 if (!(argc & 1) /* if even */ || argc < 2) {
[1765]28 bb_show_usage();
[821]29 }
30
[2725]31 fd = get_console_fd_or_die();
[821]32
[2725]33 while (argv[1]) {
34 int sc = xstrtoul_range(argv[1], 16, 0, 0xe07f);
35 if (sc >= 0xe000) {
36 sc -= 0xe000;
37 sc += 0x0080;
[1765]38 }
[2725]39 a.scancode = sc;
40 a.keycode = xatou_range(argv[2], 0, 255);
[1765]41 ioctl_or_perror_and_die(fd, KDSETKEYCODE, &a,
[2725]42 "can't set SCANCODE %x to KEYCODE %d",
[1765]43 sc, a.keycode);
44 argv += 2;
[821]45 }
46 return EXIT_SUCCESS;
47}
Note: See TracBrowser for help on using the repository browser.