From 881a7daf701d5f9cef70d1ca8af249398ef4071c Mon Sep 17 00:00:00 2001 From: pelya Date: Sun, 23 Feb 2014 19:26:20 +0200 Subject: [PATCH] Fixed international text input in XServer --- project/java/MainActivity.java | 36 +++++- project/java/Video.java | 31 ++---- project/jni/application/xserver/xserver | 2 +- .../android/SDL_androidinput-queue-compat.c | 2 +- .../android/SDL_androidinput-queue-fast.c | 10 +- .../src/video/android/SDL_androidinput.c | 105 +++++++++--------- .../src/video/android/SDL_androidinput.h | 2 +- .../video/android/SDL_touchscreenkeyboard.c | 48 ++++---- 8 files changed, 131 insertions(+), 105 deletions(-) diff --git a/project/java/MainActivity.java b/project/java/MainActivity.java index c9c14b7e0..b0bb32062 100644 --- a/project/java/MainActivity.java +++ b/project/java/MainActivity.java @@ -687,6 +687,38 @@ public class MainActivity extends Activity } } + @Override + public boolean dispatchKeyEvent(final KeyEvent event) + { + //Log.i("SDL", "dispatchKeyEvent: action " + event.getAction() + " keycode " + event.getKeyCode() + " unicode " + event.getUnicodeChar() + " getCharacters() " + ((event.getCharacters() != null) ? event.getCharacters() : "none")); + + if( event.getAction() == KeyEvent.ACTION_DOWN ) + return onKeyDown(event.getKeyCode(), event); + if( event.getAction() == KeyEvent.ACTION_UP ) + return onKeyUp(event.getKeyCode(), event); + if( event.getAction() == KeyEvent.ACTION_MULTIPLE && event.getKeyCode() == KeyEvent.KEYCODE_UNKNOWN ) + { + // International text input + if( mGLView != null && event.getCharacters() != null ) + { + for(int i = 0; i < event.getCharacters().length(); i++ ) + { + /* + if( mGLView.nativeKey( event.getKeyCode(), 1, event.getCharacters().codePointAt(i) ) == 0 ) + return super.dispatchKeyEvent(event); + if( mGLView.nativeKey( event.getKeyCode(), 0, event.getCharacters().codePointAt(i) ) == 0 ) + return super.dispatchKeyEvent(event); + */ + mGLView.nativeKey( event.getKeyCode(), 1, event.getCharacters().codePointAt(i) ); + mGLView.nativeKey( event.getKeyCode(), 0, event.getCharacters().codePointAt(i) ); + } + return true; + } + } + return true; + //return super.dispatchKeyEvent(event); + } + @Override public boolean onKeyDown(int keyCode, final KeyEvent event) { @@ -695,7 +727,7 @@ public class MainActivity extends Activity else if( mGLView != null ) { - if( mGLView.nativeKey( keyCode, 1 ) == 0 ) + if( mGLView.nativeKey( keyCode, 1, event.getUnicodeChar() ) == 0 ) return super.onKeyDown(keyCode, event); } /* @@ -727,7 +759,7 @@ public class MainActivity extends Activity else if( mGLView != null ) { - if( mGLView.nativeKey( keyCode, 0 ) == 0 ) + if( mGLView.nativeKey( keyCode, 0, event.getUnicodeChar() ) == 0 ) return super.onKeyUp(keyCode, event); if( keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU ) { diff --git a/project/java/Video.java b/project/java/Video.java index 60dd47050..d5f067cdd 100644 --- a/project/java/Video.java +++ b/project/java/Video.java @@ -436,22 +436,22 @@ abstract class DifferentTouchInput hatX = event.getAxisValue(MotionEvent.AXIS_HAT_X); if( hatX == 0.0f ) { - DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_LEFT, 0); - DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_RIGHT, 0); + DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_LEFT, 0, 0); + DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_RIGHT, 0, 0); } else - DemoGLSurfaceView.nativeKey(hatX < 0.0f ? KeyEvent.KEYCODE_DPAD_LEFT : KeyEvent.KEYCODE_DPAD_RIGHT, 1); + DemoGLSurfaceView.nativeKey(hatX < 0.0f ? KeyEvent.KEYCODE_DPAD_LEFT : KeyEvent.KEYCODE_DPAD_RIGHT, 1, 0); } if( event.getAxisValue(MotionEvent.AXIS_HAT_Y) != hatY ) { hatY = event.getAxisValue(MotionEvent.AXIS_HAT_Y); if( hatY == 0.0f ) { - DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_UP, 0); - DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_DOWN, 0); + DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_UP, 0, 0); + DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_DOWN, 0, 0); } else - DemoGLSurfaceView.nativeKey(hatY < 0.0f ? KeyEvent.KEYCODE_DPAD_UP : KeyEvent.KEYCODE_DPAD_DOWN, 1); + DemoGLSurfaceView.nativeKey(hatY < 0.0f ? KeyEvent.KEYCODE_DPAD_UP : KeyEvent.KEYCODE_DPAD_DOWN, 1, 0); } return; } @@ -964,28 +964,11 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL { mRenderer.accelerometer.start(); }; - // This seems like redundant code - it handled in MainActivity.java - @Override - public boolean onKeyDown(int keyCode, final KeyEvent event) { - //Log.i("SDL", "Got key down event, id " + keyCode + " meta " + event.getMetaState() + " event " + event.toString()); - if( nativeKey( keyCode, 1 ) == 0 ) - return super.onKeyDown(keyCode, event); - return true; - } - - @Override - public boolean onKeyUp(int keyCode, final KeyEvent event) { - //Log.i("SDL", "Got key up event, id " + keyCode + " meta " + event.getMetaState()); - if( nativeKey( keyCode, 0 ) == 0 ) - return super.onKeyUp(keyCode, event); - return true; - } - DemoRenderer mRenderer; MainActivity mParent; public static native void nativeMotionEvent( int x, int y, int action, int pointerId, int pressure, int radius ); - public static native int nativeKey( int keyCode, int down ); + public static native int nativeKey( int keyCode, int down, int unicode ); public static native void initJavaCallbacks(); public static native void nativeHardwareMouseDetected( int detected ); public static native void nativeMouseButtonsPressed( int buttonId, int pressedState ); diff --git a/project/jni/application/xserver/xserver b/project/jni/application/xserver/xserver index a7d07d892..b24094aa9 160000 --- a/project/jni/application/xserver/xserver +++ b/project/jni/application/xserver/xserver @@ -1 +1 @@ -Subproject commit a7d07d892c16cba7ec775f5eaf301d1dddf310dd +Subproject commit b24094aa9cf1d923109a814a257a9530eed778b2 diff --git a/project/jni/sdl-1.2/src/video/android/SDL_androidinput-queue-compat.c b/project/jni/sdl-1.2/src/video/android/SDL_androidinput-queue-compat.c index 3e7a9f3c5..32045ad3e 100644 --- a/project/jni/sdl-1.2/src/video/android/SDL_androidinput-queue-compat.c +++ b/project/jni/sdl-1.2/src/video/android/SDL_androidinput-queue-compat.c @@ -245,7 +245,7 @@ extern void SDL_ANDROID_MainThreadPushMouseButton(int pressed, int button) SDL_mutexV(BufferedEventsMutex); }; -extern void SDL_ANDROID_MainThreadPushKeyboardKey(int pressed, SDL_scancode key) +extern void SDL_ANDROID_MainThreadPushKeyboardKey(int pressed, SDL_scancode key, int unicode) { int nextEvent = getNextEventAndLock(); if( nextEvent == -1 ) diff --git a/project/jni/sdl-1.2/src/video/android/SDL_androidinput-queue-fast.c b/project/jni/sdl-1.2/src/video/android/SDL_androidinput-queue-fast.c index b5649def4..f2916c7d7 100644 --- a/project/jni/sdl-1.2/src/video/android/SDL_androidinput-queue-fast.c +++ b/project/jni/sdl-1.2/src/video/android/SDL_androidinput-queue-fast.c @@ -91,7 +91,7 @@ extern void SDL_ANDROID_MainThreadPushMouseButton(int pressed, int button) SDL_ANDROID_currentMouseButtons &= ~(SDL_BUTTON(button)); } -extern void SDL_ANDROID_MainThreadPushKeyboardKey(int pressed, SDL_scancode key) +extern void SDL_ANDROID_MainThreadPushKeyboardKey(int pressed, SDL_scancode key, int unicode) { SDL_keysym keysym; @@ -174,11 +174,17 @@ extern void SDL_ANDROID_MainThreadPushKeyboardKey(int pressed, SDL_scancode key) #else if ( SDL_TranslateUNICODE ) #endif - keysym.unicode = key; + keysym.unicode = unicode; + if( (keysym.unicode & 0xFF80) != 0 ) + keysym.sym = SDLK_WORLD_0; + //else if( keysym.sym < 0x80 ) + // keysym.unicode = keysym.sym; if( pressed == SDL_RELEASED ) keysym.unicode = 0; + //__android_log_print(ANDROID_LOG_INFO, "libSDL","SDL_SendKeyboardKey sym %d scancode %d unicode %d", keysym.sym, keysym.scancode, keysym.unicode); + SDL_SendKeyboardKey( pressed, &keysym ); } diff --git a/project/jni/sdl-1.2/src/video/android/SDL_androidinput.c b/project/jni/sdl-1.2/src/video/android/SDL_androidinput.c index 8d740d73c..371cc2984 100644 --- a/project/jni/sdl-1.2/src/video/android/SDL_androidinput.c +++ b/project/jni/sdl-1.2/src/video/android/SDL_androidinput.c @@ -49,7 +49,7 @@ SDLKey SDL_android_keymap[KEYCODE_LAST+1]; static inline SDL_scancode TranslateKey(int scancode) { - if ( scancode >= SDL_arraysize(SDL_android_keymap) ) + if ( scancode >= KEYCODE_LAST + 1 ) scancode = KEYCODE_UNKNOWN; return SDL_android_keymap[scancode]; } @@ -295,7 +295,7 @@ static void ProcessMultitouchGesture( int x, int y, int action, int pointerId ) if( multitouchGestureKeyPressed[i] ) { multitouchGestureKeyPressed[i] = 0; - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, multitouchGestureKeycode[i] ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, multitouchGestureKeycode[i], 0 ); } } } @@ -322,24 +322,24 @@ static void ProcessMultitouchGesture( int x, int y, int action, int pointerId ) if( dist - multitouchGestureDist > distMaxDiff ) { multitouchGestureKeyPressed[0] = 1; - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, multitouchGestureKeycode[0] ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, multitouchGestureKeycode[0], 0 ); } else if( multitouchGestureKeyPressed[0] ) { multitouchGestureKeyPressed[0] = 0; - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, multitouchGestureKeycode[0] ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, multitouchGestureKeycode[0], 0 ); } if( multitouchGestureDist - dist > distMaxDiff ) { multitouchGestureKeyPressed[1] = 1; - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, multitouchGestureKeycode[1] ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, multitouchGestureKeycode[1], 0 ); } else if( multitouchGestureKeyPressed[1] ) { multitouchGestureKeyPressed[1] = 0; - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, multitouchGestureKeycode[1] ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, multitouchGestureKeycode[1], 0 ); } int angleDiff = angle - multitouchGestureAngle; @@ -352,24 +352,24 @@ static void ProcessMultitouchGesture( int x, int y, int action, int pointerId ) if( angleDiff < -angleMaxDiff ) { multitouchGestureKeyPressed[2] = 1; - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, multitouchGestureKeycode[2] ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, multitouchGestureKeycode[2], 0 ); } else if( multitouchGestureKeyPressed[2] ) { multitouchGestureKeyPressed[2] = 0; - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, multitouchGestureKeycode[2] ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, multitouchGestureKeycode[2], 0 ); } if( angleDiff > angleMaxDiff ) { multitouchGestureKeyPressed[3] = 1; - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, multitouchGestureKeycode[3] ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, multitouchGestureKeycode[3], 0 ); } else if( multitouchGestureKeyPressed[3] ) { multitouchGestureKeyPressed[3] = 0; - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, multitouchGestureKeycode[3] ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, multitouchGestureKeycode[3], 0 ); } } } @@ -400,7 +400,7 @@ static void SendMultitouchEvents( int x, int y, int action, int pointerId, int f { SDL_keysym keysym; if( action != MOUSE_MOVE ) - SDL_ANDROID_MainThreadPushKeyboardKey( action == MOUSE_DOWN ? SDL_PRESSED : SDL_RELEASED, SDL_ANDROID_GetScreenKeyboardButtonKey(SDL_ANDROID_SCREENKEYBOARD_BUTTON_0) ); + SDL_ANDROID_MainThreadPushKeyboardKey( action == MOUSE_DOWN ? SDL_PRESSED : SDL_RELEASED, SDL_ANDROID_GetScreenKeyboardButtonKey(SDL_ANDROID_SCREENKEYBOARD_BUTTON_0), 0 ); return; } } @@ -774,7 +774,7 @@ void SDL_ANDROID_WarpMouse(int x, int y) static int processAndroidTrackball(int key, int action); JNIEXPORT jint JNICALL -JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeKey) ( JNIEnv* env, jobject thiz, jint key, jint action ) +JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeKey) ( JNIEnv* env, jobject thiz, jint key, jint action, jint unicode ) { #if SDL_VERSION_ATLEAST(1,3,0) #else @@ -796,10 +796,15 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeKey) ( JNIEnv* env, jobject thiz, jint return 1; } - if( TranslateKey(key) == SDLK_NO_REMAP || TranslateKey(key) == SDLK_UNKNOWN ) + //__android_log_print(ANDROID_LOG_INFO, "libSDL","nativeKey %d translated %d unicode %d", key, TranslateKey(key), unicode); + + if( TranslateKey(key) == SDLK_NO_REMAP || (TranslateKey(key) == SDLK_UNKNOWN && (unicode & 0xFF80) == 0) ) return 0; - SDL_ANDROID_MainThreadPushKeyboardKey( action ? SDL_PRESSED : SDL_RELEASED, TranslateKey(key) ); + if( TranslateKey(key) != SDLK_UNKNOWN ) + unicode = 0; + + SDL_ANDROID_MainThreadPushKeyboardKey( action ? SDL_PRESSED : SDL_RELEASED, TranslateKey(key), unicode ); return 1; } @@ -1032,8 +1037,8 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouseWheel) (JNIEnv* env, jobject thiz, { if( !SDL_ANDROID_isMouseUsed ) { - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(KEYCODE_DPAD_RIGHT) ); - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_RIGHT) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(KEYCODE_DPAD_RIGHT), 0 ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_RIGHT), 0 ); } else { @@ -1045,8 +1050,8 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouseWheel) (JNIEnv* env, jobject thiz, { if( !SDL_ANDROID_isMouseUsed ) { - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(KEYCODE_DPAD_LEFT) ); - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_LEFT) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(KEYCODE_DPAD_LEFT), 0 ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_LEFT), 0 ); } else { @@ -1058,8 +1063,8 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouseWheel) (JNIEnv* env, jobject thiz, { if( !SDL_ANDROID_isMouseUsed ) { - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(KEYCODE_DPAD_UP) ); - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_UP) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(KEYCODE_DPAD_UP), 0 ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_UP), 0 ); } else { @@ -1071,8 +1076,8 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouseWheel) (JNIEnv* env, jobject thiz, { if( !SDL_ANDROID_isMouseUsed ) { - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(KEYCODE_DPAD_DOWN) ); - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_DOWN) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(KEYCODE_DPAD_DOWN), 0 ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_DOWN), 0 ); } else { @@ -1147,42 +1152,42 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeGamepadAnalogJoystickInput) (JNIEnv* en if( stick1x < -0.5f ) { if( !SDL_GetKeyboardState(NULL)[SDL_KEY(LEFT)] ) - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(LEFT) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(LEFT), 0 ); } else { if( SDL_GetKeyboardState(NULL)[SDL_KEY(LEFT)] ) - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(LEFT) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(LEFT), 0 ); } if( stick1x > 0.5f ) { if( !SDL_GetKeyboardState(NULL)[SDL_KEY(RIGHT)] ) - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(RIGHT) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(RIGHT), 0 ); } else { if( SDL_GetKeyboardState(NULL)[SDL_KEY(RIGHT)] ) - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(RIGHT) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(RIGHT), 0 ); } if( stick1y < -0.5f ) { if( !SDL_GetKeyboardState(NULL)[SDL_KEY(UP)] ) - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(UP) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(UP), 0 ); } else { if( SDL_GetKeyboardState(NULL)[SDL_KEY(UP)] ) - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(UP) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(UP), 0 ); } if( stick1y > 0.5f ) { if( !SDL_GetKeyboardState(NULL)[SDL_KEY(DOWN)] ) - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(DOWN) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(DOWN), 0 ); } else { if( SDL_GetKeyboardState(NULL)[SDL_KEY(DOWN)] ) - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(DOWN) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(DOWN), 0 ); } } } @@ -1206,18 +1211,18 @@ int processAndroidTrackball(int key, int action) if( downPressed ) { downPressed = 0; - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_DOWN) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_DOWN), 0 ); return 1; } if( !upPressed ) { upPressed = 1; - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(key) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(key), 0 ); } else { - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(key) ); - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(key) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(key), 0 ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(key), 0 ); } return 1; } @@ -1227,18 +1232,18 @@ int processAndroidTrackball(int key, int action) if( upPressed ) { upPressed = 0; - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_UP) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_UP), 0 ); return 1; } if( !upPressed ) { downPressed = 1; - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(key) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(key), 0 ); } else { - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(key) ); - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(key) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(key), 0 ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(key), 0 ); } return 1; } @@ -1248,18 +1253,18 @@ int processAndroidTrackball(int key, int action) if( rightPressed ) { rightPressed = 0; - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_RIGHT) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_RIGHT), 0 ); return 1; } if( !leftPressed ) { leftPressed = 1; - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(key) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(key), 0 ); } else { - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(key) ); - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(key) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(key), 0 ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(key), 0 ); } return 1; } @@ -1269,18 +1274,18 @@ int processAndroidTrackball(int key, int action) if( leftPressed ) { leftPressed = 0; - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_LEFT) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_LEFT), 0 ); return 1; } if( !rightPressed ) { rightPressed = 1; - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(key) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(key), 0 ); } else { - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(key) ); - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(key) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(key), 0 ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(key), 0 ); } return 1; } @@ -1295,13 +1300,13 @@ void SDL_ANDROID_processAndroidTrackballDampening() if( SDL_GetTicks() > TrackballDampening + lastTrackballAction ) { if( upPressed ) - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_UP) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_UP), 0 ); if( downPressed ) - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_DOWN) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_DOWN), 0 ); if( leftPressed ) - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_LEFT) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_LEFT), 0 ); if( rightPressed ) - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_RIGHT) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_RIGHT), 0 ); upPressed = 0; downPressed = 0; leftPressed = 0; diff --git a/project/jni/sdl-1.2/src/video/android/SDL_androidinput.h b/project/jni/sdl-1.2/src/video/android/SDL_androidinput.h index 7a97db502..f8b5cb931 100644 --- a/project/jni/sdl-1.2/src/video/android/SDL_androidinput.h +++ b/project/jni/sdl-1.2/src/video/android/SDL_androidinput.h @@ -226,7 +226,7 @@ extern int SDL_ANDROID_isTouchscreenKeyboardUsed; // Queue events to main thread extern void SDL_ANDROID_MainThreadPushMouseMotion(int x, int y); extern void SDL_ANDROID_MainThreadPushMouseButton(int pressed, int button); -extern void SDL_ANDROID_MainThreadPushKeyboardKey(int pressed, SDL_scancode key); +extern void SDL_ANDROID_MainThreadPushKeyboardKey(int pressed, SDL_scancode key, int unicode); extern void SDL_ANDROID_MainThreadPushMultitouchButton(int id, int pressed, int x, int y, int force); // SDL 1.3 only extern void SDL_ANDROID_MainThreadPushMultitouchMotion(int id, int x, int y, int force); // SDL 1.3 only extern void SDL_ANDROID_MainThreadPushJoystickAxis(int joy, int axis, int value); diff --git a/project/jni/sdl-1.2/src/video/android/SDL_touchscreenkeyboard.c b/project/jni/sdl-1.2/src/video/android/SDL_touchscreenkeyboard.c index 767d2f624..b44974db3 100644 --- a/project/jni/sdl-1.2/src/video/android/SDL_touchscreenkeyboard.c +++ b/project/jni/sdl-1.2/src/video/android/SDL_touchscreenkeyboard.c @@ -477,13 +477,13 @@ unsigned SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int po { i = ArrowKeysPressed(x, y); if( i & ARROW_UP ) - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(UP) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(UP), 0 ); if( i & ARROW_DOWN ) - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(DOWN) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(DOWN), 0 ); if( i & ARROW_LEFT ) - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(LEFT) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(LEFT), 0 ); if( i & ARROW_RIGHT ) - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(RIGHT) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(RIGHT), 0 ); oldArrows = i; } } @@ -503,7 +503,7 @@ unsigned SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int po if( i == BUTTON_TEXT_INPUT ) SDL_ANDROID_ToggleScreenKeyboardTextInput(NULL); else - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, buttonKeysyms[i] ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, buttonKeysyms[i], 0 ); if( i < AutoFireButtonsNum ) { ButtonAutoFire[i] = 0; @@ -533,10 +533,10 @@ unsigned SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int po } else { - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(UP) ); - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(DOWN) ); - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(LEFT) ); - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(RIGHT) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(UP), 0 ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(DOWN), 0 ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(LEFT), 0 ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(RIGHT), 0 ); oldArrows = 0; } } @@ -556,7 +556,7 @@ unsigned SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int po else { if( i != BUTTON_TEXT_INPUT ) - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, buttonKeysyms[i] ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, buttonKeysyms[i], 0 ); } if( i < AutoFireButtonsNum ) { @@ -601,10 +601,10 @@ unsigned SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int po } else { - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(UP) ); - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(DOWN) ); - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(LEFT) ); - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(RIGHT) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(UP), 0 ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(DOWN), 0 ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(LEFT), 0 ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(RIGHT), 0 ); oldArrows = 0; } } @@ -623,21 +623,21 @@ unsigned SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int po if( i != oldArrows ) { if( oldArrows & ARROW_UP && ! (i & ARROW_UP) ) - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(UP) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(UP), 0 ); if( oldArrows & ARROW_DOWN && ! (i & ARROW_DOWN) ) - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(DOWN) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(DOWN), 0 ); if( oldArrows & ARROW_LEFT && ! (i & ARROW_LEFT) ) - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(LEFT) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(LEFT), 0 ); if( oldArrows & ARROW_RIGHT && ! (i & ARROW_RIGHT) ) - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(RIGHT) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(RIGHT), 0 ); if( i & ARROW_UP ) - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(UP) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(UP), 0 ); if( i & ARROW_DOWN ) - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(DOWN) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(DOWN), 0 ); if( i & ARROW_LEFT ) - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(LEFT) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(LEFT), 0 ); if( i & ARROW_RIGHT ) - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(RIGHT) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(RIGHT), 0 ); } oldArrows = i; } @@ -655,7 +655,7 @@ unsigned SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int po if( !ButtonAutoFire[i] ) { if( i != BUTTON_TEXT_INPUT ) - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, buttonKeysyms[i] ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, buttonKeysyms[i], 0 ); } else { @@ -704,7 +704,7 @@ unsigned SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int po { pointerInButtonRect[i] = -1; if( i != BUTTON_TEXT_INPUT ) - SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, buttonKeysyms[i] ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, buttonKeysyms[i], 0 ); } } }