* [U-Boot] [PATCH v2 0/5] usb: kbd: implement special keys
@ 2019-08-10 9:24 Heinrich Schuchardt
2019-08-10 9:24 ` [U-Boot] [PATCH v2 1/5] usb: kbd: simplify coding for arrow keys Heinrich Schuchardt
` (5 more replies)
0 siblings, 6 replies; 12+ messages in thread
From: Heinrich Schuchardt @ 2019-08-10 9:24 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.
Enhance the keyboard unit test.
v2:
enhance the keyboard unit test
Heinrich Schuchardt (5):
usb: kbd: simplify coding for arrow keys
usb: kbd: implement special keys
usb: kbd: fix typo
usb: kbd: move USB_KBD_BOOT_REPORT_SIZE to usb.h
dm: test: usb: rework keyboard test
common/usb_kbd.c | 89 +++++++---
drivers/usb/emul/sandbox_keyb.c | 27 +--
include/usb.h | 6 +
test/dm/usb.c | 285 +++++++++++++++++++++++++++++++-
4 files changed, 361 insertions(+), 46 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH v2 1/5] usb: kbd: simplify coding for arrow keys
2019-08-10 9:24 [U-Boot] [PATCH v2 0/5] usb: kbd: implement special keys Heinrich Schuchardt
@ 2019-08-10 9:24 ` Heinrich Schuchardt
2019-08-10 9:24 ` [U-Boot] [PATCH v2 2/5] usb: kbd: implement special keys Heinrich Schuchardt
` (4 subsequent siblings)
5 siblings, 0 replies; 12+ messages in thread
From: Heinrich Schuchardt @ 2019-08-10 9:24 UTC (permalink / raw)
To: u-boot
Avoid duplicate translation of arrow key codes.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
v2
no change
---
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] 12+ messages in thread
* [U-Boot] [PATCH v2 2/5] usb: kbd: implement special keys
2019-08-10 9:24 [U-Boot] [PATCH v2 0/5] usb: kbd: implement special keys Heinrich Schuchardt
2019-08-10 9:24 ` [U-Boot] [PATCH v2 1/5] usb: kbd: simplify coding for arrow keys Heinrich Schuchardt
@ 2019-08-10 9:24 ` Heinrich Schuchardt
2019-08-10 9:24 ` [U-Boot] [PATCH v2 3/5] usb: kbd: fix typo Heinrich Schuchardt
` (3 subsequent siblings)
5 siblings, 0 replies; 12+ messages in thread
From: Heinrich Schuchardt @ 2019-08-10 9:24 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>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
v2:
no change
---
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] 12+ messages in thread
* [U-Boot] [PATCH v2 3/5] usb: kbd: fix typo
2019-08-10 9:24 [U-Boot] [PATCH v2 0/5] usb: kbd: implement special keys Heinrich Schuchardt
2019-08-10 9:24 ` [U-Boot] [PATCH v2 1/5] usb: kbd: simplify coding for arrow keys Heinrich Schuchardt
2019-08-10 9:24 ` [U-Boot] [PATCH v2 2/5] usb: kbd: implement special keys Heinrich Schuchardt
@ 2019-08-10 9:24 ` Heinrich Schuchardt
2019-08-13 9:34 ` Simon Glass
2019-08-13 17:06 ` Simon Glass
2019-08-10 9:24 ` [U-Boot] [PATCH v2 4/5] usb: kbd: move USB_KBD_BOOT_REPORT_SIZE to usb.h Heinrich Schuchardt
` (2 subsequent siblings)
5 siblings, 2 replies; 12+ messages in thread
From: Heinrich Schuchardt @ 2019-08-10 9:24 UTC (permalink / raw)
To: u-boot
%s/a interrupt/an interrupt/
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
v2
new patch
---
common/usb_kbd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index c9ac7a9e4c..42c8c4041a 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -379,7 +379,7 @@ static inline void usb_kbd_poll_for_event(struct usb_device *dev)
#if defined(CONFIG_SYS_USB_EVENT_POLL)
struct usb_kbd_pdata *data = dev->privptr;
- /* Submit a interrupt transfer request */
+ /* Submit an interrupt transfer request */
usb_submit_int_msg(dev, data->intpipe, &data->new[0], data->intpktsize,
data->intinterval);
--
2.20.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH v2 4/5] usb: kbd: move USB_KBD_BOOT_REPORT_SIZE to usb.h
2019-08-10 9:24 [U-Boot] [PATCH v2 0/5] usb: kbd: implement special keys Heinrich Schuchardt
` (2 preceding siblings ...)
2019-08-10 9:24 ` [U-Boot] [PATCH v2 3/5] usb: kbd: fix typo Heinrich Schuchardt
@ 2019-08-10 9:24 ` Heinrich Schuchardt
2019-08-13 9:34 ` Simon Glass
2019-08-10 9:24 ` [U-Boot] [PATCH v2 5/5] dm: test: usb: rework keyboard test Heinrich Schuchardt
2019-08-23 18:20 ` [U-Boot] [PATCH v2 0/5] usb: kbd: implement special keys Heinrich Schuchardt
5 siblings, 1 reply; 12+ messages in thread
From: Heinrich Schuchardt @ 2019-08-10 9:24 UTC (permalink / raw)
To: u-boot
Move constant USB_KBD_BOOT_REPORT_SIZE. This allows us to reuse it.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
v2
new patch
---
common/usb_kbd.c | 6 ------
include/usb.h | 6 ++++++
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index 42c8c4041a..050c9ee783 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -86,12 +86,6 @@ static const unsigned char usb_kbd_num_keypad[] = {
#define USB_KBD_LEDMASK \
(USB_KBD_NUMLOCK | USB_KBD_CAPSLOCK | USB_KBD_SCROLLLOCK)
-/*
- * USB Keyboard reports are 8 bytes in boot protocol.
- * Appendix B of HID Device Class Definition 1.11
- */
-#define USB_KBD_BOOT_REPORT_SIZE 8
-
struct usb_kbd_pdata {
unsigned long intpipe;
int intpktsize;
diff --git a/include/usb.h b/include/usb.h
index 420a30e49f..db52736295 100644
--- a/include/usb.h
+++ b/include/usb.h
@@ -242,6 +242,12 @@ int usb_host_eth_scan(int mode);
#ifdef CONFIG_USB_KEYBOARD
+/*
+ * USB Keyboard reports are 8 bytes in boot protocol.
+ * Appendix B of HID Device Class Definition 1.11
+ */
+#define USB_KBD_BOOT_REPORT_SIZE 8
+
int drv_usb_kbd_init(void);
int usb_kbd_deregister(int force);
--
2.20.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH v2 5/5] dm: test: usb: rework keyboard test
2019-08-10 9:24 [U-Boot] [PATCH v2 0/5] usb: kbd: implement special keys Heinrich Schuchardt
` (3 preceding siblings ...)
2019-08-10 9:24 ` [U-Boot] [PATCH v2 4/5] usb: kbd: move USB_KBD_BOOT_REPORT_SIZE to usb.h Heinrich Schuchardt
@ 2019-08-10 9:24 ` Heinrich Schuchardt
2019-08-13 9:34 ` Simon Glass
2019-08-23 18:20 ` [U-Boot] [PATCH v2 0/5] usb: kbd: implement special keys Heinrich Schuchardt
5 siblings, 1 reply; 12+ messages in thread
From: Heinrich Schuchardt @ 2019-08-10 9:24 UTC (permalink / raw)
To: u-boot
Allow the unit test to pass full 8 byte scan code sequences to the USB
keyboard emulation driver and to parse multi-byte escape sequences.
The following features are not yet tested:
* LED status
* caps-lock
* num-lock
* numerical pad keys
The following features are not yet implemented by the USB keyboard
driver and therefore not tested:
* modifiers for non-alpha-numeric keys, e.g. <SHIFT><TAB> and <ALT><F4>
* some special keys, e.g. <PRINT>
* some modifiers, e.g. <ALT> and <META>
* alternative keyboard layouts
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
v2
new patch
---
drivers/usb/emul/sandbox_keyb.c | 27 +--
test/dm/usb.c | 283 +++++++++++++++++++++++++++++++-
2 files changed, 292 insertions(+), 18 deletions(-)
diff --git a/drivers/usb/emul/sandbox_keyb.c b/drivers/usb/emul/sandbox_keyb.c
index 635945179e..2e7fb3b97c 100644
--- a/drivers/usb/emul/sandbox_keyb.c
+++ b/drivers/usb/emul/sandbox_keyb.c
@@ -155,14 +155,20 @@ static void *keyb_desc_list[] = {
NULL,
};
-int sandbox_usb_keyb_add_string(struct udevice *dev, const char *str)
+/**
+ * sandbox_usb_keyb_add_string() - provide a USB scancode buffer
+ *
+ * @dev: the keyboard emulation device
+ * @scancode: scancode buffer with USB_KBD_BOOT_REPORT_SIZE bytes
+ */
+int sandbox_usb_keyb_add_string(struct udevice *dev,
+ const char scancode[USB_KBD_BOOT_REPORT_SIZE])
{
struct sandbox_keyb_priv *priv = dev_get_priv(dev);
- int len, ret;
+ int ret;
- len = strlen(str);
- ret = membuff_put(&priv->in, str, len);
- if (ret != len)
+ ret = membuff_put(&priv->in, scancode, USB_KBD_BOOT_REPORT_SIZE);
+ if (ret != USB_KBD_BOOT_REPORT_SIZE)
return -ENOSPC;
return 0;
@@ -182,12 +188,12 @@ static int sandbox_keyb_interrupt(struct udevice *dev, struct usb_device *udev,
{
struct sandbox_keyb_priv *priv = dev_get_priv(dev);
uint8_t *data = buffer;
- int ch;
memset(data, '\0', length);
- ch = membuff_getbyte(&priv->in);
- if (ch != -1)
- data[2] = 4 + ch - 'a';
+ if (length < USB_KBD_BOOT_REPORT_SIZE)
+ return 0;
+
+ membuff_get(&priv->in, buffer, USB_KBD_BOOT_REPORT_SIZE);
return 0;
}
@@ -212,7 +218,8 @@ static int sandbox_keyb_probe(struct udevice *dev)
{
struct sandbox_keyb_priv *priv = dev_get_priv(dev);
- return membuff_new(&priv->in, 256);
+ /* Provide an 80 character keyboard buffer */
+ return membuff_new(&priv->in, 80 * USB_KBD_BOOT_REPORT_SIZE);
}
static const struct dm_usb_ops sandbox_usb_keyb_ops = {
diff --git a/test/dm/usb.c b/test/dm/usb.c
index ef454b0ae5..6420b6efdc 100644
--- a/test/dm/usb.c
+++ b/test/dm/usb.c
@@ -15,6 +15,12 @@
#include <dm/uclass-internal.h>
#include <test/ut.h>
+struct keyboard_test_data {
+ const char modifiers;
+ const char scancode;
+ const char result[6];
+};
+
/* Test that sandbox USB works correctly */
static int dm_test_usb_base(struct unit_test_state *uts)
{
@@ -115,9 +121,262 @@ static int dm_test_usb_stop(struct unit_test_state *uts)
}
DM_TEST(dm_test_usb_stop, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+/**
+ * dm_test_usb_keyb() - test USB keyboard driver
+ *
+ * This test copies USB keyboard scan codes into the key buffer of the USB
+ * keyboard emulation driver. These are picked up during emulated interrupts
+ * by the USB keyboard driver and converted to characters and escape sequences.
+ * The test then reads and verifies these characters and escape sequences from
+ * the standard input.
+ *
+ * TODO: The following features are not yet tested:
+ *
+ * * LED status
+ * * caps-lock
+ * * num-lock
+ * * numerical pad keys
+ *
+ * TODO: The following features are not yet implemented by the USB keyboard
+ * driver and therefore not tested:
+ *
+ * * modifiers for non-alpha-numeric keys, e.g. <SHIFT><TAB> and <ALT><F4>
+ * * some special keys, e.g. <PRINT>
+ * * some modifiers, e.g. <ALT> and <META>
+ * * alternative keyboard layouts
+ *
+ * @uts: unit test state
+ * Return: 0 on success
+ */
static int dm_test_usb_keyb(struct unit_test_state *uts)
{
struct udevice *dev;
+ const struct keyboard_test_data *pos;
+ const struct keyboard_test_data kbd_test_data[] = {
+ /* <A> */
+ {0x00, 0x04, "a"},
+ /* <B> */
+ {0x00, 0x05, "b"},
+ /* <C> */
+ {0x00, 0x06, "c"},
+ /* <D> */
+ {0x00, 0x07, "d"},
+ /* <E> */
+ {0x00, 0x08, "e"},
+ /* <F> */
+ {0x00, 0x09, "f"},
+ /* <G> */
+ {0x00, 0x0a, "g"},
+ /* <H> */
+ {0x00, 0x0b, "h"},
+ /* <I> */
+ {0x00, 0x0c, "i"},
+ /* <J> */
+ {0x00, 0x0d, "j"},
+ /* <K> */
+ {0x00, 0x0e, "k"},
+ /* <L> */
+ {0x00, 0x0f, "l"},
+ /* <M> */
+ {0x00, 0x10, "m"},
+ /* <N> */
+ {0x00, 0x11, "n"},
+ /* <O> */
+ {0x00, 0x12, "o"},
+ /* <P> */
+ {0x00, 0x13, "p"},
+ /* <Q> */
+ {0x00, 0x14, "q"},
+ /* <R> */
+ {0x00, 0x15, "r"},
+ /* <S> */
+ {0x00, 0x16, "s"},
+ /* <T> */
+ {0x00, 0x17, "t"},
+ /* <U> */
+ {0x00, 0x18, "u"},
+ /* <V> */
+ {0x00, 0x19, "v"},
+ /* <W> */
+ {0x00, 0x1a, "w"},
+ /* <X> */
+ {0x00, 0x1b, "x"},
+ /* <Y> */
+ {0x00, 0x1c, "y"},
+ /* <Z> */
+ {0x00, 0x1d, "z"},
+
+ /* <LEFT-SHIFT><A> */
+ {0x02, 0x04, "A"},
+ /* <RIGHT-SHIFT><Z> */
+ {0x20, 0x1d, "Z"},
+
+ /* <LEFT-CONTROL><A> */
+ {0x01, 0x04, "\x01"},
+ /* <RIGHT-CONTROL><Z> */
+ {0x10, 0x1d, "\x1a"},
+
+ /* <1> */
+ {0x00, 0x1e, "1"},
+ /* <2> */
+ {0x00, 0x1f, "2"},
+ /* <3> */
+ {0x00, 0x20, "3"},
+ /* <4> */
+ {0x00, 0x21, "4"},
+ /* <5> */
+ {0x00, 0x22, "5"},
+ /* <6> */
+ {0x00, 0x23, "6"},
+ /* <7> */
+ {0x00, 0x24, "7"},
+ /* <8> */
+ {0x00, 0x25, "8"},
+ /* <9> */
+ {0x00, 0x26, "9"},
+ /* <0> */
+ {0x00, 0x27, "0"},
+
+ /* <LEFT-SHIFT><1> */
+ {0x02, 0x1e, "!"},
+ /* <RIGHT-SHIFT><2> */
+ {0x20, 0x1f, "@"},
+ /* <LEFT-SHIFT><3> */
+ {0x02, 0x20, "#"},
+ /* <RIGHT-SHIFT><4> */
+ {0x20, 0x21, "$"},
+ /* <LEFT-SHIFT><5> */
+ {0x02, 0x22, "%"},
+ /* <RIGHT-SHIFT><6> */
+ {0x20, 0x23, "^"},
+ /* <LEFT-SHIFT><7> */
+ {0x02, 0x24, "&"},
+ /* <RIGHT-SHIFT><8> */
+ {0x20, 0x25, "*"},
+ /* <LEFT-SHIFT><9> */
+ {0x02, 0x26, "("},
+ /* <RIGHT-SHIFT><0> */
+ {0x20, 0x27, ")"},
+
+ /* <ENTER> */
+ {0x00, 0x28, "\r"},
+ /* <ESCAPE> */
+ {0x00, 0x29, "\x1b"},
+ /* <BACKSPACE> */
+ {0x00, 0x2a, "\x08"},
+ /* <TAB> */
+ {0x00, 0x2b, "\x09"},
+ /* <SPACE> */
+ {0x00, 0x2c, " "},
+ /* <MINUS> */
+ {0x00, 0x2d, "-"},
+ /* <EQUAL> */
+ {0x00, 0x2e, "="},
+ /* <LEFT BRACE> */
+ {0x00, 0x2f, "["},
+ /* <RIGHT BRACE> */
+ {0x00, 0x30, "]"},
+ /* <BACKSLASH> */
+ {0x00, 0x31, "\\"},
+ /* <HASH-TILDE> */
+ {0x00, 0x32, "#"},
+ /* <SEMICOLON> */
+ {0x00, 0x33, ";"},
+ /* <APOSTROPHE> */
+ {0x00, 0x34, "'"},
+ /* <GRAVE> */
+ {0x00, 0x35, "`"},
+ /* <COMMA> */
+ {0x00, 0x36, ","},
+ /* <DOT> */
+ {0x00, 0x37, "."},
+ /* <SLASH> */
+ {0x00, 0x38, "/"},
+
+ /* <LEFT-SHIFT><ENTER> */
+ {0x02, 0x28, "\r"},
+ /* <RIGHT-SHIFT><ESCAPE> */
+ {0x20, 0x29, "\x1b"},
+ /* <LEFT-SHIFT><BACKSPACE> */
+ {0x02, 0x2a, "\x08"},
+ /* <RIGHT-SHIFT><TAB> */
+ {0x20, 0x2b, "\x09"},
+ /* <LEFT-SHIFT><SPACE> */
+ {0x02, 0x2c, " "},
+ /* <MINUS> */
+ {0x20, 0x2d, "_"},
+ /* <LEFT-SHIFT><EQUAL> */
+ {0x02, 0x2e, "+"},
+ /* <RIGHT-SHIFT><LEFT BRACE> */
+ {0x20, 0x2f, "{"},
+ /* <LEFT-SHIFT><RIGHT BRACE> */
+ {0x02, 0x30, "}"},
+ /* <RIGHT-SHIFT><BACKSLASH> */
+ {0x20, 0x31, "|"},
+ /* <LEFT-SHIFT><HASH-TILDE> */
+ {0x02, 0x32, "~"},
+ /* <RIGHT-SHIFT><SEMICOLON> */
+ {0x20, 0x33, ":"},
+ /* <LEFT-SHIFT><APOSTROPHE> */
+ {0x02, 0x34, "\""},
+ /* <RIGHT-SHIFT><GRAVE> */
+ {0x20, 0x35, "~"},
+ /* <LEFT-SHIFT><COMMA> */
+ {0x02, 0x36, "<"},
+ /* <RIGHT-SHIFT><DOT> */
+ {0x20, 0x37, ">"},
+ /* <LEFT-SHIFT><SLASH> */
+ {0x02, 0x38, "?"},
+
+ /* <F1> */
+ {0x00, 0x3a, "\x1bOP"},
+ /* <F2> */
+ {0x00, 0x3b, "\x1bOQ"},
+ /* <F3> */
+ {0x00, 0x3c, "\x1bOR"},
+ /* <F4> */
+ {0x00, 0x3d, "\x1bOS"},
+ /* <F5> */
+ {0x00, 0x3e, "\x1b[15~"},
+ /* <F6> */
+ {0x00, 0x3f, "\x1b[17~"},
+ /* <F7> */
+ {0x00, 0x40, "\x1b[18~"},
+ /* <F8> */
+ {0x00, 0x41, "\x1b[19~"},
+ /* <F9> */
+ {0x00, 0x42, "\x1b[20~"},
+ /* <F10> */
+ {0x00, 0x43, "\x1b[21~"},
+ /* <F11> */
+ {0x00, 0x44, "\x1b[23~"},
+ /* <F12> */
+ {0x00, 0x45, "\x1b[24~"},
+ /* <INSERT> */
+ {0x00, 0x49, "\x1b[2~"},
+ /* <HOME> */
+ {0x00, 0x4a, "\x1b[H"},
+ /* <PAGE UP> */
+ {0x00, 0x4b, "\x1b[5~"},
+ /* <DELETE> */
+ {0x00, 0x4c, "\x1b[3~"},
+ /* <END> */
+ {0x00, 0x4d, "\x1b[F"},
+ /* <PAGE DOWN> */
+ {0x00, 0x4e, "\x1b[6~"},
+ /* <RIGHT> */
+ {0x00, 0x4f, "\x1b[C"},
+ /* <LEFT> */
+ {0x00, 0x50, "\x1b[D"},
+ /* <DOWN> */
+ {0x00, 0x51, "\x1b[B"},
+ /* <UP> */
+ {0x00, 0x52, "\x1b[A"},
+
+ /* End of list */
+ {0x00, 0x00, "\0"}
+ };
+
state_set_skip_delays(true);
ut_assertok(usb_init());
@@ -129,16 +388,24 @@ static int dm_test_usb_keyb(struct unit_test_state *uts)
&dev));
/*
- * Add a string to the USB keyboard buffer - it should appear in
- * stdin
+ * Add scan codes to the USB keyboard buffer. They should appear as
+ * corresponding characters and escape sequences in stdin.
*/
- ut_assertok(sandbox_usb_keyb_add_string(dev, "ab"));
- ut_asserteq(1, tstc());
- ut_asserteq('a', getc());
- ut_asserteq(1, tstc());
- ut_asserteq('b', getc());
- ut_asserteq(0, tstc());
+ for (pos = kbd_test_data; pos->scancode; ++pos) {
+ const char *c;
+ char scancodes[USB_KBD_BOOT_REPORT_SIZE] = {0};
+ scancodes[0] = pos->modifiers;
+ scancodes[2] = pos->scancode;
+
+ ut_assertok(sandbox_usb_keyb_add_string(dev, scancodes));
+
+ for (c = pos->result; *c; ++c) {
+ ut_asserteq(1, tstc());
+ ut_asserteq(*c, getc());
+ }
+ ut_asserteq(0, tstc());
+ }
ut_assertok(usb_stop());
return 0;
--
2.20.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH v2 3/5] usb: kbd: fix typo
2019-08-10 9:24 ` [U-Boot] [PATCH v2 3/5] usb: kbd: fix typo Heinrich Schuchardt
@ 2019-08-13 9:34 ` Simon Glass
2019-08-13 17:06 ` Simon Glass
1 sibling, 0 replies; 12+ messages in thread
From: Simon Glass @ 2019-08-13 9:34 UTC (permalink / raw)
To: u-boot
On Sat, 10 Aug 2019 at 03:24, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> %s/a interrupt/an interrupt/
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
> v2
> new patch
> ---
> common/usb_kbd.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/emul/sandbox_keyb.c
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH v2 4/5] usb: kbd: move USB_KBD_BOOT_REPORT_SIZE to usb.h
2019-08-10 9:24 ` [U-Boot] [PATCH v2 4/5] usb: kbd: move USB_KBD_BOOT_REPORT_SIZE to usb.h Heinrich Schuchardt
@ 2019-08-13 9:34 ` Simon Glass
0 siblings, 0 replies; 12+ messages in thread
From: Simon Glass @ 2019-08-13 9:34 UTC (permalink / raw)
To: u-boot
On Sat, 10 Aug 2019 at 03:24, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> Move constant USB_KBD_BOOT_REPORT_SIZE. This allows us to reuse it.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
> v2
> new patch
> ---
> common/usb_kbd.c | 6 ------
> include/usb.h | 6 ++++++
> 2 files changed, 6 insertions(+), 6 deletions(-)
Reviewed-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH v2 5/5] dm: test: usb: rework keyboard test
2019-08-10 9:24 ` [U-Boot] [PATCH v2 5/5] dm: test: usb: rework keyboard test Heinrich Schuchardt
@ 2019-08-13 9:34 ` Simon Glass
0 siblings, 0 replies; 12+ messages in thread
From: Simon Glass @ 2019-08-13 9:34 UTC (permalink / raw)
To: u-boot
On Sat, 10 Aug 2019 at 03:24, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> Allow the unit test to pass full 8 byte scan code sequences to the USB
> keyboard emulation driver and to parse multi-byte escape sequences.
>
> The following features are not yet tested:
>
> * LED status
> * caps-lock
> * num-lock
> * numerical pad keys
>
> The following features are not yet implemented by the USB keyboard
> driver and therefore not tested:
>
> * modifiers for non-alpha-numeric keys, e.g. <SHIFT><TAB> and <ALT><F4>
> * some special keys, e.g. <PRINT>
> * some modifiers, e.g. <ALT> and <META>
> * alternative keyboard layouts
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
> v2
> new patch
> ---
> drivers/usb/emul/sandbox_keyb.c | 27 +--
> test/dm/usb.c | 283 +++++++++++++++++++++++++++++++-
> 2 files changed, 292 insertions(+), 18 deletions(-)
Nice!
Reviewed-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH v2 3/5] usb: kbd: fix typo
2019-08-10 9:24 ` [U-Boot] [PATCH v2 3/5] usb: kbd: fix typo Heinrich Schuchardt
2019-08-13 9:34 ` Simon Glass
@ 2019-08-13 17:06 ` Simon Glass
1 sibling, 0 replies; 12+ messages in thread
From: Simon Glass @ 2019-08-13 17:06 UTC (permalink / raw)
To: u-boot
On Sat, 10 Aug 2019 at 03:24, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> %s/a interrupt/an interrupt/
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
> v2
> new patch
> ---
> common/usb_kbd.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH v2 0/5] usb: kbd: implement special keys
2019-08-10 9:24 [U-Boot] [PATCH v2 0/5] usb: kbd: implement special keys Heinrich Schuchardt
` (4 preceding siblings ...)
2019-08-10 9:24 ` [U-Boot] [PATCH v2 5/5] dm: test: usb: rework keyboard test Heinrich Schuchardt
@ 2019-08-23 18:20 ` Heinrich Schuchardt
2019-08-23 18:29 ` Marek Vasut
5 siblings, 1 reply; 12+ messages in thread
From: Heinrich Schuchardt @ 2019-08-23 18:20 UTC (permalink / raw)
To: u-boot
On 8/10/19 11:24 AM, Heinrich Schuchardt wrote:
> 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.
>
> Enhance the keyboard unit test.
>
> v2:
> enhance the keyboard unit test
>
> Heinrich Schuchardt (5):
> usb: kbd: simplify coding for arrow keys
> usb: kbd: implement special keys
> usb: kbd: fix typo
> usb: kbd: move USB_KBD_BOOT_REPORT_SIZE to usb.h
> dm: test: usb: rework keyboard test
>
> common/usb_kbd.c | 89 +++++++---
> drivers/usb/emul/sandbox_keyb.c | 27 +--
> include/usb.h | 6 +
> test/dm/usb.c | 285 +++++++++++++++++++++++++++++++-
> 4 files changed, 361 insertions(+), 46 deletions(-)
>
> --
> 2.20.1
>
>
Hello Marek,
these patches have been assigned to you in Patchwork. All have been
reviewed by Simon. Will you take these patches via the USB tree?
Best regards
Heinrich
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH v2 0/5] usb: kbd: implement special keys
2019-08-23 18:20 ` [U-Boot] [PATCH v2 0/5] usb: kbd: implement special keys Heinrich Schuchardt
@ 2019-08-23 18:29 ` Marek Vasut
0 siblings, 0 replies; 12+ messages in thread
From: Marek Vasut @ 2019-08-23 18:29 UTC (permalink / raw)
To: u-boot
On 8/23/19 8:20 PM, Heinrich Schuchardt wrote:
> On 8/10/19 11:24 AM, Heinrich Schuchardt wrote:
>> 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.
>>
>> Enhance the keyboard unit test.
>>
>> v2:
>> enhance the keyboard unit test
>>
>> Heinrich Schuchardt (5):
>> usb: kbd: simplify coding for arrow keys
>> usb: kbd: implement special keys
>> usb: kbd: fix typo
>> usb: kbd: move USB_KBD_BOOT_REPORT_SIZE to usb.h
>> dm: test: usb: rework keyboard test
>>
>> common/usb_kbd.c | 89 +++++++---
>> drivers/usb/emul/sandbox_keyb.c | 27 +--
>> include/usb.h | 6 +
>> test/dm/usb.c | 285 +++++++++++++++++++++++++++++++-
>> 4 files changed, 361 insertions(+), 46 deletions(-)
>>
>> --
>> 2.20.1
>>
>>
>
> Hello Marek,
>
> these patches have been assigned to you in Patchwork. All have been
> reviewed by Simon. Will you take these patches via the USB tree?
They don't apply to u-boot-usb/master , but I suspect that's because of
a conflict with the series that's already there (and which doesn't
build). So I need to deconflict the situation somehow, maybe wait a bit
for Michal to fix the series and then rebase on top ?
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2019-08-23 18:29 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-10 9:24 [U-Boot] [PATCH v2 0/5] usb: kbd: implement special keys Heinrich Schuchardt
2019-08-10 9:24 ` [U-Boot] [PATCH v2 1/5] usb: kbd: simplify coding for arrow keys Heinrich Schuchardt
2019-08-10 9:24 ` [U-Boot] [PATCH v2 2/5] usb: kbd: implement special keys Heinrich Schuchardt
2019-08-10 9:24 ` [U-Boot] [PATCH v2 3/5] usb: kbd: fix typo Heinrich Schuchardt
2019-08-13 9:34 ` Simon Glass
2019-08-13 17:06 ` Simon Glass
2019-08-10 9:24 ` [U-Boot] [PATCH v2 4/5] usb: kbd: move USB_KBD_BOOT_REPORT_SIZE to usb.h Heinrich Schuchardt
2019-08-13 9:34 ` Simon Glass
2019-08-10 9:24 ` [U-Boot] [PATCH v2 5/5] dm: test: usb: rework keyboard test Heinrich Schuchardt
2019-08-13 9:34 ` Simon Glass
2019-08-23 18:20 ` [U-Boot] [PATCH v2 0/5] usb: kbd: implement special keys Heinrich Schuchardt
2019-08-23 18:29 ` Marek Vasut
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.