project_files/Android-build/SDL-android-project/jni/SDL/src/video/android/SDL_androidkeyboard.c
author Wuzzy <almikes@aol.com>
Sat, 30 Sep 2017 23:52:08 +0200
changeset 12627 07fdda8c13a2
parent 6900 26873e68034f
permissions -rwxr-xr-x
TrophyRace: Fix game never eliminating any hogs after a hog skipped or ran out of time Warning: This commit _might_ invalidate past records, but I'm not sure if this is actually the case. Note that only the eliminiation part of the script is touched, not the actual race logic. Even if records are actually broken by this, I and sheepluva have decided that it's more imporant to fix this very, VERY stupid and old bug than to preserve records.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6900
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
     1
/*
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
     2
  Simple DirectMedia Layer
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
     3
  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
     4
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
     5
  This software is provided 'as-is', without any express or implied
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
     7
  arising from the use of this software.
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
     8
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    11
  freely, subject to the following restrictions:
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    12
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    14
     claim that you wrote the original software. If you use this software
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    16
     appreciated but is not required.
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    18
     misrepresented as being the original software.
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    20
*/
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    21
#include "SDL_config.h"
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    22
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    23
#if SDL_VIDEO_DRIVER_ANDROID
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    24
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    25
#include <android/log.h>
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    26
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    27
#include "../../events/SDL_events_c.h"
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    28
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    29
#include "SDL_androidkeyboard.h"
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    30
#include "SDL_keycode.h"
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    31
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    32
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    33
void Android_InitKeyboard()
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    34
{
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    35
    SDL_Keycode keymap[SDL_NUM_SCANCODES];
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    36
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    37
    /* Add default scancode to key mapping */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    38
    SDL_GetDefaultKeymap(keymap);
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    39
    SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    40
}
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    41
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    42
static SDL_Scancode Android_Keycodes[] = {
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    43
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_UNKNOWN */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    44
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SOFT_LEFT */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    45
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SOFT_RIGHT */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    46
    SDL_SCANCODE_AC_HOME, /* AKEYCODE_HOME */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    47
    SDL_SCANCODE_AC_BACK, /* AKEYCODE_BACK */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    48
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CALL */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    49
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ENDCALL */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    50
    SDL_SCANCODE_0, /* AKEYCODE_0 */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    51
    SDL_SCANCODE_1, /* AKEYCODE_1 */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    52
    SDL_SCANCODE_2, /* AKEYCODE_2 */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    53
    SDL_SCANCODE_3, /* AKEYCODE_3 */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    54
    SDL_SCANCODE_4, /* AKEYCODE_4 */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    55
    SDL_SCANCODE_5, /* AKEYCODE_5 */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    56
    SDL_SCANCODE_6, /* AKEYCODE_6 */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    57
    SDL_SCANCODE_7, /* AKEYCODE_7 */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    58
    SDL_SCANCODE_8, /* AKEYCODE_8 */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    59
    SDL_SCANCODE_9, /* AKEYCODE_9 */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    60
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STAR */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    61
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_POUND */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    62
    SDL_SCANCODE_UP, /* AKEYCODE_DPAD_UP */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    63
    SDL_SCANCODE_DOWN, /* AKEYCODE_DPAD_DOWN */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    64
    SDL_SCANCODE_LEFT, /* AKEYCODE_DPAD_LEFT */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    65
    SDL_SCANCODE_RIGHT, /* AKEYCODE_DPAD_RIGHT */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    66
    SDL_SCANCODE_SELECT, /* AKEYCODE_DPAD_CENTER */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    67
    SDL_SCANCODE_VOLUMEUP, /* AKEYCODE_VOLUME_UP */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    68
    SDL_SCANCODE_VOLUMEDOWN, /* AKEYCODE_VOLUME_DOWN */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    69
    SDL_SCANCODE_POWER, /* AKEYCODE_POWER */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    70
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CAMERA */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    71
    SDL_SCANCODE_CLEAR, /* AKEYCODE_CLEAR */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    72
    SDL_SCANCODE_A, /* AKEYCODE_A */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    73
    SDL_SCANCODE_B, /* AKEYCODE_B */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    74
    SDL_SCANCODE_C, /* AKEYCODE_C */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    75
    SDL_SCANCODE_D, /* AKEYCODE_D */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    76
    SDL_SCANCODE_E, /* AKEYCODE_E */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    77
    SDL_SCANCODE_F, /* AKEYCODE_F */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    78
    SDL_SCANCODE_G, /* AKEYCODE_G */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    79
    SDL_SCANCODE_H, /* AKEYCODE_H */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    80
    SDL_SCANCODE_I, /* AKEYCODE_I */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    81
    SDL_SCANCODE_J, /* AKEYCODE_J */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    82
    SDL_SCANCODE_K, /* AKEYCODE_K */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    83
    SDL_SCANCODE_L, /* AKEYCODE_L */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    84
    SDL_SCANCODE_M, /* AKEYCODE_M */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    85
    SDL_SCANCODE_N, /* AKEYCODE_N */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    86
    SDL_SCANCODE_O, /* AKEYCODE_O */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    87
    SDL_SCANCODE_P, /* AKEYCODE_P */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    88
    SDL_SCANCODE_Q, /* AKEYCODE_Q */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    89
    SDL_SCANCODE_R, /* AKEYCODE_R */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    90
    SDL_SCANCODE_S, /* AKEYCODE_S */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    91
    SDL_SCANCODE_T, /* AKEYCODE_T */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    92
    SDL_SCANCODE_U, /* AKEYCODE_U */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    93
    SDL_SCANCODE_V, /* AKEYCODE_V */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    94
    SDL_SCANCODE_W, /* AKEYCODE_W */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    95
    SDL_SCANCODE_X, /* AKEYCODE_X */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    96
    SDL_SCANCODE_Y, /* AKEYCODE_Y */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    97
    SDL_SCANCODE_Z, /* AKEYCODE_Z */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    98
    SDL_SCANCODE_COMMA, /* AKEYCODE_COMMA */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
    99
    SDL_SCANCODE_PERIOD, /* AKEYCODE_PERIOD */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   100
    SDL_SCANCODE_LALT, /* AKEYCODE_ALT_LEFT */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   101
    SDL_SCANCODE_RALT, /* AKEYCODE_ALT_RIGHT */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   102
    SDL_SCANCODE_LSHIFT, /* AKEYCODE_SHIFT_LEFT */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   103
    SDL_SCANCODE_RSHIFT, /* AKEYCODE_SHIFT_RIGHT */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   104
    SDL_SCANCODE_TAB, /* AKEYCODE_TAB */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   105
    SDL_SCANCODE_SPACE, /* AKEYCODE_SPACE */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   106
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SYM */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   107
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_EXPLORER */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   108
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ENVELOPE */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   109
    SDL_SCANCODE_RETURN, /* AKEYCODE_ENTER */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   110
    SDL_SCANCODE_BACKSPACE, /* AKEYCODE_DEL */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   111
    SDL_SCANCODE_GRAVE, /* AKEYCODE_GRAVE */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   112
    SDL_SCANCODE_MINUS, /* AKEYCODE_MINUS */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   113
    SDL_SCANCODE_EQUALS, /* AKEYCODE_EQUALS */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   114
    SDL_SCANCODE_LEFTBRACKET, /* AKEYCODE_LEFT_BRACKET */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   115
    SDL_SCANCODE_RIGHTBRACKET, /* AKEYCODE_RIGHT_BRACKET */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   116
    SDL_SCANCODE_BACKSLASH, /* AKEYCODE_BACKSLASH */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   117
    SDL_SCANCODE_SEMICOLON, /* AKEYCODE_SEMICOLON */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   118
    SDL_SCANCODE_APOSTROPHE, /* AKEYCODE_APOSTROPHE */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   119
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SLASH */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   120
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_AT */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   121
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NUM */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   122
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_HEADSETHOOK */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   123
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_FOCUS */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   124
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PLUS */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   125
    SDL_SCANCODE_MENU, /* AKEYCODE_MENU */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   126
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NOTIFICATION */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   127
    SDL_SCANCODE_AC_SEARCH, /* AKEYCODE_SEARCH */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   128
    SDL_SCANCODE_AUDIOPLAY, /* AKEYCODE_MEDIA_PLAY_PAUSE */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   129
    SDL_SCANCODE_AUDIOSTOP, /* AKEYCODE_MEDIA_STOP */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   130
    SDL_SCANCODE_AUDIONEXT, /* AKEYCODE_MEDIA_NEXT */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   131
    SDL_SCANCODE_AUDIOPREV, /* AKEYCODE_MEDIA_PREVIOUS */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   132
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_REWIND */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   133
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_FAST_FORWARD */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   134
    SDL_SCANCODE_MUTE, /* AKEYCODE_MUTE */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   135
    SDL_SCANCODE_PAGEUP, /* AKEYCODE_PAGE_UP */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   136
    SDL_SCANCODE_PAGEDOWN, /* AKEYCODE_PAGE_DOWN */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   137
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PICTSYMBOLS */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   138
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SWITCH_CHARSET */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   139
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_A */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   140
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_B */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   141
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_C */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   142
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_X */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   143
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_Y */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   144
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_Z */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   145
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_L1 */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   146
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_R1 */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   147
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_L2 */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   148
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_R2 */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   149
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_THUMBL */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   150
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_THUMBR */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   151
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_START */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   152
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_SELECT */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   153
    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_MODE */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   154
};
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   155
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   156
static SDL_Scancode
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   157
TranslateKeycode(int keycode)
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   158
{
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   159
    SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN;
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   160
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   161
    if (keycode < SDL_arraysize(Android_Keycodes)) {
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   162
        scancode = Android_Keycodes[keycode];
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   163
    }
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   164
    if (scancode == SDL_SCANCODE_UNKNOWN) {
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   165
        __android_log_print(ANDROID_LOG_INFO, "SDL", "Unknown keycode %d", keycode);
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   166
    }
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   167
    __android_log_print(ANDROID_LOG_INFO, "SDLXELI", "keycode %d scancode %d", keycode, scancode);
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   168
    return scancode;
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   169
}
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   170
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   171
int
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   172
Android_OnKeyDown(int keycode)
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   173
{
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   174
    return SDL_SendKeyboardKey(SDL_PRESSED, TranslateKeycode(keycode));
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   175
}
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   176
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   177
int
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   178
Android_OnKeyUp(int keycode)
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   179
{
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   180
    return SDL_SendKeyboardKey(SDL_RELEASED, TranslateKeycode(keycode));
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   181
}
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   182
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   183
#endif /* SDL_VIDEO_DRIVER_ANDROID */
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   184
26873e68034f - Added support for keyboards on android
Xeli
parents:
diff changeset
   185
/* vi: set ts=4 sw=4 expandtab: */