src/video/android/SDL_androidkeyboard.c
author Sam Lantinga <slouken@libsdl.org>
Wed, 03 Jan 2018 10:03:25 -0800
changeset 11811 5d94cb6b24d3
parent 11271 ab3f2402a777
child 12503 806492103856
permissions -rw-r--r--
Updated copyright for 2018
slouken@4980
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@11811
     3
  Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
slouken@4980
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@4980
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@4980
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@4980
    20
*/
icculus@8093
    21
#include "../../SDL_internal.h"
slouken@4980
    22
slouken@6044
    23
#if SDL_VIDEO_DRIVER_ANDROID
slouken@6044
    24
slouken@4993
    25
#include <android/log.h>
slouken@4993
    26
slouken@4980
    27
#include "../../events/SDL_events_c.h"
slouken@4980
    28
slouken@4980
    29
#include "SDL_androidkeyboard.h"
slouken@4980
    30
philipp@7163
    31
#include "../../core/android/SDL_android.h"
slouken@4980
    32
philipp@7177
    33
void Android_InitKeyboard(void)
slouken@4980
    34
{
slouken@5220
    35
    SDL_Keycode keymap[SDL_NUM_SCANCODES];
slouken@4980
    36
slouken@4980
    37
    /* Add default scancode to key mapping */
slouken@4980
    38
    SDL_GetDefaultKeymap(keymap);
slouken@4980
    39
    SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
slouken@4980
    40
}
slouken@4980
    41
slouken@5218
    42
