SDL: do not move mouse position when toggling text input, it will unfocus the text input field in the game

This commit is contained in:
Sergii Pylypenko
2021-05-24 00:41:22 +03:00
parent 5e27a1f850
commit fc47eac67f
4 changed files with 11 additions and 3 deletions

View File

@@ -464,6 +464,12 @@ static void SendMultitouchEvents( int x, int y, int action, int pointerId, int f
SDL_ANDROID_MainThreadPushJoystickBall(JOY_TOUCHSCREEN, pointerId, x, y);
if( action == MOUSE_UP )
SDL_ANDROID_MainThreadPushJoystickButton(JOY_TOUCHSCREEN, pointerId, SDL_RELEASED);
if( !SDL_ANDROID_isMouseUsed && pointerId == 0 )
{
// Set mouse coordinates to track the first touch pointer, they are used elsewhere but not updated when mouse events are disabled
SDL_ANDROID_currentMouseX = x;
SDL_ANDROID_currentMouseY = y;
}
}
if( !isMultitouchUsed && !SDL_ANDROID_isMouseUsed && !SDL_ANDROID_isTouchscreenKeyboardUsed )

View File

@@ -281,7 +281,9 @@ void SDL_ANDROID_CallJavaShowScreenKeyboard(const char * oldText, char * outBuf,
SDL_ANDROID_MainThreadPushMouseButton( SDL_RELEASED, SDL_BUTTON_LEFT );
SDL_ANDROID_MainThreadPushMouseButton( SDL_RELEASED, SDL_BUTTON_RIGHT );
SDL_ANDROID_MainThreadPushMouseButton( SDL_RELEASED, SDL_BUTTON_MIDDLE );
for (i = 0; i < MAX_MULTITOUCH_POINTERS; i++)
//__android_log_print(ANDROID_LOG_INFO, "libSDL", "Releasing all touch pointers: mouse at %4d %4d", SDL_ANDROID_currentMouseX, SDL_ANDROID_currentMouseY);
JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMotionEvent) ( NULL, NULL, SDL_ANDROID_currentMouseX, SDL_ANDROID_currentMouseY, MOUSE_UP, 0, 0, 0 );
for (i = 1; i < MAX_MULTITOUCH_POINTERS; i++)
{
JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMotionEvent) ( NULL, NULL, 0, 0, MOUSE_UP, i, 0, 0 );
}