All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/2] usb: kbd: implement special keys
@ 2019-06-16 21:43 Heinrich Schuchardt
  2019-06-16 21:43 ` [U-Boot] [PATCH 1/2] usb: kbd: simplify coding for arrow keys Heinrich Schuchardt
  2019-06-16 21:43 ` [U-Boot] [PATCH 2/2] usb: kbd: implement special keys Heinrich Schuchardt
  0 siblings, 2 replies; 8+ messages in thread
From: Heinrich Schuchardt @ 2019-06-16 21:43 UTC (permalink / raw)
  To: u-boot

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/2] usb: kbd: simplify coding for arrow keys
  2019-06-16 21:43 [U-Boot] [PATCH 0/2] usb: kbd: implement special keys Heinrich Schuchardt
@ 2019-06-16 21:43 ` Heinrich Schuchardt
  2019-06-24 13:56   ` Simon Glass
  2019-06-16 21:43 ` [U-Boot] [PATCH 2/2] usb: kbd: implement special keys Heinrich Schuchardt
  1 sibling, 1 reply; 8+ messages in thread
From: Heinrich Schuchardt @ 2019-06-16 21:43 UTC (permalink / raw)
  To: u-boot

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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 2/2] usb: kbd: implement special keys
  2019-06-16 21:43 [U-Boot] [PATCH 0/2] usb: kbd: implement special keys Heinrich Schuchardt
  2019-06-16 21:43 ` [U-Boot] [PATCH 1/2] usb: kbd: simplify coding for arrow keys Heinrich Schuchardt
@ 2019-06-16 21:43 ` Heinrich Schuchardt
  1 sibling, 0 replies; 8+ messages in thread
From: Heinrich Schuchardt @ 2019-06-16 21:43 UTC (permalink / raw)
  To: u-boot

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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/2] usb: kbd: simplify coding for arrow keys
  2019-06-16 21:43 ` [U-Boot] [PATCH 1/2] usb: kbd: simplify coding for arrow keys Heinrich Schuchardt
@ 2019-06-24 13:56   ` Simon Glass
  2019-06-24 17:36     ` Heinrich Schuchardt
  0 siblings, 1 reply; 8+ messages in thread
From: Simon Glass @ 2019-06-24 13:56 UTC (permalink / raw)
  To: u-boot

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...

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/2] usb: kbd: simplify coding for arrow keys
  2019-06-24 13:56   ` Simon Glass
@ 2019-06-24 17:36     ` Heinrich Schuchardt
  2019-06-24 18:49       ` Simon Glass
  0 siblings, 1 reply; 8+ messages in thread
From: Heinrich Schuchardt @ 2019-06-24 17:36 UTC (permalink / raw)
  To: u-boot

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/2] usb: kbd: simplify coding for arrow keys
  2019-06-24 17:36     ` Heinrich Schuchardt
@ 2019-06-24 18:49       ` Simon Glass
  2019-08-09 21:36         ` Heinrich Schuchardt
  0 siblings, 1 reply; 8+ messages in thread
From: Simon Glass @ 2019-06-24 18:49 UTC (permalink / raw)
  To: u-boot

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/2] usb: kbd: simplify coding for arrow keys
  2019-06-24 18:49       ` Simon Glass
@ 2019-08-09 21:36         ` Heinrich Schuchardt
  2019-08-13  9:34           ` Simon Glass
  0 siblings, 1 reply; 8+ messages in thread
From: Heinrich Schuchardt @ 2019-08-09 21:36 UTC (permalink / raw)
  To: u-boot

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/2] usb: kbd: simplify coding for arrow keys
  2019-08-09 21:36         ` Heinrich Schuchardt
@ 2019-08-13  9:34           ` Simon Glass
  0 siblings, 0 replies; 8+ messages in thread
From: Simon Glass @ 2019-08-13  9:34 UTC (permalink / raw)
  To: u-boot

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-08-13  9:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-16 21:43 [U-Boot] [PATCH 0/2] usb: kbd: implement special keys Heinrich Schuchardt
2019-06-16 21:43 ` [U-Boot] [PATCH 1/2] usb: kbd: simplify coding for arrow keys Heinrich Schuchardt
2019-06-24 13:56   ` Simon Glass
2019-06-24 17:36     ` Heinrich Schuchardt
2019-06-24 18:49       ` Simon Glass
2019-08-09 21:36         ` Heinrich Schuchardt
2019-08-13  9:34           ` Simon Glass
2019-06-16 21:43 ` [U-Boot] [PATCH 2/2] usb: kbd: implement special keys Heinrich Schuchardt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.