static SDL_Scancode Android_Keycodes[] = {
slouken@4993
    43
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_UNKNOWN */
slouken@4993
    44
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SOFT_LEFT */
slouken@4993
    45
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SOFT_RIGHT */
slouken@4993
    46
    SDL_SCANCODE_AC_HOME, /* AKEYCODE_HOME */
slouken@4993
    47
    SDL_SCANCODE_AC_BACK, /* AKEYCODE_BACK */
slouken@4993
    48
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CALL */
slouken@4993
    49
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ENDCALL */
slouken@4993
    50
    SDL_SCANCODE_0, /* AKEYCODE_0 */
slouken@4993
    51
    SDL_SCANCODE_1, /* AKEYCODE_1 */
slouken@4993
    52
    SDL_SCANCODE_2, /* AKEYCODE_2 */
slouken@4993
    53
    SDL_SCANCODE_3, /* AKEYCODE_3 */
slouken@4993
    54
    SDL_SCANCODE_4, /* AKEYCODE_4 */
slouken@4993
    55
    SDL_SCANCODE_5, /* AKEYCODE_5 */
slouken@4993
    56
    SDL_SCANCODE_6, /* AKEYCODE_6 */
slouken@4993
    57
    SDL_SCANCODE_7, /* AKEYCODE_7 */
slouken@4993
    58
    SDL_SCANCODE_8, /* AKEYCODE_8 */
slouken@4993
    59
    SDL_SCANCODE_9, /* AKEYCODE_9 */
slouken@4993
    60
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STAR */
slouken@4993
    61
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_POUND */
slouken@4993
    62
    SDL_SCANCODE_UP, /* AKEYCODE_DPAD_UP */
slouken@4993
    63
    SDL_SCANCODE_DOWN, /* AKEYCODE_DPAD_DOWN */
slouken@4993
    64
    SDL_SCANCODE_LEFT, /* AKEYCODE_DPAD_LEFT */
slouken@4993
    65
    SDL_SCANCODE_RIGHT, /* AKEYCODE_DPAD_RIGHT */
slouken@4993
    66
    SDL_SCANCODE_SELECT, /* AKEYCODE_DPAD_CENTER */
slouken@4993
    67
    SDL_SCANCODE_VOLUMEUP, /* AKEYCODE_VOLUME_UP */
slouken@4993
    68
    SDL_SCANCODE_VOLUMEDOWN, /* AKEYCODE_VOLUME_DOWN */
slouken@4993
    69
    SDL_SCANCODE_POWER, /* AKEYCODE_POWER */
slouken@4993
    70
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CAMERA */
slouken@4993
    71
    SDL_SCANCODE_CLEAR, /* AKEYCODE_CLEAR */
slouken@4993
    72
    SDL_SCANCODE_A, /* AKEYCODE_A */
slouken@4993
    73
    SDL_SCANCODE_B, /* AKEYCODE_B */
slouken@4993
    74
    SDL_SCANCODE_C, /* AKEYCODE_C */
slouken@4993
    75
    SDL_SCANCODE_D, /* AKEYCODE_D */
slouken@4993
    76
    SDL_SCANCODE_E, /* AKEYCODE_E */
slouken@4993
    77
    SDL_SCANCODE_F, /* AKEYCODE_F */
slouken@4993
    78
    SDL_SCANCODE_G, /* AKEYCODE_G */
slouken@4993
    79
    SDL_SCANCODE_H, /* AKEYCODE_H */
slouken@4993
    80
    SDL_SCANCODE_I, /* AKEYCODE_I */
slouken@4993
    81
    SDL_SCANCODE_J, /* AKEYCODE_J */
slouken@4993
    82
    SDL_SCANCODE_K, /* AKEYCODE_K */
slouken@4993
    83
    SDL_SCANCODE_L, /* AKEYCODE_L */
slouken@4993
    84
    SDL_SCANCODE_M, /* AKEYCODE_M */
slouken@4993
    85
    SDL_SCANCODE_N, /* AKEYCODE_N */
slouken@4993
    86
    SDL_SCANCODE_O, /* AKEYCODE_O */
slouken@4993
    87
    SDL_SCANCODE_P, /* AKEYCODE_P */
slouken@4993
    88
    SDL_SCANCODE_Q, /* AKEYCODE_Q */
slouken@4993
    89
    SDL_SCANCODE_R, /* AKEYCODE_R */
slouken@4993
    90
    SDL_SCANCODE_S, /* AKEYCODE_S */
slouken@4993
    91
    SDL_SCANCODE_T, /* AKEYCODE_T */
slouken@4993
    92
    SDL_SCANCODE_U, /* AKEYCODE_U */
slouken@4993
    93
    SDL_SCANCODE_V, /* AKEYCODE_V */
slouken@4993
    94
    SDL_SCANCODE_W, /* AKEYCODE_W */
slouken@4993
    95
    SDL_SCANCODE_X, /* AKEYCODE_X */
slouken@4993
    96
    SDL_SCANCODE_Y, /* AKEYCODE_Y */
slouken@4993
    97
    SDL_SCANCODE_Z, /* AKEYCODE_Z */
slouken@4993
    98
    SDL_SCANCODE_COMMA, /* AKEYCODE_COMMA */
slouken@4993
    99
    SDL_SCANCODE_PERIOD, /* AKEYCODE_PERIOD */
slouken@4993
   100
    SDL_SCANCODE_LALT, /* AKEYCODE_ALT_LEFT */
slouken@4993
   101
    SDL_SCANCODE_RALT, /* AKEYCODE_ALT_RIGHT */
slouken@4993
   102
    SDL_SCANCODE_LSHIFT, /* AKEYCODE_SHIFT_LEFT */
slouken@4993
   103
    SDL_SCANCODE_RSHIFT, /* AKEYCODE_SHIFT_RIGHT */
slouken@4993
   104
    SDL_SCANCODE_TAB, /* AKEYCODE_TAB */
slouken@4993
   105
    SDL_SCANCODE_SPACE, /* AKEYCODE_SPACE */
slouken@4993
   106
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SYM */
slouken@6465
   107
    SDL_SCANCODE_WWW, /* AKEYCODE_EXPLORER */
slouken@6465
   108
    SDL_SCANCODE_MAIL, /* AKEYCODE_ENVELOPE */
slouken@4993
   109
    SDL_SCANCODE_RETURN, /* AKEYCODE_ENTER */
slouken@6465
   110
    SDL_SCANCODE_BACKSPACE, /* AKEYCODE_DEL */
slouken@4993
   111
    SDL_SCANCODE_GRAVE, /* AKEYCODE_GRAVE */
slouken@4993
   112
    SDL_SCANCODE_MINUS, /* AKEYCODE_MINUS */
slouken@4993
   113
    SDL_SCANCODE_EQUALS, /* AKEYCODE_EQUALS */
slouken@4993
   114
    SDL_SCANCODE_LEFTBRACKET, /* AKEYCODE_LEFT_BRACKET */
slouken@4993
   115
    SDL_SCANCODE_RIGHTBRACKET, /* AKEYCODE_RIGHT_BRACKET */
slouken@4993
   116
    SDL_SCANCODE_BACKSLASH, /* AKEYCODE_BACKSLASH */
slouken@4993
   117
    SDL_SCANCODE_SEMICOLON, /* AKEYCODE_SEMICOLON */
slouken@4993
   118
    SDL_SCANCODE_APOSTROPHE, /* AKEYCODE_APOSTROPHE */
slouken@6465
   119
    SDL_SCANCODE_SLASH, /* AKEYCODE_SLASH */
slouken@4993
   120
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_AT */
slouken@4993
   121
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NUM */
slouken@4993
   122
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_HEADSETHOOK */
slouken@4993
   123
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_FOCUS */
slouken@4993
   124
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PLUS */
slouken@4993
   125
    SDL_SCANCODE_MENU, /* AKEYCODE_MENU */
slouken@4993
   126
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NOTIFICATION */
slouken@4993
   127
    SDL_SCANCODE_AC_SEARCH, /* AKEYCODE_SEARCH */
slouken@4993
   128
    SDL_SCANCODE_AUDIOPLAY, /* AKEYCODE_MEDIA_PLAY_PAUSE */
slouken@4993
   129
    SDL_SCANCODE_AUDIOSTOP, /* AKEYCODE_MEDIA_STOP */
slouken@4993
   130
    SDL_SCANCODE_AUDIONEXT, /* AKEYCODE_MEDIA_NEXT */
slouken@4993
   131
    SDL_SCANCODE_AUDIOPREV, /* AKEYCODE_MEDIA_PREVIOUS */
slouken@11149
   132
    SDL_SCANCODE_AUDIOREWIND, /* AKEYCODE_MEDIA_REWIND */
slouken@11149
   133
    SDL_SCANCODE_AUDIOFASTFORWARD, /* AKEYCODE_MEDIA_FAST_FORWARD */
slouken@4993
   134
    SDL_SCANCODE_MUTE, /* AKEYCODE_MUTE */
slouken@4993
   135
    SDL_SCANCODE_PAGEUP, /* AKEYCODE_PAGE_UP */
slouken@4993
   136
    SDL_SCANCODE_PAGEDOWN, /* AKEYCODE_PAGE_DOWN */
slouken@4993
   137
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PICTSYMBOLS */
slouken@4993
   138
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SWITCH_CHARSET */
slouken@4993
   139
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_A */
slouken@4993
   140
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_B */
slouken@4993
   141
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_C */
slouken@4993
   142
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_X */
slouken@4993
   143
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_Y */
slouken@4993
   144
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_Z */
slouken@4993
   145
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_L1 */
slouken@4993
   146
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_R1 */
slouken@4993
   147
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_L2 */
slouken@4993
   148
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_R2 */
slouken@4993
   149
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_THUMBL */
slouken@4993
   150
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_THUMBR */
slouken@4993
   151
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_START */
slouken@4993
   152
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_SELECT */
slouken@4993
   153
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_MODE */
slouken@6465
   154
    SDL_SCANCODE_ESCAPE, /* AKEYCODE_ESCAPE */
slouken@6465
   155
    SDL_SCANCODE_DELETE, /* AKEYCODE_FORWARD_DEL */
slouken@6465
   156
    SDL_SCANCODE_LCTRL, /* AKEYCODE_CTRL_LEFT */
slouken@6465
   157
    SDL_SCANCODE_RCTRL, /* AKEYCODE_CTRL_RIGHT */
slouken@6465
   158
    SDL_SCANCODE_CAPSLOCK, /* AKEYCODE_CAPS_LOCK */
slouken@6465
   159
    SDL_SCANCODE_SCROLLLOCK, /* AKEYCODE_SCROLL_LOCK */
slouken@6465
   160
    SDL_SCANCODE_LGUI, /* AKEYCODE_META_LEFT */
slouken@6465
   161
    SDL_SCANCODE_RGUI, /* AKEYCODE_META_RIGHT */
slouken@6465
   162
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_FUNCTION */
slouken@6465
   163
    SDL_SCANCODE_PRINTSCREEN, /* AKEYCODE_SYSRQ */
slouken@6465
   164
    SDL_SCANCODE_PAUSE, /* AKEYCODE_BREAK */
slouken@6465
   165
    SDL_SCANCODE_HOME, /* AKEYCODE_MOVE_HOME */
slouken@6465
   166
    SDL_SCANCODE_END, /* AKEYCODE_MOVE_END */
slouken@6465
   167
    SDL_SCANCODE_INSERT, /* AKEYCODE_INSERT */
slouken@6465
   168
    SDL_SCANCODE_AC_FORWARD, /* AKEYCODE_FORWARD */
slouken@6465
   169
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_PLAY */
slouken@6465
   170
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_PAUSE */
slouken@6465
   171
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_CLOSE */
slouken@6465
   172
    SDL_SCANCODE_EJECT, /* AKEYCODE_MEDIA_EJECT */
slouken@6465
   173
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_RECORD */
slouken@6465
   174
    SDL_SCANCODE_F1, /* AKEYCODE_F1 */
slouken@6465
   175
    SDL_SCANCODE_F2, /* AKEYCODE_F2 */
slouken@6465
   176
    SDL_SCANCODE_F3, /* AKEYCODE_F3 */
slouken@6465
   177
    SDL_SCANCODE_F4, /* AKEYCODE_F4 */
slouken@6465
   178
    SDL_SCANCODE_F5, /* AKEYCODE_F5 */
slouken@6465
   179
    SDL_SCANCODE_F6, /* AKEYCODE_F6 */
slouken@6465
   180
    SDL_SCANCODE_F7, /* AKEYCODE_F7 */
slouken@6465
   181
    SDL_SCANCODE_F8, /* AKEYCODE_F8 */
slouken@6465
   182
    SDL_SCANCODE_F9, /* AKEYCODE_F9 */
slouken@6465
   183
    SDL_SCANCODE_F10, /* AKEYCODE_F10 */
slouken@6465
   184
    SDL_SCANCODE_F11, /* AKEYCODE_F11 */
slouken@6465
   185
    SDL_SCANCODE_F12, /* AKEYCODE_F12 */
slouken@6465
   186
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NUM_LOCK */
slouken@6465
   187
    SDL_SCANCODE_KP_0, /* AKEYCODE_NUMPAD_0 */
slouken@6465
   188
    SDL_SCANCODE_KP_1, /* AKEYCODE_NUMPAD_1 */
slouken@6465
   189
    SDL_SCANCODE_KP_2, /* AKEYCODE_NUMPAD_2 */
slouken@6465
   190
    SDL_SCANCODE_KP_3, /* AKEYCODE_NUMPAD_3 */
slouken@6465
   191
    SDL_SCANCODE_KP_4, /* AKEYCODE_NUMPAD_4 */
slouken@6465
   192
    SDL_SCANCODE_KP_5, /* AKEYCODE_NUMPAD_5 */
slouken@6465
   193
    SDL_SCANCODE_KP_6, /* AKEYCODE_NUMPAD_6 */
slouken@6465
   194
    SDL_SCANCODE_KP_7, /* AKEYCODE_NUMPAD_7 */
slouken@6465
   195
    SDL_SCANCODE_KP_8, /* AKEYCODE_NUMPAD_8 */
slouken@6465
   196
    SDL_SCANCODE_KP_9, /* AKEYCODE_NUMPAD_9 */
slouken@6465
   197
    SDL_SCANCODE_KP_DIVIDE, /* AKEYCODE_NUMPAD_DIVIDE */
slouken@6465
   198
    SDL_SCANCODE_KP_MULTIPLY, /* AKEYCODE_NUMPAD_MULTIPLY */
slouken@6465
   199
    SDL_SCANCODE_KP_MINUS, /* AKEYCODE_NUMPAD_SUBTRACT */
slouken@6465
   200
    SDL_SCANCODE_KP_PLUS, /* AKEYCODE_NUMPAD_ADD */
slouken@6465
   201
    SDL_SCANCODE_KP_PERIOD, /* AKEYCODE_NUMPAD_DOT */
slouken@6465
   202
    SDL_SCANCODE_KP_COMMA, /* AKEYCODE_NUMPAD_COMMA */
slouken@6465
   203
    SDL_SCANCODE_KP_ENTER, /* AKEYCODE_NUMPAD_ENTER */
slouken@6465
   204
    SDL_SCANCODE_KP_EQUALS, /* AKEYCODE_NUMPAD_EQUALS */
slouken@6465
   205
    SDL_SCANCODE_KP_LEFTPAREN, /* AKEYCODE_NUMPAD_LEFT_PAREN */
slouken@6465
   206
    SDL_SCANCODE_KP_RIGHTPAREN, /* AKEYCODE_NUMPAD_RIGHT_PAREN */
slouken@6465
   207
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_VOLUME_MUTE */
slouken@6465
   208
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_INFO */
slouken@6465
   209
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CHANNEL_UP */
slouken@6465
   210
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CHANNEL_DOWN */
slouken@6465
   211
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ZOOM_IN */
slouken@6465
   212
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ZOOM_OUT */
slouken@6465
   213
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV */
slouken@6465
   214
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_WINDOW */
slouken@6465
   215
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_GUIDE */
slouken@6465
   216
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_DVR */
slouken@6465
   217
    SDL_SCANCODE_AC_BOOKMARKS, /* AKEYCODE_BOOKMARK */
slouken@6465
   218
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CAPTIONS */
slouken@6465
   219
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SETTINGS */
slouken@6465
   220
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_POWER */
slouken@6465
   221
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT */
slouken@6465
   222
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STB_POWER */
slouken@6465
   223
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STB_INPUT */
slouken@6465
   224
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_AVR_POWER */
slouken@6465
   225
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_AVR_INPUT */
slouken@6465
   226
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PROG_RED */
slouken@6465
   227
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PROG_GREEN */
slouken@6465
   228
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PROG_YELLOW */
slouken@6465
   229
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PROG_BLUE */
slouken@6465
   230
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_APP_SWITCH */
slouken@6465
   231
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_1 */
slouken@6465
   232
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_2 */
slouken@6465
   233
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_3 */
slouken@6465
   234
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_4 */
slouken@6465
   235
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_5 */
slouken@6465
   236
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_6 */
slouken@6465
   237
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_7 */
slouken@6465
   238
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_8 */
slouken@6465
   239
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_9 */
slouken@6465
   240
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_10 */
slouken@6465
   241
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_11 */
slouken@6465
   242
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_12 */
slouken@6465
   243
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_13 */
slouken@6465
   244
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_14 */
slouken@6465
   245
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_15 */
slouken@6465
   246
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_16 */
slouken@6465
   247
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_LANGUAGE_SWITCH */
slouken@6465
   248
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MANNER_MODE */
slouken@6465
   249
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_3D_MODE */
slouken@6465
   250
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CONTACTS */
slouken@6465
   251
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CALENDAR */
slouken@6465
   252
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MUSIC */
slouken@6465
   253
    SDL_SCANCODE_CALCULATOR, /* AKEYCODE_CALCULATOR */
slouken@6465
   254
    SDL_SCANCODE_LANG5, /* AKEYCODE_ZENKAKU_HANKAKU */
slouken@6465
   255
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_EISU */
philipp@9689
   256
    SDL_SCANCODE_INTERNATIONAL5, /* AKEYCODE_MUHENKAN */
philipp@9689
   257
    SDL_SCANCODE_INTERNATIONAL4, /* AKEYCODE_HENKAN */
slouken@6465
   258
    SDL_SCANCODE_LANG3, /* AKEYCODE_KATAKANA_HIRAGANA */
slouken@6465
   259
    SDL_SCANCODE_INTERNATIONAL3, /* AKEYCODE_YEN */
slouken@6465
   260
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_RO */
slouken@6465
   261
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_KANA */
slouken@6465
   262
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ASSIST */
philipp@7548
   263
    SDL_SCANCODE_BRIGHTNESSDOWN, /* AKEYCODE_BRIGHTNESS_DOWN */
philipp@7548
   264
    SDL_SCANCODE_BRIGHTNESSUP, /* AKEYCODE_BRIGHTNESS_UP */
philipp@7931
   265
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_AUDIO_TRACK */
philipp@9187
   266
    SDL_SCANCODE_SLEEP, /* AKEYCODE_SLEEP */
philipp@9187
   267
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_WAKEUP */
philipp@9187
   268
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PAIRING */
philipp@9187
   269
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_TOP_MENU */
philipp@9187
   270
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_11 */
philipp@9187
   271
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_12 */
philipp@9187
   272
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_LAST_CHANNEL */
philipp@9187
   273
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_DATA_SERVICE */
philipp@9187
   274
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_VOICE_ASSIST */
philipp@9187
   275
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_RADIO_SERVICE */
philipp@9187
   276
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_TELETEXT */
philipp@9187
   277
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_NUMBER_ENTRY */
philipp@9187
   278
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_TERRESTRIAL_ANALOG */
philipp@9187
   279
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_TERRESTRIAL_DIGITAL */
philipp@9187
   280
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_SATELLITE */
philipp@9187
   281
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_SATELLITE_BS */
philipp@9187
   282
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_SATELLITE_CS */
philipp@9187
   283
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_SATELLITE_SERVICE */
philipp@9187
   284
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_NETWORK */
philipp@9187
   285
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_ANTENNA_CABLE */
philipp@9187
   286
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_HDMI_1 */
philipp@9187
   287
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_HDMI_2 */
philipp@9187
   288
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_HDMI_3 */
philipp@9187
   289
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_HDMI_4 */
philipp@9187
   290
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_COMPOSITE_1 */
philipp@9187
   291
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_COMPOSITE_2 */
philipp@9187
   292
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_COMPONENT_1 */
philipp@9187
   293
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_COMPONENT_2 */
philipp@9187
   294
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_INPUT_VGA_1 */
philipp@9187
   295
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_AUDIO_DESCRIPTION */
philipp@9187
   296
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP */
philipp@9187
   297
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN */
philipp@9187
   298
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_ZOOM_MODE */
philipp@9187
   299
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_CONTENTS_MENU */
philipp@9187
   300
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_MEDIA_CONTEXT_MENU */
philipp@9187
   301
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_TV_TIMER_PROGRAMMING */
philipp@9187
   302
    SDL_SCANCODE_HELP, /* AKEYCODE_HELP */
philipp@9890
   303
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NAVIGATE_PREVIOUS */
philipp@9890
   304
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NAVIGATE_NEXT */
philipp@9890
   305
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NAVIGATE_IN */
philipp@9890
   306
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NAVIGATE_OUT */
philipp@10191
   307
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STEM_PRIMARY */
philipp@10191
   308
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STEM_1 */
philipp@10191
   309
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STEM_2 */
philipp@10191
   310
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STEM_3 */
philipp@10191
   311
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_DPAD_UP_LEFT */
philipp@10191
   312
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_DPAD_DOWN_LEFT */
philipp@10191
   313
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_DPAD_UP_RIGHT */
philipp@10191
   314
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_DPAD_DOWN_RIGHT */
philipp@9890
   315
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_SKIP_FORWARD */
philipp@9890
   316
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_SKIP_BACKWARD */
philipp@9890
   317
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_STEP_FORWARD */
philipp@9890
   318
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_STEP_BACKWARD */
philipp@10191
   319
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SOFT_SLEEP */
philipp@10191
   320
    SDL_SCANCODE_CUT, /* AKEYCODE_CUT */
philipp@10191
   321
    SDL_SCANCODE_COPY, /* AKEYCODE_COPY */
philipp@10191
   322
    SDL_SCANCODE_PASTE, /* AKEYCODE_PASTE */
slouken@4993
   323
};
slouken@4993
   324
