diff --git a/project/jni/application/fheroes2/AndroidAppSettings.cfg b/project/jni/application/fheroes2/AndroidAppSettings.cfg index c615973a5..18e5d0be1 100644 --- a/project/jni/application/fheroes2/AndroidAppSettings.cfg +++ b/project/jni/application/fheroes2/AndroidAppSettings.cfg @@ -11,7 +11,7 @@ SdlVideoResizeKeepAspect=n NeedDepthBuffer=n AppUsesMouse=y AppNeedsTwoButtonMouse=y -AppNeedsArrowKeys=y +AppNeedsArrowKeys=n AppNeedsTextInput=y AppUsesJoystick=n AppHandlesJoystickSensitivity=n 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 6a59cccea..c36d8db09 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 @@ -73,7 +73,7 @@ int SDL_ANDROID_isJoystickUsed = 0; static int isMultitouchUsed = 0; SDL_Joystick *SDL_ANDROID_CurrentJoysticks[MAX_MULTITOUCH_POINTERS+1] = {NULL}; static int TrackballDampening = 0; // in milliseconds -static int lastTrackballAction = 0; +static Uint32 lastTrackballAction = 0; static inline int InsideRect(const SDL_Rect * r, int x, int y) @@ -403,157 +403,6 @@ JAVA_EXPORT_NAME(Settings_nativeSetMultitouchUsed) ( JNIEnv* env, jobject thiz) isMultitouchUsed = 1; } -void ANDROID_InitOSKeymap() -{ - int i; - SDLKey * keymap = SDL_android_keymap; - -#if (SDL_VERSION_ATLEAST(1,3,0)) - SDLKey defaultKeymap[SDL_NUM_SCANCODES]; - SDL_GetDefaultKeymap(defaultKeymap); - SDL_SetKeymap(0, defaultKeymap, SDL_NUM_SCANCODES); - - SDL_Touch touch; - memset( &touch, 0, sizeof(touch) ); - touch.x_min = touch.y_min = touch.pressure_min = 0.0f; - touch.pressure_max = 1000000; - touch.x_max = SDL_ANDROID_sWindowWidth; - touch.y_max = SDL_ANDROID_sWindowHeight; - - // These constants are hardcoded inside SDL_touch.c, which makes no sense for me. - touch.xres = touch.yres = 32768; - touch.native_xres = touch.native_yres = 32768.0f; - - touch.pressureres = 1; - touch.native_pressureres = 1.0f; - touch.id = 0; - - SDL_AddTouch(&touch, "Android touch screen"); - -#endif - - // TODO: keys are mapped rather randomly - - for (i=0; i TrackballDampening ) + if( SDL_GetTicks() > TrackballDampening + lastTrackballAction ) { if( upPressed ) SDL_ANDROID_MainThreadPushKeyboardKey( SDL_RELEASED, TranslateKey(KEYCODE_DPAD_UP) ); @@ -956,6 +804,9 @@ static SDL_mutex * BufferedEventsMutex = NULL; extern void SDL_ANDROID_PumpEvents() { + SDL_ANDROID_processAndroidTrackballDampening(); + SDL_ANDROID_processMoveMouseWithKeyboard(); + if( !BufferedEventsMutex ) BufferedEventsMutex = SDL_CreateMutex(); SDL_mutexP(BufferedEventsMutex); @@ -1271,15 +1122,178 @@ extern void SDL_ANDROID_MainThreadPushText( int scancode, int unicode ) SDL_mutexV(BufferedEventsMutex); }; + +Uint32 lastMoveMouseWithKeyboardUpdate = 0; + void SDL_ANDROID_processMoveMouseWithKeyboard() { + if( moveMouseWithKbUpdateSpeedX == 0 && moveMouseWithKbUpdateSpeedY == 0 ) + return; + + Uint32 ticks = SDL_GetTicks(); + + if( ticks - lastMoveMouseWithKeyboardUpdate < 20 ) // Update at 50 FPS max, or it will not work properlty on very fast devices + return; + + lastMoveMouseWithKeyboardUpdate = ticks; + moveMouseWithKbXspeed += moveMouseWithKbUpdateSpeedX; moveMouseWithKbYspeed += moveMouseWithKbUpdateSpeedY; - - if( moveMouseWithKbXspeed != 0 || moveMouseWithKbYspeed != 0) - { - moveMouseWithKbX += moveMouseWithKbXspeed; - moveMouseWithKbY += moveMouseWithKbYspeed; - SDL_ANDROID_MainThreadPushMouseMotion(moveMouseWithKbX, moveMouseWithKbY); - } + + moveMouseWithKbX += moveMouseWithKbXspeed; + moveMouseWithKbY += moveMouseWithKbYspeed; + SDL_ANDROID_MainThreadPushMouseMotion(moveMouseWithKbX, moveMouseWithKbY); }; + + +void ANDROID_InitOSKeymap() +{ + int i; + SDLKey * keymap = SDL_android_keymap; + +#if (SDL_VERSION_ATLEAST(1,3,0)) + SDLKey defaultKeymap[SDL_NUM_SCANCODES]; + SDL_GetDefaultKeymap(defaultKeymap); + SDL_SetKeymap(0, defaultKeymap, SDL_NUM_SCANCODES); + + SDL_Touch touch; + memset( &touch, 0, sizeof(touch) ); + touch.x_min = touch.y_min = touch.pressure_min = 0.0f; + touch.pressure_max = 1000000; + touch.x_max = SDL_ANDROID_sWindowWidth; + touch.y_max = SDL_ANDROID_sWindowHeight; + + // These constants are hardcoded inside SDL_touch.c, which makes no sense for me. + touch.xres = touch.yres = 32768; + touch.native_xres = touch.native_yres = 32768.0f; + + touch.pressureres = 1; + touch.native_pressureres = 1.0f; + touch.id = 0; + + SDL_AddTouch(&touch, "Android touch screen"); + +#endif + + // TODO: keys are mapped rather randomly + + for (i=0; i