[U-Boot] [PATCH] common:usb_kbd:Add key values of F1~F12

Leo Wen leo.wen at rock-chips.com
Tue Aug 8 01:27:46 UTC 2017


When you press the F1~F12 button from the USB keyboard, the reference Fn
key table(usb_kbd_fn_key[]),the key value(0xf0~0xfb) will be returned,
and you can use it to do more things.

Signed-off-by: Leo Wen <leo.wen at rock-chips.com>
---
 common/usb_kbd.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index d2d29cc..7c96c78 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -73,6 +73,10 @@ static const unsigned char usb_kbd_num_keypad[] = {
 	'1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
 	'.', 0, 0, 0, '='
 };
+static const unsigned char usb_kbd_fn_key[] = {
+	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5,
+	0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb
+};
 
 /*
  * map arrow keys to ^F/^B ^N/^P, can't really use the proper
@@ -206,6 +210,9 @@ static int usb_kbd_translate(struct usb_kbd_pdata *data, unsigned char scancode,
 		else
 			keycode = usb_kbd_numkey[scancode - 0x1e];
 	}
+	/* Fn keys pressed */
+	if ((scancode >= 0x3a) && (scancode <= 0x45))
+		keycode = usb_kbd_fn_key[scancode - 0x3a];
 
 	/* Arrow keys */
 	if ((scancode >= 0x4f) && (scancode <= 0x52))
-- 
2.7.4




More information about the U-Boot mailing list