slouken@5218
   325
static SDL_Scancode
slouken@4993
   326
TranslateKeycode(int keycode)
slouken@4993
   327
{
slouken@5218
   328
    SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN;
slouken@4993
   329
slouken@4993
   330
    if (keycode < SDL_arraysize(Android_Keycodes)) {
slouken@4993
   331
        scancode = Android_Keycodes[keycode];
slouken@4993
   332
    }
slouken@4993
   333
    if (scancode == SDL_SCANCODE_UNKNOWN) {
slouken@4993
   334
        __android_log_print(ANDROID_LOG_INFO, "SDL", "Unknown keycode %d", keycode);
slouken@4993
   335
    }
slouken@4993
   336
    return scancode;
slouken@4993
   337
}
slouken@4993
   338
slouken@4980
   339
int
slouken@4980
   340
Android_OnKeyDown(int keycode)
slouken@4980
   341
{
slouken@4993
   342
    return SDL_SendKeyboardKey(SDL_PRESSED, TranslateKeycode(keycode));
slouken@4980
   343
}
slouken@4980
   344
slouken@4980
   345
int
slouken@4980
   346
Android_OnKeyUp(int keycode)
slouken@4980
   347
{
slouken@4993
   348
    return SDL_SendKeyboardKey(SDL_RELEASED, TranslateKeycode(keycode));
slouken@4980
   349
}
slouken@4980
   350
