[U-Boot] [PATCH 0/2] usb: kbd: implement special keys

GRUB uses function keys. So we should support these with an USB keyboard.
Provide support for F1-F12, Insert, Delete, Home, End, Page Up, Page Down.
Simplify the code beforehand.
Heinrich Schuchardt (2): usb: kbd: simplify coding for arrow keys usb: kbd: implement special keys
common/usb_kbd.c | 81 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 61 insertions(+), 20 deletions(-)
-- 2.20.1

Avoid duplicate translation of arrow key codes.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de --- common/usb_kbd.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-)
diff --git a/common/usb_kbd.c b/common/usb_kbd.c index cc99c6be07..232d278e13 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -74,15 +74,6 @@ static const unsigned char usb_kbd_num_keypad[] = { '.', 0, 0, 0, '=' };
-/* - * map arrow keys to ^F/^B ^N/^P, can't really use the proper - * ANSI sequence for arrow keys because the queuing code breaks - * when a single keypress expands to 3 queue elements - */ -static const unsigned char usb_kbd_arrow[] = { - 0x6, 0x2, 0xe, 0x10 -}; - /* * NOTE: It's important for the NUM, CAPS, SCROLL-lock bits to be in this * order. See usb_kbd_setled() function! @@ -213,10 +204,6 @@ static int usb_kbd_translate(struct usb_kbd_pdata *data, unsigned char scancode, keycode = usb_kbd_numkey[scancode - 0x1e]; }
- /* Arrow keys */ - if ((scancode >= 0x4f) && (scancode <= 0x52)) - keycode = usb_kbd_arrow[scancode - 0x4f]; - /* Numeric keypad */ if ((scancode >= 0x54) && (scancode <= 0x67)) keycode = usb_kbd_num_keypad[scancode - 0x54]; @@ -244,19 +231,19 @@ static int usb_kbd_translate(struct usb_kbd_pdata *data, unsigned char scancode, if (keycode) debug("%c", keycode);
- switch (keycode) { - case 0x0e: /* Down arrow key */ - usb_kbd_put_sequence(data, "\e[B"); - break; - case 0x10: /* Up arrow key */ - usb_kbd_put_sequence(data, "\e[A"); - break; - case 0x06: /* Right arrow key */ + switch (scancode) { + case 0x4f: /* Right arrow key */ usb_kbd_put_sequence(data, "\e[C"); break; - case 0x02: /* Left arrow key */ + case 0x50: /* Left arrow key */ usb_kbd_put_sequence(data, "\e[D"); break; + case 0x51: /* Down arrow key */ + usb_kbd_put_sequence(data, "\e[B"); + break; + case 0x52: /* Up arrow key */ + usb_kbd_put_sequence(data, "\e[A"); + break; default: usb_kbd_put_queue(data, keycode); break; -- 2.20.1

On Sun, 16 Jun 2019 at 22:44, Heinrich Schuchardt xypron.glpk@gmx.de wrote:
Avoid duplicate translation of arrow key codes.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
common/usb_kbd.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
We should really have a test for this input stuff...

On 6/24/19 3:56 PM, Simon Glass wrote:
On Sun, 16 Jun 2019 at 22:44, Heinrich Schuchardt xypron.glpk@gmx.de wrote:
Avoid duplicate translation of arrow key codes.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
common/usb_kbd.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
We should really have a test for this input stuff...
We already have.
For low level analysis:
=> conitrace Waiting for your input To terminate type 'x' 61 1b 5b 32 30 7e
For a higher level view:
=> setenv efi_selftest extended text input => bootefi selftest Executing 'extended text input' Waiting for your input To terminate type 'CTRL+x' Unicode char 100 ('d'), scan code 0 (Null) Unicode char 0 (Null), scan code 19 (+FN 9) Unicode char 0 (Null), scan code 19 (SHIFT+FN 9)
Regards
Heinrich

Hi Heinrich,
On Mon, 24 Jun 2019 at 11:36, Heinrich Schuchardt xypron.glpk@gmx.de wrote:
On 6/24/19 3:56 PM, Simon Glass wrote:
On Sun, 16 Jun 2019 at 22:44, Heinrich Schuchardt xypron.glpk@gmx.de wrote:
Avoid duplicate translation of arrow key codes.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
common/usb_kbd.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
We should really have a test for this input stuff...
We already have.
For low level analysis:
=> conitrace Waiting for your input To terminate type 'x' 61 1b 5b 32 30 7e
For a higher level view:
=> setenv efi_selftest extended text input => bootefi selftest Executing 'extended text input' Waiting for your input To terminate type 'CTRL+x' Unicode char 100 ('d'), scan code 0 (Null) Unicode char 0 (Null), scan code 19 (+FN 9) Unicode char 0 (Null), scan code 19 (SHIFT+FN 9)
I mean automated test :-)
Regards, Simon

On 6/24/19 8:49 PM, Simon Glass wrote:
Hi Heinrich,
On Mon, 24 Jun 2019 at 11:36, Heinrich Schuchardt xypron.glpk@gmx.de wrote:
On 6/24/19 3:56 PM, Simon Glass wrote:
On Sun, 16 Jun 2019 at 22:44, Heinrich Schuchardt xypron.glpk@gmx.de wrote:
Avoid duplicate translation of arrow key codes.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
common/usb_kbd.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
We should really have a test for this input stuff...
We already have.
For low level analysis:
=> conitrace Waiting for your input To terminate type 'x' 61 1b 5b 32 30 7e
For a higher level view:
=> setenv efi_selftest extended text input => bootefi selftest Executing 'extended text input' Waiting for your input To terminate type 'CTRL+x' Unicode char 100 ('d'), scan code 0 (Null) Unicode char 0 (Null), scan code 19 (+FN 9) Unicode char 0 (Null), scan code 19 (SHIFT+FN 9)
I mean automated test :-)
Regards, Simon
Hello Simon,
drivers/usb/emul/sandbox_keyb.c seems to bypass the driver in common/usb_keyb.c instead of emulating a USB keyboard.
Shouldn't it pass keyboard scan codes to common/usb_keyb.c?
Would you know how to get this fixed? Then I can add the additional keyboard scan codes.
Best regards
Heinrich

Hi Heinrich,
On Fri, 9 Aug 2019 at 15:36, Heinrich Schuchardt xypron.debian@gmx.de wrote:
On 6/24/19 8:49 PM, Simon Glass wrote:
Hi Heinrich,
On Mon, 24 Jun 2019 at 11:36, Heinrich Schuchardt xypron.glpk@gmx.de wrote:
On 6/24/19 3:56 PM, Simon Glass wrote:
On Sun, 16 Jun 2019 at 22:44, Heinrich Schuchardt xypron.glpk@gmx.de wrote:
Avoid duplicate translation of arrow key codes.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
common/usb_kbd.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
We should really have a test for this input stuff...
We already have.
For low level analysis:
=> conitrace Waiting for your input To terminate type 'x' 61 1b 5b 32 30 7e
For a higher level view:
=> setenv efi_selftest extended text input => bootefi selftest Executing 'extended text input' Waiting for your input To terminate type 'CTRL+x' Unicode char 100 ('d'), scan code 0 (Null) Unicode char 0 (Null), scan code 19 (+FN 9) Unicode char 0 (Null), scan code 19 (SHIFT+FN 9)
I mean automated test :-)
Regards, Simon
Hello Simon,
drivers/usb/emul/sandbox_keyb.c seems to bypass the driver in common/usb_keyb.c instead of emulating a USB keyboard.
Shouldn't it pass keyboard scan codes to common/usb_keyb.c?
Would you know how to get this fixed? Then I can add the additional keyboard scan codes.
Well it looks like you have figured this out.
Regards, Simon

