]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
usb: add numeric keypad support to HID driver
authorVincent Palatin <vpalatin@chromium.org>
Mon, 9 Jan 2012 12:59:36 +0000 (12:59 +0000)
committerWolfgang Denk <wd@denx.de>
Sat, 3 Mar 2012 15:56:15 +0000 (16:56 +0100)
When keys are pressed on the numeric keypad, emit key codes for the numbers,
operators, dot and enter.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
common/usb_kbd.c

index aaf7d6fa3dab9f1a8a11c42b3d213ecfd172596f..2472d25d4a9bc33b3f9e21724000eaaf0549c71e 100644 (file)
@@ -87,6 +87,12 @@ static const unsigned char usb_kbd_numkey_shifted[] = {
        '|', '~', ':', '"', '~', '<', '>', '?'
 };
 
+static const unsigned char usb_kbd_num_keypad[] = {
+       '/', '*', '-', '+', '\r',
+       '1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
+       '.', 0, 0, 0, '='
+};
+
 /*
  * NOTE: It's important for the NUM, CAPS, SCROLL-lock bits to be in this
  *       order. See usb_kbd_setled() function!
@@ -218,6 +224,10 @@ static int usb_kbd_translate(struct usb_kbd_pdata *data, unsigned char scancode,
                        keycode = usb_kbd_numkey[scancode - 0x1e];
        }
 
+       /* Numeric keypad */
+       if ((scancode >= 0x54) && (scancode <= 0x67))
+               keycode = usb_kbd_num_keypad[scancode - 0x54];
+
        if (data->flags & USB_KBD_CTRL)
                keycode = scancode - 0x3;