Magellan Linux

Diff of /trunk/mkinitrd-magellan/busybox/console-tools/setkeycodes.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 815 by niro, Sat Sep 1 22:45:15 2007 UTC revision 816 by niro, Fri Apr 24 18:33:46 2009 UTC
# Line 9  Line 9 
9   * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.   * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
10   */   */
11    
12  #include <stdio.h>  //#include <sys/ioctl.h>
13  #include <stdlib.h>  #include "libbb.h"
 #include <fcntl.h>  
 #include <sys/ioctl.h>  
 #include "busybox.h"  
   
14    
15  /* From <linux/kd.h> */  /* From <linux/kd.h> */
16  struct kbkeycode {  struct kbkeycode {
17   unsigned int scancode, keycode;   unsigned scancode, keycode;
18  };  };
19  enum {  enum {
20   KDSETKEYCODE = 0x4B4D  /* write kernel keycode table entry */   KDSETKEYCODE = 0x4B4D  /* write kernel keycode table entry */
21  };  };
22    
23  extern int  int setkeycodes_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
24  setkeycodes_main(int argc, char** argv)  int setkeycodes_main(int argc, char **argv)
25  {  {
26   int fd, sc;   int fd, sc;
27   struct kbkeycode a;   struct kbkeycode a;
28    
29   if (argc % 2 != 1 || argc < 2) {   if (!(argc & 1) /* if even */ || argc < 2) {
30   bb_show_usage();   bb_show_usage();
31   }   }
32    
33   fd = get_console_fd();   fd = get_console_fd_or_die();
34    
35   while (argc > 2) {   while (argc > 2) {
36   a.keycode = xatoul_range(argv[2], 0, 127);   a.keycode = xatou_range(argv[2], 0, 127);
37   a.scancode = sc = xstrtoul_range(argv[1], 16, 0, 255);   a.scancode = sc = xstrtoul_range(argv[1], 16, 0, 255);
38   if (a.scancode > 127) {   if (a.scancode > 127) {
39   a.scancode -= 0xe000;   a.scancode -= 0xe000;
40   a.scancode += 128;   a.scancode += 128;
41   }   }
42   if (ioctl(fd, KDSETKEYCODE, &a)) {   ioctl_or_perror_and_die(fd, KDSETKEYCODE, &a,
43   bb_perror_msg_and_die("failed to set SCANCODE %x to KEYCODE %d", sc, a.keycode);   "can't set SCANCODE %x to KEYCODE %d",
44   }   sc, a.keycode);
45   argc -= 2;   argc -= 2;
46   argv += 2;   argv += 2;
47   }   }

Legend:
Removed from v.815  
changed lines
  Added in v.816