--- a/hedgewars/uKeys.pas Sat Apr 21 17:55:45 2012 +0200
+++ b/hedgewars/uKeys.pas Sat Apr 21 17:59:14 2012 +0200
@@ -41,7 +41,7 @@
procedure ControllerButtonEvent(joy, button: Byte; pressed: Boolean);
{$IFDEF MOBILE}
-procedure setiPhoneBinds;
+procedure setTouchWidgetStates;
{$ENDIF}
implementation
@@ -63,7 +63,7 @@
var i, j, k: LongInt;
s: shortstring;
Trusted: boolean;
-{$IFNDEF MOBILE}pkbd: PByteArray;{$ENDIF}
+ pkbd: PByteArray;
begin
hideAmmoMenu:= false;
Trusted:= (CurrentTeam <> nil)
@@ -74,37 +74,34 @@
// TODO: Scale on screen dimensions and/or axis value (game controller)?
movecursor(5 * CursorMovementX, 5 * CursorMovementY);
-k:= SDL_GetMouseState(nil, nil);
+pkbd:= SDL_GetKeyState(@j);
+for i:= 1 to pred(j) do
+ tkbdn[i]:= pkbd^[i];
-{$IFDEF MOBILE}
-SDL_GetKeyState(@j);
-{$ELSE}
-pkbd:= SDL_GetKeyState(@j);
-for i:= 6 to pred(j) do // first 6 will be overwritten
- tkbdn[i]:= pkbd^[i];
-{$ENDIF}
-
+k:= SDL_GetMouseState(nil, nil);
// mouse buttons
{$IFDEF DARWIN}
-tkbdn[1]:= ((k and 1) and not (tkbdn[306] or tkbdn[305]));
-tkbdn[3]:= ((k and 1) and (tkbdn[306] or tkbdn[305])) or (k and 4);
+tkbdn[SDL_SCANCODE_MOUSEL]:= ((k and 1) and not (tkbdn[306] or tkbdn[305]));
+tkbdni[SDL_SCANCODE_MOUSER]:= ((k and 1) and (tkbdn[306] or tkbdn[305])) or (k and 4);
{$ELSE}
-tkbdn[1]:= (k and 1);
-tkbdn[3]:= ((k shr 2) and 1);
+tkbdn[SDL_SCANCODE_MOUSEL]:= (k and 1);
+tkbdn[SDL_SCANCODE_MOUSER]:= ((k shr 2) and 1);
{$ENDIF}
-tkbdn[2]:= ((k shr 1) and 1);
+tkbdn[SDL_SCANCODE_MOUSEM]:= ((k shr 1) and 1);
// mouse wheels
-tkbdn[4]:= ord(wheelDown);
-tkbdn[5]:= ord(wheelUp);
+tkbdn[SDL_SCANCODE_WHEELDOWN]:= ord(wheelDown);
+tkbdn[SDL_SCANCODE_WHEELUP]:= ord(wheelUp);
wheelUp:= false;
wheelDown:= false;
{$IFDEF MOBILE}
-setiPhoneBinds();
-{$ELSE}
+setTouchWidgetStates();
+{$ENDIF}
+
+{$IFNDEF MOBILE}
// Controller(s)
-k:= j; // should we test k for hitting the limit? sounds rather unlikely to ever reach it
+k:= SDL_SCANCODE_CONTROLLER; // should we test k for hitting the limit? sounds rather unlikely to ever reach it
for j:= 0 to Pred(ControllerNumControllers) do
begin
for i:= 0 to Pred(ControllerNumAxes[j]) do
@@ -137,12 +134,12 @@
// ctrl/cmd + q to close engine and frontend
{$IFDEF DARWIN}
- if ((tkbdn[KeyNameToCode('left_meta')] = 1) or (tkbdn[KeyNameToCode('right_meta')] = 1)) then
+ if ((tkbdn[SDL_SCANCODE_LGUI] = 1) or (tkbdn[SDL_SCANCODE_RGUI] = 1)) then
{$ELSE}
- if ((tkbdn[KeyNameToCode('left_ctrl')] = 1) or (tkbdn[KeyNameToCode('right_ctrl')] = 1)) then
+ if ((tkbdn[SDL_SCANCODE_LCTRL] = 1) or (tkbdn[SDL_SCANCODE_RCTRL] = 1)) then
{$ENDIF}
begin
- if tkbdn[KeyNameToCode('q')] = 1 then ParseCommand ('halt', true)
+ if tkbdn[SDL_SCANCODE_Q] = 1 then ParseCommand ('halt', true)
end;
// now process strokes
@@ -170,43 +167,41 @@
procedure ResetKbd;
var j, k, t: LongInt;
-{$IFNDEF MOBILE}
i: LongInt;
pkbd: PByteArray;
-{$ENDIF}
begin
k:= SDL_GetMouseState(nil, nil);
-{$IFNDEF MOBILE}pkbd:={$ENDIF}SDL_GetKeyState(@j);
+pkbd:=SDL_GetKeyState(@j);
TryDo(j < cKeyMaxIndex, 'SDL keys number is more than expected (' + IntToStr(j) + ')', true);
-{$IFNDEF MOBILE}
for i:= 1 to pred(j) do
tkbdn[i]:= pkbd^[i];
-{$ENDIF}
// mouse buttons
{$IFDEF DARWIN}
-tkbdn[1]:= ((k and 1) and not (tkbdn[306] or tkbdn[305]));
-tkbdn[3]:= ((k and 1) and (tkbdn[306] or tkbdn[305])) or (k and 4);
+tkbdn[SDL_SCANCODE_MOUSEL]:= ((k and 1) and not (tkbdn[306] or tkbdn[305]));
+tkbdn[SDL_SCANCODE_MOUSER]:= ((k and 1) and (tkbdn[306] or tkbdn[305])) or (k and 4);
{$ELSE}
-tkbdn[1]:= (k and 1);
-tkbdn[3]:= ((k shr 2) and 1);
+tkbdn[SDL_SCANCODE_MOUSEL]:= (k and 1);
+tkbdn[SDL_SCANCODE_MOUSER]:= ((k shr 2) and 1);
{$ENDIF}
-tkbdn[2]:= ((k shr 1) and 1);
+tkbdn[SDL_SCANCODE_MOUSEM]:= ((k shr 1) and 1);
// mouse wheels
-tkbdn[4]:= ord(wheelDown);
-tkbdn[5]:= ord(wheelUp);
+tkbdn[SDL_SCANCODE_WHEELDOWN]:= ord(wheelDown);
+tkbdn[SDL_SCANCODE_WHEELUP]:= ord(wheelUp);
wheelUp:= false;
wheelDown:= false;
{$IFDEF MOBILE}
-setiPhoneBinds();
-{$ELSE}
+setTouchWidgetStates();
+{$ENDIF}
+
+{$IFNDEF MOBILE}
// Controller(s)
-k:= j; // should we test k for hitting the limit? sounds rather unlikely to ever reach it
+k:= SDL_SCANCODE_CONTROLLER; // should we test k for hitting the limit? sounds rather unlikely to ever reach it
for j:= 0 to Pred(ControllerNumControllers) do
begin
for i:= 0 to Pred(ControllerNumAxes[j]) do
@@ -246,16 +241,10 @@
var i, j, k, t: LongInt;
s: string[15];
begin
-KeyNames[1]:= 'mousel';
-KeyNames[2]:= 'mousem';
-KeyNames[3]:= 'mouser';
-KeyNames[4]:= 'wheelup';
-KeyNames[5]:= 'wheeldown';
-
-for i:= 6 to cKeyMaxIndex do
+for i:= 0 to cKeyMaxIndex do
begin
s:= shortstring(sdl_getkeyname(i));
- //writeln(stdout,IntToStr(i) + ': ' + s);
+ //WriteToConsole(IntToStr(i) + ': ' + s);
if s = 'unknown key' then KeyNames[i]:= ''
else
begin
@@ -266,11 +255,14 @@
end;
end;
+KeyNames[SDL_SCANCODE_MOUSEL]:= 'mousel';
+KeyNames[SDL_SCANCODE_MOUSEM]:= 'mousem';
+KeyNames[SDL_SCANCODE_MOUSER]:= 'mouser';
+KeyNames[SDL_SCANCODE_WHEELUP]:= 'wheelup';
+KeyNames[SDL_SCANCODE_WHEELDOWN]:= 'wheeldown';
//for i:= 0 to cKeyMaxIndex do writeln(stdout,IntToStr(i) + ': ' + KeyNames[i]);
-// get the size of keyboard array
-SDL_GetKeyState(@k);
-
+k:= SDL_SCANCODE_CONTROLLER;
// Controller(s)
for j:= 0 to Pred(ControllerNumControllers) do
begin
@@ -295,54 +287,59 @@
end;
end;
-DefaultBinds[ 27]:= 'quit';
-DefaultBinds[ 96]:= 'history';
+DefaultBinds[SDL_SCANCODE_ESCAPE]:= 'quit';
+DefaultBinds[SDL_SCANCODE_GRAVE]:= 'history';
DefaultBinds[127]:= 'rotmask';
//numpad
//DefaultBinds[265]:= '+volup';
//DefaultBinds[256]:= '+voldown';
-DefaultBinds[KeyNameToCode('0')]:= '+volup';
-DefaultBinds[KeyNameToCode('9')]:= '+voldown';
-DefaultBinds[KeyNameToCode('c')]:= 'capture';
-DefaultBinds[KeyNameToCode('h')]:= 'findhh';
-DefaultBinds[KeyNameToCode('p')]:= 'pause';
-DefaultBinds[KeyNameToCode('s')]:= '+speedup';
-DefaultBinds[KeyNameToCode('t')]:= 'chat';
-DefaultBinds[KeyNameToCode('y')]:= 'confirm';
+DefaultBinds[SDL_SCANCODE_0]:= '+volup';
+DefaultBinds[SDL_SCANCODE_9]:= '+voldown';
+DefaultBinds[SDL_SCANCODE_C]:= 'capture';
+DefaultBinds[SDL_SCANCODE_H]:= 'findhh';
+DefaultBinds[SDL_SCANCODE_P]:= 'pause';
+DefaultBinds[SDL_SCANCODE_S]:= '+speedup';
+DefaultBinds[SDL_SCANCODE_T]:= 'chat';
+DefaultBinds[SDL_SCANCODE_Y]:= 'confirm';
-DefaultBinds[KeyNameToCode('mousem')]:= 'zoomreset';
-DefaultBinds[KeyNameToCode('wheelup')]:= 'zoomout';
-DefaultBinds[KeyNameToCode('wheeldown')]:= 'zoomin';
+DefaultBinds[SDL_SCANCODE_MOUSEM]:= 'zoomreset';
+DefaultBinds[SDL_SCANCODE_WHEELUP]:= 'zoomout';
+DefaultBinds[SDL_SCANCODE_WHEELDOWN]:= 'zoomin';
-DefaultBinds[KeyNameToCode('f12')]:= 'fullscr';
+DefaultBinds[SDL_SCANCODE_F12]:= 'fullscr';
-DefaultBinds[ 1]:= '/put';
-DefaultBinds[ 3]:= 'ammomenu';
-DefaultBinds[ 8]:= 'hjump';
-DefaultBinds[ 9]:= 'switch';
-DefaultBinds[13]:= 'ljump';
-DefaultBinds[32]:= '+attack';
-{$IFDEF MOBILE}
-DefaultBinds[23]:= '+up';
-DefaultBinds[24]:= '+down';
-DefaultBinds[25]:= '+left';
-DefaultBinds[26]:= '+right';
-DefaultBinds[27]:= '+precise';
-DefaultBinds[44]:= 'chat';
-DefaultBinds[55]:= 'pause';
-{$ELSE}
-DefaultBinds[KeyNameToCode('up')]:= '+up';
-DefaultBinds[KeyNameToCode('down')]:= '+down';
-DefaultBinds[KeyNameToCode('left')]:= '+left';
-DefaultBinds[KeyNameToCode('right')]:= '+right';
-DefaultBinds[KeyNameToCode('left_shift')]:= '+precise';
-{$ENDIF}
+DefaultBinds[SDL_SCANCODE_MOUSEL]:= '/put';
+DefaultBinds[SDL_SCANCODE_MOUSER]:= 'ammomenu';
+DefaultBinds[SDL_SCANCODE_BACKSPACE]:= 'hjump';
+DefaultBinds[SDL_SCANCODE_TAB]:= 'switch';
+DefaultBinds[SDL_SCANCODE_RETURN]:= 'ljump';
+DefaultBinds[SDL_SCANCODE_SPACE]:= '+attack';
+
+DefaultBinds[SDL_SCANCODE_UP]:= '+up';
+DefaultBinds[SDL_SCANCODE_DOWN]:= '+down';
+DefaultBinds[SDL_SCANCODE_LEFT]:= '+left';
+DefaultBinds[SDL_SCANCODE_RIGHT]:= '+right';
+DefaultBinds[SDL_SCANCODE_LSHIFT]:= '+precise';
-for i:= 1 to 10 do DefaultBinds[KeyNameToCode('f'+IntToStr(i))]:= 'slot '+IntToStr(i);
-for i:= 1 to 5 do DefaultBinds[KeyNameToCode(IntToStr(i))]:= 'timer '+IntToStr(i);
+DefaultBinds[SDL_SCANCODE_F1]:= 'slot 1';
+DefaultBinds[SDL_SCANCODE_F2]:= 'slot 2';
+DefaultBinds[SDL_SCANCODE_F3]:= 'slot 3';
+DefaultBinds[SDL_SCANCODE_F4]:= 'slot 4';
+DefaultBinds[SDL_SCANCODE_F5]:= 'slot 5';
+DefaultBinds[SDL_SCANCODE_F6]:= 'slot 6';
+DefaultBinds[SDL_SCANCODE_F7]:= 'slot 7';
+DefaultBinds[SDL_SCANCODE_F8]:= 'slot 8';
+DefaultBinds[SDL_SCANCODE_F9]:= 'slot 9';
+DefaultBinds[SDL_SCANCODE_F10]:= 'slot 10';
+
+DefaultBinds[SDL_SCANCODE_1]:= 'timer 1';
+DefaultBinds[SDL_SCANCODE_2]:= 'timer 2';
+DefaultBinds[SDL_SCANCODE_3]:= 'timer 3';
+DefaultBinds[SDL_SCANCODE_4]:= 'timer 4';
+DefaultBinds[SDL_SCANCODE_5]:= 'timer 5';
SetDefaultBinds();
end;
@@ -363,25 +360,25 @@
end;
{$IFDEF MOBILE}
-procedure setiPhoneBinds;
+procedure setTouchWidgetStates;
begin
- tkbdn[ 1]:= ord(leftClick);
- tkbdn[ 2]:= ord(middleClick);
- tkbdn[ 3]:= ord(rightClick);
+ tkbdn[SDL_SCANCODE_MOUSEL]:= tkbdn[SDL_SCANCODE_MOUSEL] or ord(leftClick);
+ tkbdn[SDL_SCANCODE_MOUSEM]:= tkbdn[SDL_SCANCODE_MOUSEM] or ord(middleClick);
+ tkbdn[SDL_SCANCODE_MOUSER]:= tkbdn[SDL_SCANCODE_MOUSER] or ord(rightClick);
- tkbdn[23]:= ord(upKey);
- tkbdn[24]:= ord(downKey);
- tkbdn[25]:= ord(leftKey);
- tkbdn[26]:= ord(rightKey);
- tkbdn[27]:= ord(preciseKey);
+ tkbdn[SDL_SCANCODE_UP] := tkbdn[SDL_SCANCODE_UP] or ord(upKey);
+ tkbdn[SDL_SCANCODE_DOWN] := tkbdn[SDL_SCANCODE_DOWN] or ord(downKey);
+ tkbdn[SDL_SCANCODE_LEFT] := tkbdn[SDL_SCANCODE_LEFT] or ord(leftKey);
+ tkbdn[SDL_SCANCODE_RIGHT] := tkbdn[SDL_SCANCODE_RIGHT] or ord(rightKey);
+ tkbdn[SDL_SCANCODE_LSHIFT]:= tkbdn[SDL_SCANCODE_LSHIFT] or ord(preciseKey);
- tkbdn[ 8]:= ord(backspaceKey);
- tkbdn[ 9]:= ord(tabKey);
- tkbdn[13]:= ord(enterKey);
- tkbdn[32]:= ord(spaceKey);
+ tkbdn[SDL_SCANCODE_BACKSPACE]:= tkbdn[SDL_SCANCODE_BACKSPACE] or ord(backspaceKey);
+ tkbdn[SDL_SCANCODE_TAB]:= tkbdn[SDL_SCANCODE_TAB] or ord(tabKey);
+ tkbdn[SDL_SCANCODE_RETURN]:= ord(enterKey);
+ tkbdn[SDL_SCANCODE_SPACE]:= ord(spaceKey);
- tkbdn[44]:= ord(chatAction);
- tkbdn[55]:= ord(pauseAction);
+ tkbdn[SDL_SCANCODE_T]:= tkbdn[SDL_SCANCODE_T] or ord(chatAction);
+ tkbdn[SDL_SCANCODE_PAUSE]:= ord(pauseAction);
// set to false the keys that only need one stoke
leftClick:= false;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/jni/SDL/src/video/android/SDL_androidkeyboard.c Sat Apr 21 17:59:14 2012 +0200
@@ -0,0 +1,185 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#include "SDL_config.h"
+
+#if SDL_VIDEO_DRIVER_ANDROID
+
+#include <android/log.h>
+
+#include "../../events/SDL_events_c.h"
+
+#include "SDL_androidkeyboard.h"
+#include "SDL_keycode.h"
+
+
+void Android_InitKeyboard()
+{
+ SDL_Keycode keymap[SDL_NUM_SCANCODES];
+
+ /* Add default scancode to key mapping */
+ SDL_GetDefaultKeymap(keymap);
+ SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
+}
+
+static SDL_Scancode Android_Keycodes[] = {
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_UNKNOWN */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SOFT_LEFT */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SOFT_RIGHT */
+ SDL_SCANCODE_AC_HOME, /* AKEYCODE_HOME */
+ SDL_SCANCODE_AC_BACK, /* AKEYCODE_BACK */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CALL */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ENDCALL */
+ SDL_SCANCODE_0, /* AKEYCODE_0 */
+ SDL_SCANCODE_1, /* AKEYCODE_1 */
+ SDL_SCANCODE_2, /* AKEYCODE_2 */
+ SDL_SCANCODE_3, /* AKEYCODE_3 */
+ SDL_SCANCODE_4, /* AKEYCODE_4 */
+ SDL_SCANCODE_5, /* AKEYCODE_5 */
+ SDL_SCANCODE_6, /* AKEYCODE_6 */
+ SDL_SCANCODE_7, /* AKEYCODE_7 */
+ SDL_SCANCODE_8, /* AKEYCODE_8 */
+ SDL_SCANCODE_9, /* AKEYCODE_9 */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STAR */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_POUND */
+ SDL_SCANCODE_UP, /* AKEYCODE_DPAD_UP */
+ SDL_SCANCODE_DOWN, /* AKEYCODE_DPAD_DOWN */
+ SDL_SCANCODE_LEFT, /* AKEYCODE_DPAD_LEFT */
+ SDL_SCANCODE_RIGHT, /* AKEYCODE_DPAD_RIGHT */
+ SDL_SCANCODE_SELECT, /* AKEYCODE_DPAD_CENTER */
+ SDL_SCANCODE_VOLUMEUP, /* AKEYCODE_VOLUME_UP */
+ SDL_SCANCODE_VOLUMEDOWN, /* AKEYCODE_VOLUME_DOWN */
+ SDL_SCANCODE_POWER, /* AKEYCODE_POWER */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CAMERA */
+ SDL_SCANCODE_CLEAR, /* AKEYCODE_CLEAR */
+ SDL_SCANCODE_A, /* AKEYCODE_A */
+ SDL_SCANCODE_B, /* AKEYCODE_B */
+ SDL_SCANCODE_C, /* AKEYCODE_C */
+ SDL_SCANCODE_D, /* AKEYCODE_D */
+ SDL_SCANCODE_E, /* AKEYCODE_E */
+ SDL_SCANCODE_F, /* AKEYCODE_F */
+ SDL_SCANCODE_G, /* AKEYCODE_G */
+ SDL_SCANCODE_H, /* AKEYCODE_H */
+ SDL_SCANCODE_I, /* AKEYCODE_I */
+ SDL_SCANCODE_J, /* AKEYCODE_J */
+ SDL_SCANCODE_K, /* AKEYCODE_K */
+ SDL_SCANCODE_L, /* AKEYCODE_L */
+ SDL_SCANCODE_M, /* AKEYCODE_M */
+ SDL_SCANCODE_N, /* AKEYCODE_N */
+ SDL_SCANCODE_O, /* AKEYCODE_O */
+ SDL_SCANCODE_P, /* AKEYCODE_P */
+ SDL_SCANCODE_Q, /* AKEYCODE_Q */
+ SDL_SCANCODE_R, /* AKEYCODE_R */
+ SDL_SCANCODE_S, /* AKEYCODE_S */
+ SDL_SCANCODE_T, /* AKEYCODE_T */
+ SDL_SCANCODE_U, /* AKEYCODE_U */
+ SDL_SCANCODE_V, /* AKEYCODE_V */
+ SDL_SCANCODE_W, /* AKEYCODE_W */
+ SDL_SCANCODE_X, /* AKEYCODE_X */
+ SDL_SCANCODE_Y, /* AKEYCODE_Y */
+ SDL_SCANCODE_Z, /* AKEYCODE_Z */
+ SDL_SCANCODE_COMMA, /* AKEYCODE_COMMA */
+ SDL_SCANCODE_PERIOD, /* AKEYCODE_PERIOD */
+ SDL_SCANCODE_LALT, /* AKEYCODE_ALT_LEFT */
+ SDL_SCANCODE_RALT, /* AKEYCODE_ALT_RIGHT */
+ SDL_SCANCODE_LSHIFT, /* AKEYCODE_SHIFT_LEFT */
+ SDL_SCANCODE_RSHIFT, /* AKEYCODE_SHIFT_RIGHT */
+ 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_RETURN, /* AKEYCODE_ENTER */
+ SDL_SCANCODE_BACKSPACE, /* AKEYCODE_DEL */
+ SDL_SCANCODE_GRAVE, /* AKEYCODE_GRAVE */
+ SDL_SCANCODE_MINUS, /* AKEYCODE_MINUS */
+ SDL_SCANCODE_EQUALS, /* AKEYCODE_EQUALS */
+ SDL_SCANCODE_LEFTBRACKET, /* AKEYCODE_LEFT_BRACKET */
+ SDL_SCANCODE_RIGHTBRACKET, /* AKEYCODE_RIGHT_BRACKET */
+ SDL_SCANCODE_BACKSLASH, /* AKEYCODE_BACKSLASH */
+ SDL_SCANCODE_SEMICOLON, /* AKEYCODE_SEMICOLON */
+ SDL_SCANCODE_APOSTROPHE, /* AKEYCODE_APOSTROPHE */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SLASH */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_AT */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NUM */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_HEADSETHOOK */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_FOCUS */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PLUS */
+ SDL_SCANCODE_MENU, /* AKEYCODE_MENU */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NOTIFICATION */
+ SDL_SCANCODE_AC_SEARCH, /* AKEYCODE_SEARCH */
+ SDL_SCANCODE_AUDIOPLAY, /* AKEYCODE_MEDIA_PLAY_PAUSE */
+ SDL_SCANCODE_AUDIOSTOP, /* AKEYCODE_MEDIA_STOP */
+ SDL_SCANCODE_AUDIONEXT, /* AKEYCODE_MEDIA_NEXT */
+ SDL_SCANCODE_AUDIOPREV, /* AKEYCODE_MEDIA_PREVIOUS */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_REWIND */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_FAST_FORWARD */
+ SDL_SCANCODE_MUTE, /* AKEYCODE_MUTE */
+ SDL_SCANCODE_PAGEUP, /* AKEYCODE_PAGE_UP */
+ SDL_SCANCODE_PAGEDOWN, /* AKEYCODE_PAGE_DOWN */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PICTSYMBOLS */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SWITCH_CHARSET */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_A */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_B */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_C */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_X */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_Y */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_Z */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_L1 */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_R1 */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_L2 */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_R2 */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_THUMBL */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_THUMBR */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_START */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_SELECT */
+ SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_MODE */
+};
+
+static SDL_Scancode
+TranslateKeycode(int keycode)
+{
+ SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN;
+
+ if (keycode < SDL_arraysize(Android_Keycodes)) {
+ scancode = Android_Keycodes[keycode];
+ }
+ if (scancode == SDL_SCANCODE_UNKNOWN) {
+ __android_log_print(ANDROID_LOG_INFO, "SDL", "Unknown keycode %d", keycode);
+ }
+ __android_log_print(ANDROID_LOG_INFO, "SDLXELI", "keycode %d scancode %d", keycode, scancode);
+ return scancode;
+}
+
+int
+Android_OnKeyDown(int keycode)
+{
+ return SDL_SendKeyboardKey(SDL_PRESSED, TranslateKeycode(keycode));
+}
+
+int
+Android_OnKeyUp(int keycode)
+{
+ return SDL_SendKeyboardKey(SDL_RELEASED, TranslateKeycode(keycode));
+}
+
+#endif /* SDL_VIDEO_DRIVER_ANDROID */
+
+/* vi: set ts=4 sw=4 expandtab: */