mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-10 23:24:38 +00:00
usb: kbd: Properly translate up/down arrow keys
So far arrows key pressed on an USB keyboard got translated to some low ASCII control sequences (Ctrl+N, Ctrl+P). Some programs understand these codes, but the standard for those keys is to use ANSI control sequences for cursor movement (ESC [ A). Our own boot menu is a victim of this, currently we cannot change the selection with an USB keyboard due to this. Since we already implement a queue for USB key codes, we can just insert the three character ANSI sequence into the key buffer. This fixes the bootmenu, and is more universal for other users (UEFI) as well. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
7035ec3cb3
commit
c99ffd72ab
1 changed files with 23 additions and 1 deletions
|
@ -145,6 +145,12 @@ static void usb_kbd_put_queue(struct usb_kbd_pdata *data, char c)
|
|||
data->usb_kbd_buffer[data->usb_in_pointer] = c;
|
||||
}
|
||||
|
||||
static void usb_kbd_put_sequence(struct usb_kbd_pdata *data, char *s)
|
||||
{
|
||||
for (; *s; s++)
|
||||
usb_kbd_put_queue(data, *s);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the LEDs. Since this is used in the irq routine, the control job is
|
||||
* issued with a timeout of 0. This means, that the job is queued without
|
||||
|
@ -235,9 +241,25 @@ static int usb_kbd_translate(struct usb_kbd_pdata *data, unsigned char scancode,
|
|||
}
|
||||
|
||||
/* Report keycode if any */
|
||||
if (keycode) {
|
||||
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 */
|
||||
usb_kbd_put_sequence(data, "\e[C");
|
||||
break;
|
||||
case 0x02: /* Left arrow key */
|
||||
usb_kbd_put_sequence(data, "\e[D");
|
||||
break;
|
||||
default:
|
||||
usb_kbd_put_queue(data, keycode);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue