diff --git a/project/jni/application/fheroes2/AndroidAppSettings.cfg b/project/jni/application/fheroes2/AndroidAppSettings.cfg index b8f27e89c..750be18ac 100644 --- a/project/jni/application/fheroes2/AndroidAppSettings.cfg +++ b/project/jni/application/fheroes2/AndroidAppSettings.cfg @@ -25,9 +25,9 @@ AppVersionCode=100 AppVersionName="1.0.0" CompiledLibraries="sdl_net sdl_mixer sdl_image sdl_ttf png intl" CustomBuildScript=n -AppCflags='-fexceptions -finline-functions -O2 -DWITH_ZLIB -DWITH_MIXER -DWITH_NET -DWITH_XML -DWITH_IMAGE -DWITH_TTF -DAI_EMPTY' +AppCflags='-finline-functions -O2 -DWITH_ZLIB -DWITH_MIXER -DWITH_NET -DWITH_XML -DWITH_IMAGE -DWITH_TTF -DAI_EMPTY' AppLdflags='' AppSubdirsBuild='fheroes2/src/engine/* fheroes2/src/fheroes2/* fheroes2/src/xmlccwrap/*' -AppUseCrystaXToolchain=y +AppUseCrystaXToolchain=n AppCmdline='fheroes2 -d' ReadmeText='^You may press "Home" now - the data will be downloaded in background' diff --git a/project/jni/application/openttd/AndroidAppSettings.cfg b/project/jni/application/openttd/AndroidAppSettings.cfg index ae0a70b1e..bf130ce70 100644 --- a/project/jni/application/openttd/AndroidAppSettings.cfg +++ b/project/jni/application/openttd/AndroidAppSettings.cfg @@ -21,8 +21,8 @@ RedefinedKeys="LALT RETURN KP_PLUS KP_MINUS DELETE ESCAPE" AppTouchscreenKeyboardKeysAmount=0 AppTouchscreenKeyboardKeysAmountAutoFire=0 MultiABI=n -AppVersionCode=10504 -AppVersionName="1.0.5.04" +AppVersionCode=10505 +AppVersionName="1.0.5.05" CompiledLibraries="jpeg png freetype timidity lzma lzo2" CustomBuildScript=y AppCflags='' diff --git a/project/jni/application/src b/project/jni/application/src index 706424f94..550b7b622 120000 --- a/project/jni/application/src +++ b/project/jni/application/src @@ -1 +1 @@ -sc2 \ No newline at end of file +openttd \ No newline at end of file diff --git a/project/jni/application/vice/AndroidAppSettings.cfg b/project/jni/application/vice/AndroidAppSettings.cfg index 2663cc217..2343b0e6f 100644 --- a/project/jni/application/vice/AndroidAppSettings.cfg +++ b/project/jni/application/vice/AndroidAppSettings.cfg @@ -5,7 +5,7 @@ AppName="ViceC64" AppFullName=org.viceteam.sdl ScreenOrientation=h InhibitSuspend=n -AppDataDownloadUrl="Data files size is 1 Mb|http://anddev.at.ua/data/vice-data.zip?attredirects=0&d=1" +AppDataDownloadUrl="Data size is 1 Mb|vice-data.zip" SdlVideoResize=y SdlVideoResizeKeepAspect=n NeedDepthBuffer=n @@ -17,17 +17,17 @@ AppUsesJoystick=n AppHandlesJoystickSensitivity=n AppUsesMultitouch=n NonBlockingSwapBuffers=n -RedefinedKeys="LALT RETURN KP_PLUS KP_MINUS LCTRL" -AppTouchscreenKeyboardKeysAmount=3 +RedefinedKeys="LCTRL RETURN KP_PLUS KP_MINUS LCTRL" +AppTouchscreenKeyboardKeysAmount=4 AppTouchscreenKeyboardKeysAmountAutoFire=0 MultiABI=n -AppVersionCode=12001 -AppVersionName="2.2.01" +AppVersionCode=22001 +AppVersionName="svn23185" CompiledLibraries="jpeg png" CustomBuildScript=y AppCflags='' AppLdflags='' AppSubdirsBuild='' AppUseCrystaXToolchain=n -AppCmdline='/sdcard/app-data/org.viceteam.sdl/vice -sdlcustomw 480 -sdlcustomh 320 -sdllimitmode 1 -menukey 306' +AppCmdline='/sdcard/app-data/org.viceteam.sdl/vice -sdlcustomw 320 -sdlcustomh 240 -sdllimitmode 1 -menukey 306' ReadmeText='^You may press "Home" now - the data will be downloaded in background' diff --git a/project/jni/application/vice/AndroidData/vice-data.zip b/project/jni/application/vice/AndroidData/vice-data.zip new file mode 100644 index 000000000..dfa89b70e Binary files /dev/null and b/project/jni/application/vice/AndroidData/vice-data.zip differ diff --git a/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c b/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c index d2eff7ca8..e8e0f4e8e 100644 --- a/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c +++ b/project/jni/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c @@ -397,6 +397,7 @@ void ANDROID_VideoQuit(_THIS) void ANDROID_PumpEvents(_THIS) { + SDL_ANDROID_PumpEvents(); } static int ANDROID_AllocHWSurface(_THIS, SDL_Surface *surface) @@ -797,7 +798,11 @@ static void ANDROID_UpdateRects(_THIS, int numrects, SDL_Rect *rects) { if( SDL_VideoThreadID != SDL_ThreadID() ) { + static count = 100; __android_log_print(ANDROID_LOG_INFO, "libSDL", "Error: calling %s not from the main thread!", __PRETTY_FUNCTION__); + count--; + if(count <=0 ) + abort(); return; } diff --git a/project/jni/sdl-1.3/src/video/android/SDL_androidinput.c b/project/jni/sdl-1.3/src/video/android/SDL_androidinput.c index 4ae3f22d5..7f26346d5 100644 --- a/project/jni/sdl-1.3/src/video/android/SDL_androidinput.c +++ b/project/jni/sdl-1.3/src/video/android/SDL_androidinput.c @@ -30,6 +30,8 @@ #include "SDL_config.h" #include "SDL_version.h" +#include "SDL_mutex.h" +#include "SDL_events.h" #if SDL_VERSION_ATLEAST(1,3,0) #include "SDL_touch.h" #include "../../events/SDL_touch_c.h" @@ -41,7 +43,14 @@ #include "jniwrapperstuff.h" -SDLKey SDL_android_keymap[KEYCODE_LAST+1]; +static SDLKey SDL_android_keymap[KEYCODE_LAST+1]; + +static inline SDL_scancode TranslateKey(int scancode) +{ + if ( scancode >= SDL_arraysize(SDL_android_keymap) ) + scancode = KEYCODE_UNKNOWN; + return SDL_android_keymap[scancode]; +} static int isTrackballUsed = 0; @@ -60,6 +69,7 @@ SDL_Joystick *SDL_ANDROID_CurrentJoysticks[MAX_MULTITOUCH_POINTERS+1] = {NULL}; static int TrackballDampening = 0; // in milliseconds static int lastTrackballAction = 0; + static inline int InsideRect(const SDL_Rect * r, int x, int y) { return ( x >= r->x && x <= r->x + r->w ) && ( y >= r->y && y <= r->y + r->h ); @@ -147,28 +157,25 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouse) ( JNIEnv* env, jobject thiz, j #if SDL_VERSION_ATLEAST(1,3,0) // Use nifty SDL 1.3 multitouch API if( action == MOUSE_MOVE ) - SDL_SendTouchMotion(0, pointerId, 0, x, y, force*radius / 16); + SDL_ANDROID_MainThreadPushMultitouchMotion(pointerId, x, y, force*radius / 16); else - SDL_SendFingerDown(0, pointerId, action == MOUSE_DOWN ? 1 : 0, x, y, force*radius / 16); + SDL_ANDROID_MainThreadPushMultitouchButton(pointerId, action == MOUSE_DOWN ? 1 : 0, x, y, force*radius / 16); #endif - if( SDL_ANDROID_CurrentJoysticks[pointerId] ) - { - SDL_PrivateJoystickAxis(SDL_ANDROID_CurrentJoysticks[pointerId+1], 0, x); - SDL_PrivateJoystickAxis(SDL_ANDROID_CurrentJoysticks[pointerId+1], 1, y); - SDL_PrivateJoystickAxis(SDL_ANDROID_CurrentJoysticks[pointerId+1], 2, force); - SDL_PrivateJoystickAxis(SDL_ANDROID_CurrentJoysticks[pointerId+1], 3, radius); - if( action == MOUSE_DOWN ) - SDL_PrivateJoystickButton(SDL_ANDROID_CurrentJoysticks[pointerId+1], 0, SDL_PRESSED); - if( action == MOUSE_UP ) - SDL_PrivateJoystickButton(SDL_ANDROID_CurrentJoysticks[pointerId+1], 0, SDL_RELEASED); - } + SDL_ANDROID_MainThreadPushJoystickAxis(pointerId+1, 0, x); + SDL_ANDROID_MainThreadPushJoystickAxis(pointerId+1, 1, y); + SDL_ANDROID_MainThreadPushJoystickAxis(pointerId+1, 2, force); + SDL_ANDROID_MainThreadPushJoystickAxis(pointerId+1, 3, radius); + if( action == MOUSE_DOWN ) + SDL_ANDROID_MainThreadPushJoystickButton(pointerId+1, 0, SDL_PRESSED); + if( action == MOUSE_UP ) + SDL_ANDROID_MainThreadPushJoystickButton(pointerId+1, 0, SDL_RELEASED); } if( !isMouseUsed && !SDL_ANDROID_isTouchscreenKeyboardUsed ) { SDL_keysym keysym; if( action != MOUSE_MOVE ) - SDL_SendKeyboardKey( action == MOUSE_DOWN ? SDL_PRESSED : SDL_RELEASED, GetKeysym(SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_0)) ,&keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( action == MOUSE_DOWN ? SDL_PRESSED : SDL_RELEASED, SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_0)) ); return; } @@ -177,27 +184,22 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouse) ( JNIEnv* env, jobject thiz, j if( pointerId == 0 ) { -#if SDL_VERSION_ATLEAST(1,3,0) -#else -#define SDL_SendMouseMotion(A,B,X,Y) SDL_PrivateMouseMotion(0, 0, X, Y) -#define SDL_SendMouseButton(N, A, B) SDL_PrivateMouseButton( A, B, 0, 0 ) -#endif - SDL_SendMouseMotion(NULL, 0, x, y); + SDL_ANDROID_MainThreadPushMouseMotion(x, y); if( action == MOUSE_UP ) { if( SDL_GetMouseState( NULL, NULL ) & SDL_BUTTON(SDL_BUTTON_LEFT) ) - SDL_SendMouseButton( NULL, SDL_RELEASED, SDL_BUTTON_LEFT ); + SDL_ANDROID_MainThreadPushMouseButton( SDL_RELEASED, SDL_BUTTON_LEFT ); if( SDL_GetMouseState( NULL, NULL ) & SDL_BUTTON(SDL_BUTTON_RIGHT) ) - SDL_SendMouseButton( NULL, SDL_RELEASED, SDL_BUTTON_RIGHT ); + SDL_ANDROID_MainThreadPushMouseButton( SDL_RELEASED, SDL_BUTTON_RIGHT ); SDL_ANDROID_ShowScreenUnderFingerRect.w = SDL_ANDROID_ShowScreenUnderFingerRect.h = 0; SDL_ANDROID_ShowScreenUnderFingerRectSrc.w = SDL_ANDROID_ShowScreenUnderFingerRectSrc.h = 0; if( SDL_ANDROID_ShowScreenUnderFinger ) - SDL_SendMouseMotion(NULL, 0, x > 0 ? x-1 : 0, y); // Move mouse by 1 pixel so it will force screen update and mouse-under-finger window will be removed + SDL_ANDROID_MainThreadPushMouseMotion(x > 0 ? x-1 : 0, y); // Move mouse by 1 pixel so it will force screen update and mouse-under-finger window will be removed } if( action == MOUSE_DOWN ) { if( !leftClickUsesPressure && !leftClickUsesMultitouch ) - SDL_SendMouseButton( NULL, SDL_PRESSED, SDL_BUTTON_LEFT ); + SDL_ANDROID_MainThreadPushMouseButton( SDL_PRESSED, SDL_BUTTON_LEFT ); else action == MOUSE_MOVE; UpdateScreenUnderFingerRect(x, y); @@ -209,9 +211,9 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouse) ( JNIEnv* env, jobject thiz, j int button = leftClickUsesPressure ? SDL_BUTTON_LEFT : SDL_BUTTON_RIGHT; int buttonState = ( force > maxForce || radius > maxRadius ); if( button == SDL_BUTTON_RIGHT && (SDL_GetMouseState( NULL, NULL ) & SDL_BUTTON(SDL_BUTTON_LEFT)) ) - SDL_SendMouseButton( NULL, SDL_RELEASED, SDL_BUTTON_LEFT ); + SDL_ANDROID_MainThreadPushMouseButton( SDL_RELEASED, SDL_BUTTON_LEFT ); if( ( (SDL_GetMouseState( NULL, NULL ) & SDL_BUTTON(button)) != 0 ) != buttonState ) - SDL_SendMouseButton( NULL, buttonState ? SDL_PRESSED : SDL_RELEASED, button ); + SDL_ANDROID_MainThreadPushMouseButton( buttonState ? SDL_PRESSED : SDL_RELEASED, button ); } UpdateScreenUnderFingerRect(x, y); } @@ -220,13 +222,13 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouse) ( JNIEnv* env, jobject thiz, j { if( leftClickUsesMultitouch ) { - SDL_SendMouseButton( NULL, (action == MOUSE_DOWN) ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_LEFT ); + SDL_ANDROID_MainThreadPushMouseButton( (action == MOUSE_DOWN) ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_LEFT ); } else if( rightClickMethod == RIGHT_CLICK_WITH_MULTITOUCH ) { if( SDL_GetMouseState( NULL, NULL ) & SDL_BUTTON(SDL_BUTTON_LEFT) ) - SDL_SendMouseButton( NULL, SDL_RELEASED, SDL_BUTTON_LEFT ); - SDL_SendMouseButton( NULL, (action == MOUSE_DOWN) ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_RIGHT ); + SDL_ANDROID_MainThreadPushMouseButton( SDL_RELEASED, SDL_BUTTON_LEFT ); + SDL_ANDROID_MainThreadPushMouseButton( (action == MOUSE_DOWN) ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_RIGHT ); } } } @@ -243,35 +245,17 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeKey) ( JNIEnv* env, jobject thiz, jint return; if( key == KEYCODE_MENU && rightClickMethod == RIGHT_CLICK_WITH_MENU_BUTTON ) { - SDL_SendMouseButton( NULL, action ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_RIGHT ); + SDL_ANDROID_MainThreadPushMouseButton( action ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_RIGHT ); return; } SDL_keysym keysym; - SDL_SendKeyboardKey( action ? SDL_PRESSED : SDL_RELEASED, TranslateKey(key ,&keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( action ? SDL_PRESSED : SDL_RELEASED, TranslateKey(key) ); } JNIEXPORT void JNICALL JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeTextInput) ( JNIEnv* env, jobject thiz, jint ascii, jint unicode ) { - SDL_keysym keysym; - keysym.scancode = ascii; - keysym.sym = ascii; - keysym.mod = KMOD_NONE; - keysym.unicode = 0; - if ( SDL_TranslateUNICODE ) { - /* Populate the unicode field with the ASCII value */ - keysym.unicode = unicode; - } - -#if SDL_VERSION_ATLEAST(1,3,0) - char text[2]; - text[0]=ascii; - text[1]=0; - SDL_SendKeyboardText(text); -#else - SDL_SendKeyboardKey( SDL_PRESSED, &keysym ); - SDL_SendKeyboardKey( SDL_RELEASED, &keysym ); -#endif + SDL_ANDROID_MainThreadPushText(ascii, unicode); } @@ -530,12 +514,12 @@ void updateOrientation ( float accX, float accY, float accZ ) //__android_log_print(ANDROID_LOG_INFO, "libSDL", "updateOrientation(): %f %f %f", accX, accY, accZ); - if( SDL_ANDROID_isJoystickUsed && SDL_ANDROID_CurrentJoysticks[0] ) // TODO: mutex for that stuff? + if( SDL_ANDROID_isJoystickUsed ) // TODO: mutex for that stuff? { //__android_log_print(ANDROID_LOG_INFO, "libSDL", "updateOrientation(): sending joystick event"); - SDL_PrivateJoystickAxis(SDL_ANDROID_CurrentJoysticks[0], 0, (Sint16)(fminf(32767.0f, fmax(-32767.0f, -(accX - midX) * joystickSensitivity)))); - SDL_PrivateJoystickAxis(SDL_ANDROID_CurrentJoysticks[0], 1, (Sint16)(fminf(32767.0f, fmax(-32767.0f, (accY - midY) * joystickSensitivity)))); - SDL_PrivateJoystickAxis(SDL_ANDROID_CurrentJoysticks[0], 2, (Sint16)(fminf(32767.0f, fmax(-32767.0f, (accZ - midZ) * joystickSensitivity)))); + SDL_ANDROID_MainThreadPushJoystickAxis(0, 0, (Sint16)(fminf(32767.0f, fmax(-32767.0f, -(accX - midX) * joystickSensitivity)))); + SDL_ANDROID_MainThreadPushJoystickAxis(0, 1, (Sint16)(fminf(32767.0f, fmax(-32767.0f, (accY - midY) * joystickSensitivity)))); + SDL_ANDROID_MainThreadPushJoystickAxis(0, 2, (Sint16)(fminf(32767.0f, fmax(-32767.0f, (accZ - midZ) * joystickSensitivity)))); if( accelerometerCenterPos == ACCELEROMETER_CENTER_FLOATING ) { @@ -559,7 +543,7 @@ void updateOrientation ( float accX, float accY, float accZ ) { //__android_log_print(ANDROID_LOG_INFO, "libSDL", "Accelerometer: press left, acc %f mid %f d %f", accX, midX, dx); pressLeft = 1; - SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(KEYCODE_DPAD_LEFT, &keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(KEYCODE_DPAD_LEFT) ); } } else @@ -568,7 +552,7 @@ void updateOrientation ( float accX, float accY, float accZ ) { //__android_log_print(ANDROID_LOG_INFO, "libSDL", "Accelerometer: release left, acc %f mid %f d %f", accX, midX, dx); pressLeft = 0; - SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_LEFT, &keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_LEFT) ); } } if( accX < midX - dx*2 ) @@ -580,7 +564,7 @@ void updateOrientation ( float accX, float accY, float accZ ) { //__android_log_print(ANDROID_LOG_INFO, "libSDL", "Accelerometer: press right, acc %f mid %f d %f", accX, midX, dx); pressRight = 1; - SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(KEYCODE_DPAD_RIGHT, &keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(KEYCODE_DPAD_RIGHT) ); } } else @@ -589,7 +573,7 @@ void updateOrientation ( float accX, float accY, float accZ ) { //__android_log_print(ANDROID_LOG_INFO, "libSDL", "Accelerometer: release right, acc %f mid %f d %f", accX, midX, dx); pressRight = 0; - SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_RIGHT, &keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_RIGHT) ); } } if( accX > midX + dx*2 ) @@ -601,7 +585,7 @@ void updateOrientation ( float accX, float accY, float accZ ) { //__android_log_print(ANDROID_LOG_INFO, "libSDL", "Accelerometer: press up, acc %f mid %f d %f", accY, midY, dy); pressUp = 1; - SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(KEYCODE_DPAD_DOWN, &keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(KEYCODE_DPAD_DOWN) ); } } else @@ -610,7 +594,7 @@ void updateOrientation ( float accX, float accY, float accZ ) { //__android_log_print(ANDROID_LOG_INFO, "libSDL", "Accelerometer: release up, acc %f mid %f d %f", accY, midY, dy); pressUp = 0; - SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_DOWN, &keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_DOWN) ); } } if( accY < midY - dy*2 ) @@ -622,7 +606,7 @@ void updateOrientation ( float accX, float accY, float accZ ) { //__android_log_print(ANDROID_LOG_INFO, "libSDL", "Accelerometer: press down, acc %f mid %f d %f", accY, midY, dy); pressDown = 1; - SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(KEYCODE_DPAD_UP, &keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(KEYCODE_DPAD_UP) ); } } else @@ -631,7 +615,7 @@ void updateOrientation ( float accX, float accY, float accZ ) { //__android_log_print(ANDROID_LOG_INFO, "libSDL", "Accelerometer: release down, acc %f mid %f d %f", accY, midY, dy); pressDown = 0; - SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_UP, &keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_UP) ); } } if( accY > midY + dy*2 ) @@ -642,7 +626,7 @@ void updateOrientation ( float accX, float accY, float accZ ) if( !pressL ) { pressL = 1; - SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(KEYCODE_ALT_LEFT, &keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(KEYCODE_ALT_LEFT) ); } } else @@ -650,7 +634,7 @@ void updateOrientation ( float accX, float accY, float accZ ) if( pressL ) { pressL = 0; - SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_ALT_LEFT, &keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_ALT_LEFT) ); } } if( accZ < midZ - dz*2 ) @@ -661,7 +645,7 @@ void updateOrientation ( float accX, float accY, float accZ ) if( !pressR ) { pressR = 1; - SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(KEYCODE_ALT_RIGHT, &keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(KEYCODE_ALT_RIGHT) ); } } else @@ -669,7 +653,7 @@ void updateOrientation ( float accX, float accY, float accZ ) if( pressR ) { pressR = 0; - SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_ALT_RIGHT, &keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_ALT_RIGHT) ); } } if( accZ > midZ + dz*2 ) @@ -696,18 +680,18 @@ int processAndroidTrackball(int key, int action) if( downPressed ) { downPressed = 0; - SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_DOWN ,&keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_DOWN) ); return 1; } if( !upPressed ) { upPressed = 1; - SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(key ,&keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(key) ); } else { - SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(key ,&keysym) ); - SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(key ,&keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(key) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(key) ); } return 1; } @@ -717,18 +701,18 @@ int processAndroidTrackball(int key, int action) if( upPressed ) { upPressed = 0; - SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_UP ,&keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_UP) ); return 1; } if( !upPressed ) { downPressed = 1; - SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(key ,&keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(key) ); } else { - SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(key ,&keysym) ); - SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(key ,&keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(key) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(key) ); } return 1; } @@ -738,18 +722,18 @@ int processAndroidTrackball(int key, int action) if( rightPressed ) { rightPressed = 0; - SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_RIGHT ,&keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_RIGHT) ); return 1; } if( !leftPressed ) { leftPressed = 1; - SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(key ,&keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(key) ); } else { - SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(key ,&keysym) ); - SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(key ,&keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(key) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(key) ); } return 1; } @@ -759,18 +743,18 @@ int processAndroidTrackball(int key, int action) if( leftPressed ) { leftPressed = 0; - SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_LEFT ,&keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_LEFT) ); return 1; } if( !rightPressed ) { rightPressed = 1; - SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(key ,&keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(key) ); } else { - SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(key ,&keysym) ); - SDL_SendKeyboardKey( SDL_PRESSED, TranslateKey(key ,&keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(key) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, TranslateKey(key) ); } return 1; } @@ -786,13 +770,13 @@ void SDL_ANDROID_processAndroidTrackballDampening() if( SDL_GetTicks() - lastTrackballAction > TrackballDampening ) { if( upPressed ) - SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_UP ,&keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_UP) ); if( downPressed ) - SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_DOWN ,&keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_DOWN) ); if( leftPressed ) - SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_LEFT ,&keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_LEFT) ); if( rightPressed ) - SDL_SendKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_RIGHT ,&keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_RIGHT) ); upPressed = 0; downPressed = 0; leftPressed = 0; @@ -867,3 +851,267 @@ void SDL_SYS_JoystickQuit(void) } +enum { MAX_BUFFERED_EVENTS = 64 }; +static SDL_Event BufferedEvents[MAX_BUFFERED_EVENTS]; +static int BufferedEventsStart = 0, BufferedEventsEnd = 0; +static SDL_mutex * BufferedEventsMutex = NULL; + +#if SDL_VERSION_ATLEAST(1,3,0) + +#define SDL_SendKeyboardKey(state, keysym) SDL_SendKeyboardKey(state, (keysym)->sym) + +#else + +#define SDL_SendMouseMotion(A,B,X,Y) SDL_PrivateMouseMotion(0, 0, X, Y) +#define SDL_SendMouseButton(N, A, B) SDL_PrivateMouseButton( A, B, 0, 0 ) +#define SDL_SendKeyboardKey(state, keysym) SDL_PrivateKeyboard(state, keysym) + +#endif + +extern void SDL_ANDROID_PumpEvents() +{ + if( !BufferedEventsMutex ) + BufferedEventsMutex = SDL_CreateMutex(); + SDL_mutexP(BufferedEventsMutex); + while( BufferedEventsStart != BufferedEventsEnd ) + { + SDL_Event * ev = &BufferedEvents[BufferedEventsStart]; + + switch( ev->type ) + { + case SDL_MOUSEMOTION: + SDL_SendMouseMotion(NULL, 0, ev->motion.x, ev->motion.y); + break; + case SDL_MOUSEBUTTONDOWN: + SDL_SendMouseButton( NULL, ev->button.state, ev->button.button ); + break; + case SDL_KEYDOWN: + SDL_SendKeyboardKey( ev->key.state, &ev->key.keysym ); + break; + case SDL_JOYAXISMOTION: + if( ev->jaxis.which < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[ev->jaxis.which] ) + SDL_PrivateJoystickAxis( SDL_ANDROID_CurrentJoysticks[ev->jaxis.which], ev->jaxis.axis, ev->jaxis.value ); + break; + case SDL_JOYBUTTONDOWN: + if( ev->jbutton.which < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[ev->jbutton.which] ) + SDL_PrivateJoystickButton( SDL_ANDROID_CurrentJoysticks[ev->jbutton.which], ev->jbutton.button, ev->jbutton.state ); + break; +#if SDL_VERSION_ATLEAST(1,3,0) + case SDL_FINGERMOTION: + SDL_SendTouchMotion(0, ev->tfinger.fingerId, 0, ev->tfinger.x, ev->tfinger.y, ev->tfinger.pressure); + break; + case SDL_FINGERDOWN: + SDL_SendFingerDown(0, ev->tfinger.fingerId, ev->tfinger.state ? 1 : 0, ev->tfinger.x, ev->tfinger.y, ev->tfinger.pressure); + break; + case SDL_TEXTINPUT: + SDL_SendKeyboardText(ev->text.text); + break; +#endif + } + + ev->type = 0; + BufferedEventsStart++; + if( BufferedEventsStart >= MAX_BUFFERED_EVENTS ) + BufferedEventsStart = 0; + } + SDL_mutexV(BufferedEventsMutex); +}; +// Queue events to main thread +static int getNextEvent() +{ + int nextEvent; + if( !BufferedEventsMutex ) + return -1; + SDL_mutexP(BufferedEventsMutex); + nextEvent = BufferedEventsEnd; + nextEvent++; + if( nextEvent >= MAX_BUFFERED_EVENTS ) + nextEvent = 0; + while( nextEvent == BufferedEventsStart ) + { + SDL_mutexV(BufferedEventsMutex); + SDL_Delay(100); + SDL_mutexP(BufferedEventsMutex); + nextEvent = BufferedEventsEnd; + nextEvent++; + if( nextEvent >= MAX_BUFFERED_EVENTS ) + nextEvent = 0; + } + return nextEvent; +} + +extern void SDL_ANDROID_MainThreadPushMouseMotion(int x, int y) +{ + int nextEvent = getNextEvent(); + if( nextEvent == -1 ) + return; + + SDL_Event * ev = &BufferedEvents[BufferedEventsEnd]; + + ev->type = SDL_MOUSEMOTION; + ev->motion.x = x; + ev->motion.y = y; + + BufferedEventsEnd = nextEvent; + SDL_mutexV(BufferedEventsMutex); +}; +extern void SDL_ANDROID_MainThreadPushMouseButton(int pressed, int button) +{ + int nextEvent = getNextEvent(); + if( nextEvent == -1 ) + return; + + SDL_Event * ev = &BufferedEvents[BufferedEventsEnd]; + + ev->type = SDL_MOUSEBUTTONDOWN; + ev->button.state = pressed; + ev->button.button = button; + + BufferedEventsEnd = nextEvent; + SDL_mutexV(BufferedEventsMutex); +}; + +extern void SDL_ANDROID_MainThreadPushKeyboardKey(int pressed, SDL_scancode scancode) +{ + int nextEvent = getNextEvent(); + if( nextEvent == -1 ) + return; + + SDL_Event * ev = &BufferedEvents[BufferedEventsEnd]; + + ev->type = SDL_KEYDOWN; + ev->key.state = pressed; + ev->key.keysym.scancode = scancode; + ev->key.keysym.sym = scancode; + ev->key.keysym.mod = KMOD_NONE; + ev->key.keysym.unicode = 0; + if ( SDL_TranslateUNICODE ) + ev->key.keysym.unicode = scancode; + + BufferedEventsEnd = nextEvent; + SDL_mutexV(BufferedEventsMutex); +}; +extern void SDL_ANDROID_MainThreadPushJoystickAxis(int joy, int axis, int value) +{ + if( ! ( joy < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[joy] ) ) + return; + + int nextEvent = getNextEvent(); + if( nextEvent == -1 ) + return; + + SDL_Event * ev = &BufferedEvents[BufferedEventsEnd]; + + ev->type = SDL_JOYAXISMOTION; + ev->jaxis.which = joy; + ev->jaxis.axis = axis; + ev->jaxis.value = value; + + BufferedEventsEnd = nextEvent; + SDL_mutexV(BufferedEventsMutex); +}; +extern void SDL_ANDROID_MainThreadPushJoystickButton(int joy, int button, int pressed) +{ + if( ! ( joy < MAX_MULTITOUCH_POINTERS+1 && SDL_ANDROID_CurrentJoysticks[joy] ) ) + return; + + int nextEvent = getNextEvent(); + if( nextEvent == -1 ) + return; + + SDL_Event * ev = &BufferedEvents[BufferedEventsEnd]; + + ev->type = SDL_JOYBUTTONDOWN; + ev->jbutton.which = joy; + ev->jbutton.button = button; + ev->jbutton.state = pressed; + + BufferedEventsEnd = nextEvent; + SDL_mutexV(BufferedEventsMutex); +}; +extern void SDL_ANDROID_MainThreadPushMultitouchButton(int id, int pressed, int x, int y, int force) +{ +#if SDL_VERSION_ATLEAST(1,3,0) + int nextEvent = getNextEvent(); + if( nextEvent == -1 ) + return; + + SDL_Event * ev = &BufferedEvents[BufferedEventsEnd]; + + ev->type = SDL_FINGERDOWN: + ev->tfinger.fingerId = id; + ev->tfinger.state = pressed; + ev->tfinger.x = x; + ev->tfinger.y = y; + ev->tfinger.pressure = force; + + BufferedEventsEnd = nextEvent; + SDL_mutexV(BufferedEventsMutex); +#endif +}; +extern void SDL_ANDROID_MainThreadPushMultitouchMotion(int id, int x, int y, int force) +{ +#if SDL_VERSION_ATLEAST(1,3,0) + int nextEvent = getNextEvent(); + if( nextEvent == -1 ) + return; + + SDL_Event * ev = &BufferedEvents[BufferedEventsEnd]; + + ev->type = SDL_FINGERMOTION: + ev->tfinger.fingerId = id; + ev->tfinger.x = x; + ev->tfinger.y = y; + ev->tfinger.pressure = force; + + BufferedEventsEnd = nextEvent; + SDL_mutexV(BufferedEventsMutex); +#endif +}; +extern void SDL_ANDROID_MainThreadPushText( int scancode, int unicode ) +{ + int nextEvent = getNextEvent(); + if( nextEvent == -1 ) + return; + + SDL_Event * ev = &BufferedEvents[BufferedEventsEnd]; + +#if SDL_VERSION_ATLEAST(1,3,0) + + // TODO: convert to UTF-8 + ev->type = SDL_TEXTINPUT; + ev->text.text[0] = scancode; + ev->text.text[1] = 0; + +#else + + ev->type = SDL_KEYDOWN; + ev->key.state = SDL_PRESSED; + ev->key.keysym.scancode = scancode; + ev->key.keysym.sym = scancode; + ev->key.keysym.mod = KMOD_NONE; + ev->key.keysym.unicode = 0; + if ( SDL_TranslateUNICODE ) + ev->key.keysym.unicode = unicode; + BufferedEventsEnd = nextEvent; + SDL_mutexV(BufferedEventsMutex); + + nextEvent = getNextEvent(); + { + SDL_Event * ev = &BufferedEvents[BufferedEventsEnd]; + ev->type = SDL_KEYUP; + ev->key.state = SDL_PRESSED; + ev->key.keysym.scancode = scancode; + ev->key.keysym.sym = scancode; + ev->key.keysym.mod = KMOD_NONE; + ev->key.keysym.unicode = 0; + if ( SDL_TranslateUNICODE ) + ev->key.keysym.unicode = unicode; + } + +#endif + + BufferedEventsEnd = nextEvent; + SDL_mutexV(BufferedEventsMutex); +}; + diff --git a/project/jni/sdl-1.3/src/video/android/SDL_androidinput.h b/project/jni/sdl-1.3/src/video/android/SDL_androidinput.h index 7bdd77bb6..1b3d110d0 100644 --- a/project/jni/sdl-1.3/src/video/android/SDL_androidinput.h +++ b/project/jni/sdl-1.3/src/video/android/SDL_androidinput.h @@ -50,8 +50,6 @@ #include "SDL_androidvideo.h" #include "javakeycodes.h" -extern SDLKey SDL_android_keymap[KEYCODE_LAST+1]; - /* JNI-C++ wrapper stuff */ #if SDL_VERSION_ATLEAST(1,3,0) @@ -59,27 +57,11 @@ extern SDLKey SDL_android_keymap[KEYCODE_LAST+1]; #define SDL_KEY2(X) SDL_SCANCODE_ ## X #define SDL_KEY(X) SDL_KEY2(X) -static inline SDL_scancode TranslateKey(int scancode, SDL_keysym *keysym) -{ - if ( scancode >= SDL_arraysize(SDL_android_keymap) ) - scancode = KEYCODE_UNKNOWN; - return SDL_android_keymap[scancode]; -} - -static inline SDL_scancode GetKeysym(SDL_scancode scancode, SDL_keysym *keysym) -{ - return scancode; -} - -//#define SDL_SendKeyboardKey(X, Y, Z) SDL_SendKeyboardKey(X, Y) - #else #define SDL_KEY2(X) SDLK_ ## X #define SDL_KEY(X) SDL_KEY2(X) -#define SDL_SendKeyboardKey SDL_PrivateKeyboard - // Randomly redefining SDL 1.3 scancodes to SDL 1.2 keycodes #define KP_0 KP0 #define KP_1 KP1 @@ -123,47 +105,9 @@ static inline SDL_scancode GetKeysym(SDL_scancode scancode, SDL_keysym *keysym) #define Y y #define Z z -#define SDL_scancode SDLKey +typedef SDLKey SDL_scancode; #define SDL_GetKeyboardState SDL_GetKeyState -static inline SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym) -{ - /* Sanity check */ - if ( scancode >= SDL_arraysize(SDL_android_keymap) ) - scancode = KEYCODE_UNKNOWN; - - /* Set the keysym information */ - keysym->scancode = scancode; - keysym->sym = SDL_android_keymap[scancode]; - keysym->mod = KMOD_NONE; - - /* If UNICODE is on, get the UNICODE value for the key */ - keysym->unicode = 0; - if ( SDL_TranslateUNICODE ) { - /* Populate the unicode field with the ASCII value */ - keysym->unicode = scancode; - } - return(keysym); -} - -static inline SDL_keysym *GetKeysym(SDLKey scancode, SDL_keysym *keysym) -{ - /* Sanity check */ - - /* Set the keysym information */ - keysym->scancode = scancode; - keysym->sym = scancode; - keysym->mod = KMOD_NONE; - - /* If UNICODE is on, get the UNICODE value for the key */ - keysym->unicode = 0; - if ( SDL_TranslateUNICODE ) { - /* Populate the unicode field with the ASCII value */ - keysym->unicode = scancode; - } - return(keysym); -} - #endif #define SDL_KEY_VAL(X) X @@ -207,4 +151,15 @@ extern int SDL_ANDROID_isTouchscreenKeyboardUsed; #define SDL_ANDROID_KEYCODE_10 SDL_ANDROID_KEYCODE_1 #endif + +// 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_MainThreadPushMultitouchButton(int id, int pressed, int x, int y, int force); +extern void SDL_ANDROID_MainThreadPushMultitouchMotion(int id, int x, int y, int force); +extern void SDL_ANDROID_MainThreadPushJoystickAxis(int joy, int axis, int value); +extern void SDL_ANDROID_MainThreadPushJoystickButton(int joy, int button, int pressed); +extern void SDL_ANDROID_MainThreadPushText( int ascii, int unicode ); + #endif diff --git a/project/jni/sdl-1.3/src/video/android/SDL_androidvideo-1.3.c b/project/jni/sdl-1.3/src/video/android/SDL_androidvideo-1.3.c index a58ad2b88..08df551d3 100644 --- a/project/jni/sdl-1.3/src/video/android/SDL_androidvideo-1.3.c +++ b/project/jni/sdl-1.3/src/video/android/SDL_androidvideo-1.3.c @@ -172,6 +172,7 @@ void ANDROID_VideoQuit(_THIS) void ANDROID_PumpEvents(_THIS) { + SDL_ANDROID_PumpEvents(); } void ANDROID_GL_SwapBuffers(_THIS, SDL_Window * window) diff --git a/project/jni/sdl-1.3/src/video/android/SDL_androidvideo.h b/project/jni/sdl-1.3/src/video/android/SDL_androidvideo.h index 2fa0cfd39..16bc19bee 100644 --- a/project/jni/sdl-1.3/src/video/android/SDL_androidvideo.h +++ b/project/jni/sdl-1.3/src/video/android/SDL_androidvideo.h @@ -26,6 +26,7 @@ #include "SDL_config.h" #include "SDL_video.h" #include "SDL_joystick.h" +#include "SDL_events.h" extern int SDL_ANDROID_sWindowWidth; extern int SDL_ANDROID_sWindowHeight; @@ -53,6 +54,8 @@ extern SDL_Window * ANDROID_CurrentWindow; enum { MAX_MULTITOUCH_POINTERS = 16 }; extern void ANDROID_InitOSKeymap(); extern int SDL_ANDROID_isJoystickUsed; -extern SDL_Joystick *SDL_ANDROID_CurrentJoysticks[MAX_MULTITOUCH_POINTERS+1]; +// Events have to be sent only from main thread from PumpEvents(), so we'll buffer them here +extern void SDL_ANDROID_PumpEvents(); + #endif /* _SDL_androidvideo_h */ diff --git a/project/jni/sdl-1.3/src/video/android/SDL_touchscreenkeyboard.c b/project/jni/sdl-1.3/src/video/android/SDL_touchscreenkeyboard.c index dbef1ce9c..57b9abc51 100644 --- a/project/jni/sdl-1.3/src/video/android/SDL_touchscreenkeyboard.c +++ b/project/jni/sdl-1.3/src/video/android/SDL_touchscreenkeyboard.c @@ -373,7 +373,6 @@ static inline int ArrowKeysPressed(int x, int y) int SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int pointerId) { int i; - SDL_keysym keysym; int processed = 0; @@ -392,23 +391,20 @@ int SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int pointer pointerInButtonRect[MAX_BUTTONS] = pointerId; if( SDL_ANDROID_isJoystickUsed ) { - if( SDL_ANDROID_CurrentJoysticks[0] != NULL ) - { - SDL_PrivateJoystickAxis(SDL_ANDROID_CurrentJoysticks[0], 0, -(x - arrows.x - arrows.w / 2) * 65534 / arrows.w ); - SDL_PrivateJoystickAxis(SDL_ANDROID_CurrentJoysticks[0], 1, -(y - arrows.y - arrows.h / 2) * 65534 / arrows.h ); - } + SDL_ANDROID_MainThreadPushJoystickAxis(0, 0, -(x - arrows.x - arrows.w / 2) * 65534 / arrows.w ); + SDL_ANDROID_MainThreadPushJoystickAxis(0, 1, -(y - arrows.y - arrows.h / 2) * 65534 / arrows.h ); } else { i = ArrowKeysPressed(x, y); if( i & ARROW_UP ) - SDL_SendKeyboardKey( SDL_PRESSED, GetKeysym( SDL_KEY(UP), &keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(UP) ); if( i & ARROW_DOWN ) - SDL_SendKeyboardKey( SDL_PRESSED, GetKeysym( SDL_KEY(DOWN), &keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(DOWN) ); if( i & ARROW_LEFT ) - SDL_SendKeyboardKey( SDL_PRESSED, GetKeysym( SDL_KEY(LEFT), &keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(LEFT) ); if( i & ARROW_RIGHT ) - SDL_SendKeyboardKey( SDL_PRESSED, GetKeysym( SDL_KEY(RIGHT), &keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(RIGHT) ); oldArrows = i; } } @@ -427,7 +423,7 @@ int SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int pointer if( i == BUTTON_TEXT_INPUT ) SDL_ANDROID_ToggleScreenKeyboardTextInput(); else - SDL_SendKeyboardKey( SDL_PRESSED, GetKeysym(buttonKeysyms[i], &keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, buttonKeysyms[i] ); if( i < AutoFireButtonsNum ) { ButtonAutoFire[i] = 0; @@ -458,18 +454,15 @@ int SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int pointer pointerInButtonRect[MAX_BUTTONS] = -1; if( SDL_ANDROID_isJoystickUsed ) { - if( SDL_ANDROID_CurrentJoysticks[0] ) - { - SDL_PrivateJoystickAxis(SDL_ANDROID_CurrentJoysticks[0], 0, 0 ); - SDL_PrivateJoystickAxis(SDL_ANDROID_CurrentJoysticks[0], 1, 0 ); - } + SDL_ANDROID_MainThreadPushJoystickAxis(0, 0, 0 ); + SDL_ANDROID_MainThreadPushJoystickAxis(0, 1, 0 ); } else { - SDL_SendKeyboardKey( SDL_RELEASED, GetKeysym( SDL_KEY(UP), &keysym) ); - SDL_SendKeyboardKey( SDL_RELEASED, GetKeysym( SDL_KEY(DOWN), &keysym) ); - SDL_SendKeyboardKey( SDL_RELEASED, GetKeysym( SDL_KEY(LEFT), &keysym) ); - SDL_SendKeyboardKey( SDL_RELEASED, GetKeysym( SDL_KEY(RIGHT), &keysym) ); + 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) ); oldArrows = 0; } } @@ -488,7 +481,7 @@ int SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int pointer else { if( i != BUTTON_TEXT_INPUT ) - SDL_SendKeyboardKey( SDL_RELEASED, GetKeysym(buttonKeysyms[i] ,&keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, buttonKeysyms[i] ); } if( i < AutoFireButtonsNum ) { @@ -521,18 +514,15 @@ int SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int pointer pointerInButtonRect[MAX_BUTTONS] = -1; if( SDL_ANDROID_isJoystickUsed ) { - if( SDL_ANDROID_CurrentJoysticks[0] ) - { - SDL_PrivateJoystickAxis(SDL_ANDROID_CurrentJoysticks[0], 0, 0 ); - SDL_PrivateJoystickAxis(SDL_ANDROID_CurrentJoysticks[0], 1, 0 ); - } + SDL_ANDROID_MainThreadPushJoystickAxis(0, 0, 0 ); + SDL_ANDROID_MainThreadPushJoystickAxis(0, 1, 0 ); } else { - SDL_SendKeyboardKey( SDL_RELEASED, GetKeysym( SDL_KEY(UP), &keysym) ); - SDL_SendKeyboardKey( SDL_RELEASED, GetKeysym( SDL_KEY(DOWN), &keysym) ); - SDL_SendKeyboardKey( SDL_RELEASED, GetKeysym( SDL_KEY(LEFT), &keysym) ); - SDL_SendKeyboardKey( SDL_RELEASED, GetKeysym( SDL_KEY(RIGHT), &keysym) ); + 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) ); oldArrows = 0; } } @@ -540,11 +530,8 @@ int SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int pointer { if( SDL_ANDROID_isJoystickUsed ) { - if( SDL_ANDROID_CurrentJoysticks[0] ) - { - SDL_PrivateJoystickAxis(SDL_ANDROID_CurrentJoysticks[0], 0, -(x - arrows.x - arrows.w / 2) * 65534 / arrows.w ); - SDL_PrivateJoystickAxis(SDL_ANDROID_CurrentJoysticks[0], 1, -(y - arrows.y - arrows.h / 2) * 65534 / arrows.h ); - } + SDL_ANDROID_MainThreadPushJoystickAxis(0, 0, -(x - arrows.x - arrows.w / 2) * 65534 / arrows.w ); + SDL_ANDROID_MainThreadPushJoystickAxis(0, 1, -(y - arrows.y - arrows.h / 2) * 65534 / arrows.h ); } else { @@ -552,21 +539,21 @@ int SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int pointer if( i != oldArrows ) { if( oldArrows & ARROW_UP && ! (i & ARROW_UP) ) - SDL_SendKeyboardKey( SDL_RELEASED, GetKeysym( SDL_KEY(UP), &keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(UP) ); if( oldArrows & ARROW_DOWN && ! (i & ARROW_DOWN) ) - SDL_SendKeyboardKey( SDL_RELEASED, GetKeysym( SDL_KEY(DOWN), &keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(DOWN) ); if( oldArrows & ARROW_LEFT && ! (i & ARROW_LEFT) ) - SDL_SendKeyboardKey( SDL_RELEASED, GetKeysym( SDL_KEY(LEFT), &keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(LEFT) ); if( oldArrows & ARROW_RIGHT && ! (i & ARROW_RIGHT) ) - SDL_SendKeyboardKey( SDL_RELEASED, GetKeysym( SDL_KEY(RIGHT), &keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, SDL_KEY(RIGHT) ); if( i & ARROW_UP ) - SDL_SendKeyboardKey( SDL_PRESSED, GetKeysym( SDL_KEY(UP), &keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(UP) ); if( i & ARROW_DOWN ) - SDL_SendKeyboardKey( SDL_PRESSED, GetKeysym( SDL_KEY(DOWN), &keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(DOWN) ); if( i & ARROW_LEFT ) - SDL_SendKeyboardKey( SDL_PRESSED, GetKeysym( SDL_KEY(LEFT), &keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(LEFT) ); if( i & ARROW_RIGHT ) - SDL_SendKeyboardKey( SDL_PRESSED, GetKeysym( SDL_KEY(RIGHT), &keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_PRESSED, SDL_KEY(RIGHT) ); } oldArrows = i; } @@ -583,7 +570,7 @@ int SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int pointer if( !ButtonAutoFire[i] ) { if( i != BUTTON_TEXT_INPUT ) - SDL_SendKeyboardKey( SDL_RELEASED, GetKeysym(buttonKeysyms[i] ,&keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, buttonKeysyms[i] ); } else { @@ -648,7 +635,7 @@ int SDL_ANDROID_processTouchscreenKeyboard(int x, int y, int action, int pointer { pointerInButtonRect[i] = -1; if( i != BUTTON_TEXT_INPUT ) - SDL_SendKeyboardKey( SDL_RELEASED, GetKeysym(buttonKeysyms[i] ,&keysym) ); + SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, buttonKeysyms[i] ); } } }