[SLOF] [PATCH v2 2/2] Fix special keys on USB

Thomas Huth thuth at redhat.com
Fri Sep 11 23:19:27 AEST 2015


On 10/09/15 12:55, Dinar valeev wrote:
> From: Dinar Valeev <dvaleev at suse.com>
> 
> This patch fixing HOME, INS, END and DEL keys in Grub, when USB
> keyboard is used. Those keys are useful in faster grub interaction in
> automated tests.

I've checked these keys in three different terminals now: xterm, minicom
and urxvt...

> Signed-off-by: Dinar Valeev <dvaleev at suse.com>
> ---
>  lib/libusb/usb-hid.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/libusb/usb-hid.c b/lib/libusb/usb-hid.c
> index 5d1a4d4..a7fb0f5 100644
> --- a/lib/libusb/usb-hid.c
> +++ b/lib/libusb/usb-hid.c
> @@ -310,36 +310,34 @@ static void check_key_code(uint8_t *buf)
>  				case 0x49:
>  					write_key(0x1b);	       /* INS */
>  					write_key(0x5b);
> -					write_key(0x31);
> +					write_key(0x32);
>  					write_key(0x7e);
>  					break;

I get "1b 5b 32 7e" in xterm, minicom and urxvt, too, so that change
should be fine.

>  				case 0x4a:
>  					write_key(0x1b);	      /* HOME */
>  					write_key(0x5b);
> -					write_key(0x32);
> -					write_key(0x7e);
> +					write_key(0x48);
>  					break;

xterm: 1b 4f 48
minicom: 1b 5b 31 7e
urxvt: 1b 5b 37 7e

All look different to what you propose!
slof/fs/accept.fs can apparently handle "1b 5b 31 7e" and "1b 4f 48" ...
and if I get the GRUB sources right, it should also be able to deal with
"1b 4f 48", so I'd suggest to use that one instead.

>  				case 0x4b:
>  					write_key(0x1b);	      /* PgUp */
>  					write_key(0x5b);
> -					write_key(0x33);
> +					write_key(0x35);
>  					write_key(0x7e);
>  					break;

xterm, minicom and urxvt all use "35" instead of "33" here, too, so I
think this change is OK

>  				case 0x4c:
>  					write_key(0x1b);	       /* DEL */
>  					write_key(0x5b);
> -					write_key(0x34);
> +					write_key(0x33);
>  					write_key(0x7e);
>  					break;

xterm, minicom and urxvt all use "33" here, too, ==> OK

>  				case 0x4d:
>  					write_key(0x1b);	       /* END */
>  					write_key(0x5b);
> -					write_key(0x35);
> -					write_key(0x7e);
> +					write_key(0x46);
>  					break;

xterm and minicom: 1b 4f 46
urxvt: 1b 5b 38 7e

... so I'd suggest to use the xterm/minicom encoding here, too (i.e.
replace the 5b with 4f in your patch).

 Thomas



More information about the SLOF mailing list