Provide support for F1-F12, Insert, Delete, Home, End, Page Up, Page Down.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de --- common/usb_kbd.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+)
diff --git a/common/usb_kbd.c b/common/usb_kbd.c index 232d278e13..c9ac7a9e4c 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -232,6 +232,60 @@ static int usb_kbd_translate(struct usb_kbd_pdata *data, unsigned char scancode, debug("%c", keycode);
switch (scancode) { + case 0x3a: /* F1 */ + usb_kbd_put_sequence(data, "\eOP"); + break; + case 0x3b: /* F2 */ + usb_kbd_put_sequence(data, "\eOQ"); + break; + case 0x3c: /* F3 */ + usb_kbd_put_sequence(data, "\eOR"); + break; + case 0x3d: /* F4 */ + usb_kbd_put_sequence(data, "\eOS"); + break; + case 0x3e: /* F5 */ + usb_kbd_put_sequence(data, "\e[15~"); + break; + case 0x3f: /* F6 */ + usb_kbd_put_sequence(data, "\e[17~"); + break; + case 0x40: /* F7 */ + usb_kbd_put_sequence(data, "\e[18~"); + break; + case 0x41: /* F8 */ + usb_kbd_put_sequence(data, "\e[19~"); + break; + case 0x42: /* F9 */ + usb_kbd_put_sequence(data, "\e[20~"); + break; + case 0x43: /* F10 */ + usb_kbd_put_sequence(data, "\e[21~"); + break; + case 0x44: /* F11 */ + usb_kbd_put_sequence(data, "\e[23~"); + break; + case 0x45: /* F12 */ + usb_kbd_put_sequence(data, "\e[24~"); + break; + case 0x49: /* INSERT */ + usb_kbd_put_sequence(data, "\e[2~"); + break; + case 0x4a: /* HOME */ + usb_kbd_put_sequence(data, "\e[H"); + break; + case 0x4b: /* PAGE UP */ + usb_kbd_put_sequence(data, "\e[5~"); + break; + case 0x4c: /* DELETE */ + usb_kbd_put_sequence(data, "\e[3~"); + break; + case 0x4d: /* END */ + usb_kbd_put_sequence(data, "\e[F"); + break; + case 0x4e: /* PAGE DOWN */ + usb_kbd_put_sequence(data, "\e[6~"); + break; case 0x4f: /* Right arrow key */ usb_kbd_put_sequence(data, "\e[C"); break; -- 2.20.1
participants (3)
-
Heinrich Schuchardt
-
Heinrich Schuchardt
-
Simon Glass