usb: add numeric keypad support to HID driver
PATCH 1/1 usb: add numeric keypad support to HID driver
When keys are pressed on the numeric keypad, emit key codes for the numbers, operators, dot and enter.
--- common/usb_kbd.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
common/usb_kbd.c +10 -0
@@ -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 ;
Signature · 1 line
1.7.3.1
PATCH 1/1 usb: add numeric keypad support to HID driver
Quoted 26 lines
When keys are pressed on the numeric keypad, emit key codes for the numbers, operators, dot and enter.
Signed-off-by Vincent Palatin <[email protected]>--- common/usb_kbd.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)common/usb_kbd.c +6
-0@@ -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!
common/usb_kbd.c static int usb_kbd_translate(struct usb_kbd_pdata · line 232
Quoted 9 lines
common/usb_kbd.c +4
-0@@ -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 ;
This is good, but what happens if you press "Ctrl + numpad_key" ? Check line 221 in usb_kbd.c for what I mean.
M
PATCH 1/1 usb: add numeric keypad support to HID driver
Quoted 9 lines · Marek Vasut
Quoted 6 lines
+ ? ? /* Numeric keypad */
+ ? ? if ((scancode >=0x54) && (scancode <=0x67))
+ ? ? ? ? ? ? keycode = usb_kbd_num_keypad[scancode -0x54]; +
? ? ? if (data->flags&USB_KBD_CTRL)
? ? ? ? ? ? ? keycode = scancode -0x3;This is good, but what happens if you press "Ctrl +
numpad_key" ? Check line 221 inusb_kbd.cfor what I mean.
As before the patch, it returns some random uppercase letters. This is broken : IMO not only for those keys, but for all keys excepted A-Z.
Signature · 1 line
Vincent
PATCH 1/1 usb: add numeric keypad support to HID driver
In reply to Vincent PalatinHi,
2012/1/9 Vincent Palatin <[email protected]>:
Quoted 7 lines
When keys are pressed on the numeric keypad, emit key codes for the numbers, operators, dot and enter.
Signed-off-by Vincent Palatin <[email protected]>---
?common/usb_kbd.c | ? 10 ++++++++++
?1 files changed, 10 insertions(+), 0 deletions(-)
Applied to u-boot-usb. Thanks.
Kind regards,
Remy
PATCH 1/1 usb: add numeric keypad support to HID driver
In reply to Vincent PalatinQuoted 5 lines
When keys are pressed on the numeric keypad, emit key codes for the numbers, operators, dot and enter.
Signed-off-by Vincent Palatin <[email protected]>---
Hi,
what's the status of this patch/patchset?
Thanks
M