slouken@6392
   351
SDL_bool
slouken@6654
   352
Android_HasScreenKeyboardSupport(_THIS)
slouken@6392
   353
{
slouken@6654
   354
    return SDL_TRUE;
slouken@6392
   355
}
slouken@6392
   356
slouken@6392
   357
SDL_bool
slouken@6392
   358
Android_IsScreenKeyboardShown(_THIS, SDL_Window * window)
slouken@6392
   359
{
slouken@11271
   360
    return Android_JNI_IsScreenKeyboardShown();
slouken@6392
   361
}
slouken@6392
   362
slouken@6555
   363
void
slouken@6555
   364
Android_StartTextInput(_THIS)
slouken@6555
   365
{
slouken@6555
   366
    SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
slouken@6555
   367
    Android_JNI_ShowTextInput(&videodata->textRect);
slouken@6555
   368
}
slouken@6555
   369
slouken@6555
   370
void
slouken@6555
   371
Android_StopTextInput(_THIS)
slouken@6555
   372
{
slouken@6654
   373
    Android_JNI_HideTextInput();
slouken@6555
   374
}
slouken@6555
   375
slouken@6555
   376
void
slouken@6555
   377
Android_SetTextInputRect(_THIS, SDL_Rect *rect)
slouken@6555
   378
{
slouken@6555
   379
    SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
aschiffler@6808
   380
aschiffler@6808
   381
    if (!rect) {
aschiffler@6811
   382
        SDL_InvalidParamError("rect");
aschiffler@6808
   383
        return;
aschiffler@6808
   384
    }
slouken@7191
   385
slouken@6555
   386
    videodata->textRect = *rect;
slouken@6555
   387
}
slouken@6555
   388
slouken@6044
   389
#endif /* SDL_VIDEO_DRIVER_ANDROID */
slouken@6044
   390
slouken@4980
   391
/* vi: set ts=4 sw=4 expandtab: */