Fixed bug 1559 - SDL does not provide scancodes for all keys available on Android.
authorSam Lantinga <slouken@libsdl.org>
Wed, 26 Sep 2012 20:28:58 -0700
changeset 6465 09b96f7ebe80
parent 6464 ab55284b389f
child 6466 ebe165c00fab
Fixed bug 1559 - SDL does not provide scancodes for all keys available on Android. Philipp Wiesemann 2012-07-28 10:03:47 PDT the current version of SDL 2.0 (HG) does not provide scancodes for all keys available on Android. Missing are all new keys added since Android API level 11. Also it would be possible to map SDL_SCANCODE_WWW, SDL_SCANCODE_MAIL and SDL_SCANCODE_SLASH. Android's KEYCODE_DEL is mapped to SDL_SCANCODE_DELETE but according to Android's documentation [1] it should be like SDL_SCANCODE_BACKSPACE. I attached a patch with these corrections.
src/video/android/SDL_androidkeyboard.c
--- a/src/video/android/SDL_androidkeyboard.c	Wed Sep 26 20:14:37 2012 -0700
+++ b/src/video/android/SDL_androidkeyboard.c	Wed Sep 26 20:28:58 2012 -0700
@@ -103,10 +103,10 @@
     SDL_SCANCODE_TAB, /* AKEYCODE_TAB */
     SDL_SCANCODE_SPACE, /* AKEYCODE_SPACE */
     SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SYM */
-    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_EXPLORER */
-    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ENVELOPE */
+    SDL_SCANCODE_WWW, /* AKEYCODE_EXPLORER */
+    SDL_SCANCODE_MAIL, /* AKEYCODE_ENVELOPE */
     SDL_SCANCODE_RETURN, /* AKEYCODE_ENTER */
-    SDL_SCANCODE_DELETE, /* AKEYCODE_DEL */
+    SDL_SCANCODE_BACKSPACE, /* AKEYCODE_DEL */
     SDL_SCANCODE_GRAVE, /* AKEYCODE_GRAVE */
     SDL_SCANCODE_MINUS, /* AKEYCODE_MINUS */
     SDL_SCANCODE_EQUALS, /* AKEYCODE_EQUALS */
@@ -115,7 +115,7 @@
     SDL_SCANCODE_BACKSLASH, /* AKEYCODE_BACKSLASH */
     SDL_SCANCODE_SEMICOLON, /* AKEYCODE_SEMICOLON */
     SDL_SCANCODE_APOSTROPHE, /* AKEYCODE_APOSTROPHE */
-    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SLASH */
+    SDL_SCANCODE_SLASH, /* AKEYCODE_SLASH */
     SDL_SCANCODE_UNKNOWN, /* AKEYCODE_AT */
     SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NUM */
     SDL_SCANCODE_UNKNOWN, /* AKEYCODE_HEADSETHOOK */
@@ -150,6 +150,115 @@
     SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_START */
     SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_SELECT */
     SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_MODE */
