diff mbox series

[1/1] sandbox: add missing SDL key scan codes

Message ID 20200928234118.124795-1-xypron.glpk@gmx.de
State Accepted
Delegated to: Simon Glass
Headers show
Series [1/1] sandbox: add missing SDL key scan codes | expand

Commit Message

Heinrich Schuchardt Sept. 28, 2020, 11:41 p.m. UTC
Add missing SDL key scan codes, e.g.

* shift, ctrl, meta, alt
* brace/bracket

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 arch/sandbox/cpu/sdl.c | 156 +++++++++++++++++++++++------------------
 1 file changed, 89 insertions(+), 67 deletions(-)

--
2.28.0

Comments

Simon Glass Oct. 5, 2020, 1:42 a.m. UTC | #1
On Mon, 28 Sep 2020 at 17:41, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> Add missing SDL key scan codes, e.g.
>
> * shift, ctrl, meta, alt
> * brace/bracket
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
>  arch/sandbox/cpu/sdl.c | 156 +++++++++++++++++++++++------------------
>  1 file changed, 89 insertions(+), 67 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
Simon Glass Oct. 5, 2020, 9:32 p.m. UTC | #2
On Mon, 28 Sep 2020 at 17:41, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> Add missing SDL key scan codes, e.g.
>
> * shift, ctrl, meta, alt
> * brace/bracket
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
>  arch/sandbox/cpu/sdl.c | 156 +++++++++++++++++++++++------------------
>  1 file changed, 89 insertions(+), 67 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-dm/next, thanks!
diff mbox series

Patch

diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c
index 6416cab96c..7dc3dab32e 100644
--- a/arch/sandbox/cpu/sdl.c
+++ b/arch/sandbox/cpu/sdl.c
@@ -172,33 +172,7 @@  int sandbox_sdl_sync(void *lcd_base)
 }

 static const unsigned short sdl_to_keycode[SDL_NUM_SCANCODES] = {
-	[SDL_SCANCODE_A]	= KEY_A,
-	[SDL_SCANCODE_B]	= KEY_B,
-	[SDL_SCANCODE_C]	= KEY_C,
-	[SDL_SCANCODE_D]	= KEY_D,
-	[SDL_SCANCODE_E]	= KEY_E,
-	[SDL_SCANCODE_F]	= KEY_F,
-	[SDL_SCANCODE_G]	= KEY_G,
-	[SDL_SCANCODE_H]	= KEY_H,
-	[SDL_SCANCODE_I]	= KEY_I,
-	[SDL_SCANCODE_J]	= KEY_J,
-	[SDL_SCANCODE_K]	= KEY_K,
-	[SDL_SCANCODE_L]	= KEY_L,
-	[SDL_SCANCODE_M]	= KEY_M,
-	[SDL_SCANCODE_N]	= KEY_N,
-	[SDL_SCANCODE_O]	= KEY_O,
-	[SDL_SCANCODE_P]	= KEY_P,
-	[SDL_SCANCODE_Q]	= KEY_Q,
-	[SDL_SCANCODE_R]	= KEY_R,
-	[SDL_SCANCODE_S]	= KEY_S,
-	[SDL_SCANCODE_T]	= KEY_T,
-	[SDL_SCANCODE_U]	= KEY_U,
-	[SDL_SCANCODE_V]	= KEY_V,
-	[SDL_SCANCODE_W]	= KEY_W,
-	[SDL_SCANCODE_X]	= KEY_X,
-	[SDL_SCANCODE_Y]	= KEY_Y,
-	[SDL_SCANCODE_Z]	= KEY_Z,
-
+	[SDL_SCANCODE_ESCAPE]	= KEY_ESC,
 	[SDL_SCANCODE_1]	= KEY_1,
 	[SDL_SCANCODE_2]	= KEY_2,
 	[SDL_SCANCODE_3]	= KEY_3,
@@ -209,25 +183,53 @@  static const unsigned short sdl_to_keycode[SDL_NUM_SCANCODES] = {
 	[SDL_SCANCODE_8]	= KEY_8,
 	[SDL_SCANCODE_9]	= KEY_9,
 	[SDL_SCANCODE_0]	= KEY_0,
-
-	[SDL_SCANCODE_RETURN]	= KEY_ENTER,
-	[SDL_SCANCODE_ESCAPE]	= KEY_ESC,
-	[SDL_SCANCODE_BACKSPACE]	= KEY_BACKSPACE,
-	[SDL_SCANCODE_TAB]	= KEY_TAB,
-	[SDL_SCANCODE_SPACE]	= KEY_SPACE,
-
 	[SDL_SCANCODE_MINUS]	= KEY_MINUS,
 	[SDL_SCANCODE_EQUALS]	= KEY_EQUAL,
-	[SDL_SCANCODE_BACKSLASH]	= KEY_BACKSLASH,
+	[SDL_SCANCODE_BACKSPACE]	= KEY_BACKSPACE,
+	[SDL_SCANCODE_TAB]	= KEY_TAB,
+	[SDL_SCANCODE_Q]	= KEY_Q,
+	[SDL_SCANCODE_W]	= KEY_W,
+	[SDL_SCANCODE_E]	= KEY_E,
+	[SDL_SCANCODE_R]	= KEY_R,
+	[SDL_SCANCODE_T]	= KEY_T,
+	[SDL_SCANCODE_Y]	= KEY_Y,
+	[SDL_SCANCODE_U]	= KEY_U,
+	[SDL_SCANCODE_I]	= KEY_I,
+	[SDL_SCANCODE_O]	= KEY_O,
+	[SDL_SCANCODE_P]	= KEY_P,
+	[SDL_SCANCODE_LEFTBRACKET]	= KEY_LEFTBRACE,
+	[SDL_SCANCODE_RIGHTBRACKET]	= KEY_RIGHTBRACE,
+	[SDL_SCANCODE_RETURN]	= KEY_ENTER,
+	[SDL_SCANCODE_LCTRL]	= KEY_LEFTCTRL,
+	[SDL_SCANCODE_A]	= KEY_A,
+	[SDL_SCANCODE_S]	= KEY_S,
+	[SDL_SCANCODE_D]	= KEY_D,
+	[SDL_SCANCODE_F]	= KEY_F,
+	[SDL_SCANCODE_G]	= KEY_G,
+	[SDL_SCANCODE_H]	= KEY_H,
+	[SDL_SCANCODE_J]	= KEY_J,
+	[SDL_SCANCODE_K]	= KEY_K,
+	[SDL_SCANCODE_L]	= KEY_L,
 	[SDL_SCANCODE_SEMICOLON]	= KEY_SEMICOLON,
 	[SDL_SCANCODE_APOSTROPHE]	= KEY_APOSTROPHE,
 	[SDL_SCANCODE_GRAVE]	= KEY_GRAVE,
+	[SDL_SCANCODE_LSHIFT]	= KEY_LEFTSHIFT,
+	[SDL_SCANCODE_BACKSLASH]	= KEY_BACKSLASH,
+	[SDL_SCANCODE_Z]	= KEY_Z,
+	[SDL_SCANCODE_X]	= KEY_X,
+	[SDL_SCANCODE_C]	= KEY_C,
+	[SDL_SCANCODE_V]	= KEY_V,
+	[SDL_SCANCODE_B]	= KEY_B,
+	[SDL_SCANCODE_N]	= KEY_N,
+	[SDL_SCANCODE_M]	= KEY_M,
 	[SDL_SCANCODE_COMMA]	= KEY_COMMA,
 	[SDL_SCANCODE_PERIOD]	= KEY_DOT,
 	[SDL_SCANCODE_SLASH]	= KEY_SLASH,
-
+	[SDL_SCANCODE_RSHIFT]	= KEY_RIGHTSHIFT,
+	[SDL_SCANCODE_KP_MULTIPLY] = KEY_KPASTERISK,
+	[SDL_SCANCODE_LALT]	= KEY_LEFTALT,
+	[SDL_SCANCODE_SPACE]	= KEY_SPACE,
 	[SDL_SCANCODE_CAPSLOCK]	= KEY_CAPSLOCK,
-
 	[SDL_SCANCODE_F1]	= KEY_F1,
 	[SDL_SCANCODE_F2]	= KEY_F2,
 	[SDL_SCANCODE_F3]	= KEY_F3,
@@ -238,45 +240,65 @@  static const unsigned short sdl_to_keycode[SDL_NUM_SCANCODES] = {
 	[SDL_SCANCODE_F8]	= KEY_F8,
 	[SDL_SCANCODE_F9]	= KEY_F9,
 	[SDL_SCANCODE_F10]	= KEY_F10,
-	[SDL_SCANCODE_F11]	= KEY_F11,
-	[SDL_SCANCODE_F12]	= KEY_F12,
-
-	[SDL_SCANCODE_PRINTSCREEN]	= KEY_PRINT,
-	[SDL_SCANCODE_SCROLLLOCK]	= KEY_SCROLLLOCK,
-	[SDL_SCANCODE_PAUSE]	= KEY_PAUSE,
-	[SDL_SCANCODE_INSERT]	= KEY_INSERT,
-	[SDL_SCANCODE_HOME]	= KEY_HOME,
-	[SDL_SCANCODE_PAGEUP]	= KEY_PAGEUP,
-	[SDL_SCANCODE_DELETE]	= KEY_DELETE,
-	[SDL_SCANCODE_END]	= KEY_END,
-	[SDL_SCANCODE_PAGEDOWN]	= KEY_PAGEDOWN,
-	[SDL_SCANCODE_RIGHT]	= KEY_RIGHT,
-	[SDL_SCANCODE_LEFT]	= KEY_LEFT,
-	[SDL_SCANCODE_DOWN]	= KEY_DOWN,
-	[SDL_SCANCODE_UP]	= KEY_UP,
-
 	[SDL_SCANCODE_NUMLOCKCLEAR]	= KEY_NUMLOCK,
-	[SDL_SCANCODE_KP_DIVIDE]	= KEY_KPSLASH,
-	[SDL_SCANCODE_KP_MULTIPLY]	= KEY_KPASTERISK,
+	[SDL_SCANCODE_SCROLLLOCK]	= KEY_SCROLLLOCK,
+	[SDL_SCANCODE_KP_7]	= KEY_KP7,
+	[SDL_SCANCODE_KP_8]	= KEY_KP8,
+	[SDL_SCANCODE_KP_9]	= KEY_KP9,
 	[SDL_SCANCODE_KP_MINUS]	= KEY_KPMINUS,
+	[SDL_SCANCODE_KP_4]	= KEY_KP4,
+	[SDL_SCANCODE_KP_5]	= KEY_KP5,
+	[SDL_SCANCODE_KP_6]	= KEY_KP6,
 	[SDL_SCANCODE_KP_PLUS]	= KEY_KPPLUS,
-	[SDL_SCANCODE_KP_ENTER]	= KEY_KPENTER,
 	[SDL_SCANCODE_KP_1]	= KEY_KP1,
 	[SDL_SCANCODE_KP_2]	= KEY_KP2,
 	[SDL_SCANCODE_KP_3]	= KEY_KP3,
-	[SDL_SCANCODE_KP_4]	= KEY_KP4,
-	[SDL_SCANCODE_KP_5]	= KEY_KP5,
-	[SDL_SCANCODE_KP_6]	= KEY_KP6,
-	[SDL_SCANCODE_KP_7]	= KEY_KP7,
-	[SDL_SCANCODE_KP_8]	= KEY_KP8,
-	[SDL_SCANCODE_KP_9]	= KEY_KP9,
 	[SDL_SCANCODE_KP_0]	= KEY_KP0,
 	[SDL_SCANCODE_KP_PERIOD]	= KEY_KPDOT,
-
-	[SDL_SCANCODE_KP_EQUALS]	= KEY_KPEQUAL,
-	[SDL_SCANCODE_KP_COMMA]	= KEY_KPCOMMA,
-
+	/* key 84 does not exist linux_input.h */
+	[SDL_SCANCODE_LANG5]	=  KEY_ZENKAKUHANKAKU,
+	[SDL_SCANCODE_NONUSBACKSLASH]	= KEY_102ND,
+	[SDL_SCANCODE_F11]	= KEY_F11,
+	[SDL_SCANCODE_F12]	= KEY_F12,
+	[SDL_SCANCODE_INTERNATIONAL1]	= KEY_RO,
+	[SDL_SCANCODE_LANG3]	= KEY_KATAKANA,
+	[SDL_SCANCODE_LANG4]	= KEY_HIRAGANA,
+	[SDL_SCANCODE_INTERNATIONAL4] = KEY_HENKAN,
+	[SDL_SCANCODE_INTERNATIONAL2] = KEY_KATAKANAHIRAGANA,
+	[SDL_SCANCODE_INTERNATIONAL5] = KEY_MUHENKAN,
+	/* [SDL_SCANCODE_INTERNATIONAL5] -> [KEY_KPJPCOMMA] */
+	[SDL_SCANCODE_KP_ENTER]	= KEY_KPENTER,
+	[SDL_SCANCODE_RCTRL]	= KEY_RIGHTCTRL,
+	[SDL_SCANCODE_KP_DIVIDE] = KEY_KPSLASH,
 	[SDL_SCANCODE_SYSREQ]	= KEY_SYSRQ,
+	[SDL_SCANCODE_RALT]	= KEY_RIGHTALT,
+	/* KEY_LINEFEED */
+	[SDL_SCANCODE_HOME]	= KEY_HOME,
+	[SDL_SCANCODE_UP]	= KEY_UP,
+	[SDL_SCANCODE_PAGEUP]	= KEY_PAGEUP,
+	[SDL_SCANCODE_LEFT]	= KEY_LEFT,
+	[SDL_SCANCODE_RIGHT]	= KEY_RIGHT,
+	[SDL_SCANCODE_END]	= KEY_END,
+	[SDL_SCANCODE_DOWN]	= KEY_DOWN,
+	[SDL_SCANCODE_PAGEDOWN]	= KEY_PAGEDOWN,
+	[SDL_SCANCODE_INSERT]	= KEY_INSERT,
+	[SDL_SCANCODE_DELETE]	= KEY_DELETE,
+	/* KEY_MACRO */
+	[SDL_SCANCODE_MUTE]	= KEY_MUTE,
+	[SDL_SCANCODE_VOLUMEDOWN]	= KEY_VOLUMEDOWN,
+	[SDL_SCANCODE_VOLUMEUP]	= KEY_VOLUMEUP,
+	[SDL_SCANCODE_POWER]	= KEY_POWER,
+	[SDL_SCANCODE_KP_EQUALS]	= KEY_KPEQUAL,
+	[SDL_SCANCODE_KP_PLUSMINUS]	= KEY_KPPLUSMINUS,
+	[SDL_SCANCODE_PAUSE]	= KEY_PAUSE,
+	/* KEY_SCALE */
+	[SDL_SCANCODE_KP_COMMA] = KEY_KPCOMMA,
+	[SDL_SCANCODE_LANG1]	= KEY_HANGUEL,
+	[SDL_SCANCODE_LANG2]	= KEY_HANJA,
+	[SDL_SCANCODE_INTERNATIONAL3]	= KEY_YEN,
+	[SDL_SCANCODE_LGUI]	= KEY_LEFTMETA,
+	[SDL_SCANCODE_RGUI]	= KEY_RIGHTMETA,
+	[SDL_SCANCODE_APPLICATION] = KEY_COMPOSE,
 };

 int sandbox_sdl_scan_keys(int key[], int max_keys)