annotate src/video/android/SDL_androidkeyboard.c @ 5092:327f181542f1

Include windows.h in a single point in the source, so we can be consistent about the definition of UNICODE and have core utility functions for Windows that all modules can share. I think this also fixes the bug relating to non-latin characters in filenames, since UNICODE wasn't defined in SDL_rwops.c
author Sam Lantinga <slouken@libsdl.org>
date Mon, 24 Jan 2011 21:20:30 -0800
parents 25d4feb7c127
children 572a73d71b5f
rev   line source
4980
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 Copyright (C) 1997-2010 Sam Lantinga
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Lesser General Public License for more details.
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 #include "SDL_config.h"
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23
4993
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
24 #include <android/log.h>
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
25
4980
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 #include "../../events/SDL_events_c.h"
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 #include "SDL_androidkeyboard.h"
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 void Android_InitKeyboard()
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 {
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 SDLKey keymap[SDL_NUM_SCANCODES];
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 /* Add default scancode to key mapping */
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 SDL_GetDefaultKeymap(keymap);
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 }
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39
5083
25d4feb7c127 Renamed SDL_keysym to SDL_KeySym
krogoway
parents: 4993
diff changeset
40 static SDL_ScanCode Android_Keycodes[] = {
4993
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
41 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_UNKNOWN */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
42 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SOFT_LEFT */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
43 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SOFT_RIGHT */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
44 SDL_SCANCODE_AC_HOME, /* AKEYCODE_HOME */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
45 SDL_SCANCODE_AC_BACK, /* AKEYCODE_BACK */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
46 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CALL */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
47 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ENDCALL */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
48 SDL_SCANCODE_0, /* AKEYCODE_0 */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
49 SDL_SCANCODE_1, /* AKEYCODE_1 */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
50 SDL_SCANCODE_2, /* AKEYCODE_2 */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
51 SDL_SCANCODE_3, /* AKEYCODE_3 */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
52 SDL_SCANCODE_4, /* AKEYCODE_4 */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
53 SDL_SCANCODE_5, /* AKEYCODE_5 */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
54 SDL_SCANCODE_6, /* AKEYCODE_6 */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
55 SDL_SCANCODE_7, /* AKEYCODE_7 */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
56 SDL_SCANCODE_8, /* AKEYCODE_8 */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
57 SDL_SCANCODE_9, /* AKEYCODE_9 */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
58 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STAR */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
59 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_POUND */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
60 SDL_SCANCODE_UP, /* AKEYCODE_DPAD_UP */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
61 SDL_SCANCODE_DOWN, /* AKEYCODE_DPAD_DOWN */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
62 SDL_SCANCODE_LEFT, /* AKEYCODE_DPAD_LEFT */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
63 SDL_SCANCODE_RIGHT, /* AKEYCODE_DPAD_RIGHT */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
64 SDL_SCANCODE_SELECT, /* AKEYCODE_DPAD_CENTER */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
65 SDL_SCANCODE_VOLUMEUP, /* AKEYCODE_VOLUME_UP */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
66 SDL_SCANCODE_VOLUMEDOWN, /* AKEYCODE_VOLUME_DOWN */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
67 SDL_SCANCODE_POWER, /* AKEYCODE_POWER */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
68 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CAMERA */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
69 SDL_SCANCODE_CLEAR, /* AKEYCODE_CLEAR */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
70 SDL_SCANCODE_A, /* AKEYCODE_A */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
71 SDL_SCANCODE_B, /* AKEYCODE_B */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
72 SDL_SCANCODE_C, /* AKEYCODE_C */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
73 SDL_SCANCODE_D, /* AKEYCODE_D */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
74 SDL_SCANCODE_E, /* AKEYCODE_E */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
75 SDL_SCANCODE_F, /* AKEYCODE_F */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
76 SDL_SCANCODE_G, /* AKEYCODE_G */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
77 SDL_SCANCODE_H, /* AKEYCODE_H */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
78 SDL_SCANCODE_I, /* AKEYCODE_I */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
79 SDL_SCANCODE_J, /* AKEYCODE_J */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
80 SDL_SCANCODE_K, /* AKEYCODE_K */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
81 SDL_SCANCODE_L, /* AKEYCODE_L */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
82 SDL_SCANCODE_M, /* AKEYCODE_M */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
83 SDL_SCANCODE_N, /* AKEYCODE_N */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
84 SDL_SCANCODE_O, /* AKEYCODE_O */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
85 SDL_SCANCODE_P, /* AKEYCODE_P */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
86 SDL_SCANCODE_Q, /* AKEYCODE_Q */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
87 SDL_SCANCODE_R, /* AKEYCODE_R */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
88 SDL_SCANCODE_S, /* AKEYCODE_S */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
89 SDL_SCANCODE_T, /* AKEYCODE_T */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
90 SDL_SCANCODE_U, /* AKEYCODE_U */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
91 SDL_SCANCODE_V, /* AKEYCODE_V */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
92 SDL_SCANCODE_W, /* AKEYCODE_W */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
93 SDL_SCANCODE_X, /* AKEYCODE_X */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
94 SDL_SCANCODE_Y, /* AKEYCODE_Y */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
95 SDL_SCANCODE_Z, /* AKEYCODE_Z */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
96 SDL_SCANCODE_COMMA, /* AKEYCODE_COMMA */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
97 SDL_SCANCODE_PERIOD, /* AKEYCODE_PERIOD */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
98 SDL_SCANCODE_LALT, /* AKEYCODE_ALT_LEFT */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
99 SDL_SCANCODE_RALT, /* AKEYCODE_ALT_RIGHT */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
100 SDL_SCANCODE_LSHIFT, /* AKEYCODE_SHIFT_LEFT */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
101 SDL_SCANCODE_RSHIFT, /* AKEYCODE_SHIFT_RIGHT */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
102 SDL_SCANCODE_TAB, /* AKEYCODE_TAB */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
103 SDL_SCANCODE_SPACE, /* AKEYCODE_SPACE */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
104 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SYM */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
105 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_EXPLORER */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
106 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ENVELOPE */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
107 SDL_SCANCODE_RETURN, /* AKEYCODE_ENTER */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
108 SDL_SCANCODE_DELETE, /* AKEYCODE_DEL */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
109 SDL_SCANCODE_GRAVE, /* AKEYCODE_GRAVE */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
110 SDL_SCANCODE_MINUS, /* AKEYCODE_MINUS */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
111 SDL_SCANCODE_EQUALS, /* AKEYCODE_EQUALS */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
112 SDL_SCANCODE_LEFTBRACKET, /* AKEYCODE_LEFT_BRACKET */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
113 SDL_SCANCODE_RIGHTBRACKET, /* AKEYCODE_RIGHT_BRACKET */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
114 SDL_SCANCODE_BACKSLASH, /* AKEYCODE_BACKSLASH */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
115 SDL_SCANCODE_SEMICOLON, /* AKEYCODE_SEMICOLON */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
116 SDL_SCANCODE_APOSTROPHE, /* AKEYCODE_APOSTROPHE */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
117 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SLASH */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
118 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_AT */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
119 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NUM */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
120 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_HEADSETHOOK */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
121 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_FOCUS */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
122 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PLUS */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
123 SDL_SCANCODE_MENU, /* AKEYCODE_MENU */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
124 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NOTIFICATION */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
125 SDL_SCANCODE_AC_SEARCH, /* AKEYCODE_SEARCH */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
126 SDL_SCANCODE_AUDIOPLAY, /* AKEYCODE_MEDIA_PLAY_PAUSE */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
127 SDL_SCANCODE_AUDIOSTOP, /* AKEYCODE_MEDIA_STOP */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
128 SDL_SCANCODE_AUDIONEXT, /* AKEYCODE_MEDIA_NEXT */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
129 SDL_SCANCODE_AUDIOPREV, /* AKEYCODE_MEDIA_PREVIOUS */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
130 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_REWIND */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
131 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_FAST_FORWARD */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
132 SDL_SCANCODE_MUTE, /* AKEYCODE_MUTE */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
133 SDL_SCANCODE_PAGEUP, /* AKEYCODE_PAGE_UP */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
134 SDL_SCANCODE_PAGEDOWN, /* AKEYCODE_PAGE_DOWN */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
135 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PICTSYMBOLS */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
136 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SWITCH_CHARSET */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
137 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_A */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
138 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_B */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
139 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_C */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
140 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_X */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
141 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_Y */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
142 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_Z */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
143 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_L1 */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
144 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_R1 */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
145 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_L2 */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
146 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_R2 */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
147 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_THUMBL */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
148 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_THUMBR */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
149 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_START */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
150 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_SELECT */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
151 SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_MODE */
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
152 };
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
153
5083
25d4feb7c127 Renamed SDL_keysym to SDL_KeySym
krogoway
parents: 4993
diff changeset
154 static SDL_ScanCode
4993
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
155 TranslateKeycode(int keycode)
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
156 {
5083
25d4feb7c127 Renamed SDL_keysym to SDL_KeySym
krogoway
parents: 4993
diff changeset
157 SDL_ScanCode scancode = SDL_SCANCODE_UNKNOWN;
4993
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
158
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
159 if (keycode < SDL_arraysize(Android_Keycodes)) {
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
160 scancode = Android_Keycodes[keycode];
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
161 }
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
162 if (scancode == SDL_SCANCODE_UNKNOWN) {
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
163 __android_log_print(ANDROID_LOG_INFO, "SDL", "Unknown keycode %d", keycode);
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
164 }
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
165 return scancode;
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
166 }
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
167
4980
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 int
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 Android_OnKeyDown(int keycode)
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 {
4993
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
171 return SDL_SendKeyboardKey(SDL_PRESSED, TranslateKeycode(keycode));
4980
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 }
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 int
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 Android_OnKeyUp(int keycode)
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 {
4993
3c9058f3ffe7 Implemented translation from Android keycodes to SDL scancodes
Sam Lantinga <slouken@libsdl.org>
parents: 4980
diff changeset
177 return SDL_SendKeyboardKey(SDL_RELEASED, TranslateKeycode(keycode));
4980
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 }
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179
d9fdff945ec9 A bit of cleanup in the Android driver
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 /* vi: set ts=4 sw=4 expandtab: */