Fixed bug 1559 - SDL does not provide scancodes for all keys available on Android.
authorSam Lantinga
Wed, 26 Sep 2012 20:28:58 -0700
changeset 646509b96f7ebe80
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
     1.1 --- a/src/video/android/SDL_androidkeyboard.c	Wed Sep 26 20:14:37 2012 -0700
     1.2 +++ b/src/video/android/SDL_androidkeyboard.c	Wed Sep 26 20:28:58 2012 -0700
     1.3 @@ -103,10 +103,10 @@
     1.4      SDL_SCANCODE_TAB, /* AKEYCODE_TAB */
     1.5      SDL_SCANCODE_SPACE, /* AKEYCODE_SPACE */
     1.6      SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SYM */
     1.7 -    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_EXPLORER */
     1.8 -    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ENVELOPE */
     1.9 +    SDL_SCANCODE_WWW, /* AKEYCODE_EXPLORER */
    1.10 +    SDL_SCANCODE_MAIL, /* AKEYCODE_ENVELOPE */
    1.11      SDL_SCANCODE_RETURN, /* AKEYCODE_ENTER */
    1.12 -    SDL_SCANCODE_DELETE, /* AKEYCODE_DEL */
    1.13 +    SDL_SCANCODE_BACKSPACE, /* AKEYCODE_DEL */
    1.14      SDL_SCANCODE_GRAVE, /* AKEYCODE_GRAVE */
    1.15      SDL_SCANCODE_MINUS, /* AKEYCODE_MINUS */
    1.16      SDL_SCANCODE_EQUALS, /* AKEYCODE_EQUALS */
    1.17 @@ -115,7 +115,7 @@
    1.18      SDL_SCANCODE_BACKSLASH, /* AKEYCODE_BACKSLASH */
    1.19      SDL_SCANCODE_SEMICOLON, /* AKEYCODE_SEMICOLON */
    1.20      SDL_SCANCODE_APOSTROPHE, /* AKEYCODE_APOSTROPHE */
    1.21 -    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SLASH */
    1.22 +    SDL_SCANCODE_SLASH, /* AKEYCODE_SLASH */
    1.23      SDL_SCANCODE_UNKNOWN, /* AKEYCODE_AT */
    1.24      SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NUM */
    1.25      SDL_SCANCODE_UNKNOWN, /* AKEYCODE_HEADSETHOOK */
    1.26 @@ -150,6 +150,115 @@
    1.27      SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_START */
    1.28      SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_SELECT */
    1.29      SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_MODE */
    1.30 +    SDL_SCANCODE_ESCAPE, /* AKEYCODE_ESCAPE */
    1.31 +    SDL_SCANCODE_DELETE, /* AKEYCODE_FORWARD_DEL */
    1.32 +    SDL_SCANCODE_LCTRL, /* AKEYCODE_CTRL_LEFT */
    1.33 +    SDL_SCANCODE_RCTRL, /* AKEYCODE_CTRL_RIGHT */
    1.34 +    SDL_SCANCODE_CAPSLOCK, /* AKEYCODE_CAPS_LOCK */
    1.35 +    SDL_SCANCODE_SCROLLLOCK, /* AKEYCODE_SCROLL_LOCK */
    1.36 +    SDL_SCANCODE_LGUI, /* AKEYCODE_META_LEFT */
    1.37 +    SDL_SCANCODE_RGUI, /* AKEYCODE_META_RIGHT */
    1.38 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_FUNCTION */
    1.39 +    SDL_SCANCODE_PRINTSCREEN, /* AKEYCODE_SYSRQ */
    1.40 +    SDL_SCANCODE_PAUSE, /* AKEYCODE_BREAK */
    1.41 +    SDL_SCANCODE_HOME, /* AKEYCODE_MOVE_HOME */
    1.42 +    SDL_SCANCODE_END, /* AKEYCODE_MOVE_END */
    1.43 +    SDL_SCANCODE_INSERT, /* AKEYCODE_INSERT */
    1.44 +    SDL_SCANCODE_AC_FORWARD, /* AKEYCODE_FORWARD */
    1.45 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_PLAY */
    1.46 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_PAUSE */
    1.47 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_CLOSE */
    1.48 +    SDL_SCANCODE_EJECT, /* AKEYCODE_MEDIA_EJECT */
    1.49 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_RECORD */
    1.50 +    SDL_SCANCODE_F1, /* AKEYCODE_F1 */
    1.51 +    SDL_SCANCODE_F2, /* AKEYCODE_F2 */
    1.52 +    SDL_SCANCODE_F3, /* AKEYCODE_F3 */
    1.53 +    SDL_SCANCODE_F4, /* AKEYCODE_F4 */
    1.54 +    SDL_SCANCODE_F5, /* AKEYCODE_F5 */
    1.55 +    SDL_SCANCODE_F6, /* AKEYCODE_F6 */
    1.56 +    SDL_SCANCODE_F7, /* AKEYCODE_F7 */
    1.57 +    SDL_SCANCODE_F8, /* AKEYCODE_F8 */
    1.58 +    SDL_SCANCODE_F9, /* AKEYCODE_F9 */
    1.59 +    SDL_SCANCODE_F10, /* AKEYCODE_F10 */
    1.60 +    SDL_SCANCODE_F11, /* AKEYCODE_F11 */
    1.61 +    SDL_SCANCODE_F12, /* AKEYCODE_F12 */
    1.62 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NUM_LOCK */
    1.63 +    SDL_SCANCODE_KP_0, /* AKEYCODE_NUMPAD_0 */
    1.64 +    SDL_SCANCODE_KP_1, /* AKEYCODE_NUMPAD_1 */
    1.65 +    SDL_SCANCODE_KP_2, /* AKEYCODE_NUMPAD_2 */
    1.66 +    SDL_SCANCODE_KP_3, /* AKEYCODE_NUMPAD_3 */
    1.67 +    SDL_SCANCODE_KP_4, /* AKEYCODE_NUMPAD_4 */
    1.68 +    SDL_SCANCODE_KP_5, /* AKEYCODE_NUMPAD_5 */
    1.69 +    SDL_SCANCODE_KP_6, /* AKEYCODE_NUMPAD_6 */
    1.70 +    SDL_SCANCODE_KP_7, /* AKEYCODE_NUMPAD_7 */
    1.71 +    SDL_SCANCODE_KP_8, /* AKEYCODE_NUMPAD_8 */
    1.72 +    SDL_SCANCODE_KP_9, /* AKEYCODE_NUMPAD_9 */
    1.73 +    SDL_SCANCODE_KP_DIVIDE, /* AKEYCODE_NUMPAD_DIVIDE */
    1.74 +    SDL_SCANCODE_KP_MULTIPLY, /* AKEYCODE_NUMPAD_MULTIPLY */
    1.75 +    SDL_SCANCODE_KP_MINUS, /* AKEYCODE_NUMPAD_SUBTRACT */
    1.76 +    SDL_SCANCODE_KP_PLUS, /* AKEYCODE_NUMPAD_ADD */
    1.77 +    SDL_SCANCODE_KP_PERIOD, /* AKEYCODE_NUMPAD_DOT */
    1.78 +    SDL_SCANCODE_KP_COMMA, /* AKEYCODE_NUMPAD_COMMA */
    1.79 +    SDL_SCANCODE_KP_ENTER, /* AKEYCODE_NUMPAD_ENTER */
    1.80 +    SDL_SCANCODE_KP_EQUALS, /* AKEYCODE_NUMPAD_EQUALS */
    1.81 +    SDL_SCANCODE_KP_LEFTPAREN, /* AKEYCODE_NUMPAD_LEFT_PAREN */
    1.82 +    SDL_SCANCODE_KP_RIGHTPAREN, /* AKEYCODE_NUMPAD_RIGHT_PAREN */
    1.83 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_VOLUME_MUTE */
    1.84 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_INFO */
    1.85 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CHANNEL_UP */
    1.86 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CHANNEL_DOWN */
    1.87 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ZOOM_IN */
    1.88 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ZOOM_OUT */
    1.89 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV */
    1.90 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_WINDOW */
    1.91 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_GUIDE */
    1.92 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_DVR */
    1.93 +    SDL_SCANCODE_AC_BOOKMARKS, /* AKEYCODE_BOOKMARK */
    1.94 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CAPTIONS */
    1.95 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SETTINGS */
    1.96 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_POWER */
    1.97 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT */
    1.98 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STB_POWER */
    1.99 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STB_INPUT */
   1.100 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_AVR_POWER */
   1.101 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_AVR_INPUT */
   1.102 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PROG_RED */
   1.103 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PROG_GREEN */
   1.104 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PROG_YELLOW */
   1.105 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PROG_BLUE */
   1.106 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_APP_SWITCH */
   1.107 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_1 */
   1.108 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_2 */
   1.109 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_3 */
   1.110 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_4 */
   1.111 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_5 */
   1.112 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_6 */
   1.113 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_7 */
   1.114 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_8 */
   1.115 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_9 */
   1.116 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_10 */
   1.117 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_11 */
   1.118 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_12 */
   1.119 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_13 */
   1.120 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_14 */
   1.121 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_15 */
   1.122 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_16 */
   1.123 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_LANGUAGE_SWITCH */
   1.124 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MANNER_MODE */
   1.125 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_3D_MODE */
   1.126 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CONTACTS */
   1.127 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CALENDAR */
   1.128 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MUSIC */
   1.129 +    SDL_SCANCODE_CALCULATOR, /* AKEYCODE_CALCULATOR */
   1.130 +    SDL_SCANCODE_LANG5, /* AKEYCODE_ZENKAKU_HANKAKU */
   1.131 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_EISU */
   1.132 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MUHENKAN */
   1.133 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_HENKAN */
   1.134 +    SDL_SCANCODE_LANG3, /* AKEYCODE_KATAKANA_HIRAGANA */
   1.135 +    SDL_SCANCODE_INTERNATIONAL3, /* AKEYCODE_YEN */
   1.136 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_RO */
   1.137 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_KANA */
   1.138 +    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ASSIST */
   1.139  };
   1.140  
   1.141  static SDL_Scancode