+    SDL_SCANCODE_ESCAPE, /* AKEYCODE_ESCAPE */
+    SDL_SCANCODE_DELETE, /* AKEYCODE_FORWARD_DEL */
+    SDL_SCANCODE_LCTRL, /* AKEYCODE_CTRL_LEFT */
+    SDL_SCANCODE_RCTRL, /* AKEYCODE_CTRL_RIGHT */
+    SDL_SCANCODE_CAPSLOCK, /* AKEYCODE_CAPS_LOCK */
+    SDL_SCANCODE_SCROLLLOCK, /* AKEYCODE_SCROLL_LOCK */
+    SDL_SCANCODE_LGUI, /* AKEYCODE_META_LEFT */
+    SDL_SCANCODE_RGUI, /* AKEYCODE_META_RIGHT */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_FUNCTION */
+    SDL_SCANCODE_PRINTSCREEN, /* AKEYCODE_SYSRQ */
+    SDL_SCANCODE_PAUSE, /* AKEYCODE_BREAK */
+    SDL_SCANCODE_HOME, /* AKEYCODE_MOVE_HOME */
+    SDL_SCANCODE_END, /* AKEYCODE_MOVE_END */
+    SDL_SCANCODE_INSERT, /* AKEYCODE_INSERT */
+    SDL_SCANCODE_AC_FORWARD, /* AKEYCODE_FORWARD */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_PLAY */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_PAUSE */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_CLOSE */
+    SDL_SCANCODE_EJECT, /* AKEYCODE_MEDIA_EJECT */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_RECORD */
+    SDL_SCANCODE_F1, /* AKEYCODE_F1 */
+    SDL_SCANCODE_F2, /* AKEYCODE_F2 */
+    SDL_SCANCODE_F3, /* AKEYCODE_F3 */
+    SDL_SCANCODE_F4, /* AKEYCODE_F4 */
+    SDL_SCANCODE_F5, /* AKEYCODE_F5 */
+    SDL_SCANCODE_F6, /* AKEYCODE_F6 */
+    SDL_SCANCODE_F7, /* AKEYCODE_F7 */
+    SDL_SCANCODE_F8, /* AKEYCODE_F8 */
+    SDL_SCANCODE_F9, /* AKEYCODE_F9 */
+    SDL_SCANCODE_F10, /* AKEYCODE_F10 */
+    SDL_SCANCODE_F11, /* AKEYCODE_F11 */
+    SDL_SCANCODE_F12, /* AKEYCODE_F12 */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NUM_LOCK */
+    SDL_SCANCODE_KP_0, /* AKEYCODE_NUMPAD_0 */
+    SDL_SCANCODE_KP_1, /* AKEYCODE_NUMPAD_1 */
+    SDL_SCANCODE_KP_2, /* AKEYCODE_NUMPAD_2 */
+    SDL_SCANCODE_KP_3, /* AKEYCODE_NUMPAD_3 */
+    SDL_SCANCODE_KP_4, /* AKEYCODE_NUMPAD_4 */
+    SDL_SCANCODE_KP_5, /* AKEYCODE_NUMPAD_5 */
+    SDL_SCANCODE_KP_6, /* AKEYCODE_NUMPAD_6 */
+    SDL_SCANCODE_KP_7, /* AKEYCODE_NUMPAD_7 */
+    SDL_SCANCODE_KP_8, /* AKEYCODE_NUMPAD_8 */
+    SDL_SCANCODE_KP_9, /* AKEYCODE_NUMPAD_9 */
+    SDL_SCANCODE_KP_DIVIDE, /* AKEYCODE_NUMPAD_DIVIDE */
+    SDL_SCANCODE_KP_MULTIPLY, /* AKEYCODE_NUMPAD_MULTIPLY */
+    SDL_SCANCODE_KP_MINUS, /* AKEYCODE_NUMPAD_SUBTRACT */
+    SDL_SCANCODE_KP_PLUS, /* AKEYCODE_NUMPAD_ADD */
+    SDL_SCANCODE_KP_PERIOD, /* AKEYCODE_NUMPAD_DOT */
+    SDL_SCANCODE_KP_COMMA, /* AKEYCODE_NUMPAD_COMMA */
+    SDL_SCANCODE_KP_ENTER, /* AKEYCODE_NUMPAD_ENTER */
+    SDL_SCANCODE_KP_EQUALS, /* AKEYCODE_NUMPAD_EQUALS */
+    SDL_SCANCODE_KP_LEFTPAREN, /* AKEYCODE_NUMPAD_LEFT_PAREN */
+    SDL_SCANCODE_KP_RIGHTPAREN, /* AKEYCODE_NUMPAD_RIGHT_PAREN */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_VOLUME_MUTE */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_INFO */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CHANNEL_UP */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CHANNEL_DOWN */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ZOOM_IN */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ZOOM_OUT */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_WINDOW */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_GUIDE */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_DVR */
+    SDL_SCANCODE_AC_BOOKMARKS, /* AKEYCODE_BOOKMARK */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CAPTIONS */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SETTINGS */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_POWER */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STB_POWER */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STB_INPUT */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_AVR_POWER */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_AVR_INPUT */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PROG_RED */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PROG_GREEN */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PROG_YELLOW */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PROG_BLUE */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_APP_SWITCH */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_1 */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_2 */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_3 */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_4 */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_5 */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_6 */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_7 */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_8 */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_9 */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_10 */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_11 */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_12 */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_13 */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_14 */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_15 */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_16 */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_LANGUAGE_SWITCH */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MANNER_MODE */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_3D_MODE */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CONTACTS */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CALENDAR */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MUSIC */
+    SDL_SCANCODE_CALCULATOR, /* AKEYCODE_CALCULATOR */
+    SDL_SCANCODE_LANG5, /* AKEYCODE_ZENKAKU_HANKAKU */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_EISU */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MUHENKAN */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_HENKAN */
+    SDL_SCANCODE_LANG3, /* AKEYCODE_KATAKANA_HIRAGANA */
+    SDL_SCANCODE_INTERNATIONAL3, /* AKEYCODE_YEN */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_RO */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_KANA */
+    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ASSIST */
 };
 
 static SDL_Scancode