SDL: fixed SdlVideoResizeKeepAspect=y messing up mouse position after restoring app from background

This commit is contained in:
Sergii Pylypenko
2018-09-20 21:01:04 +03:00
parent aa7919811f
commit bef5f545c5
9 changed files with 21 additions and 16 deletions

View File

@@ -996,7 +996,7 @@ public class Settings
private static native int nativeGetKeymapKeyMultitouchGesture(int keynum);
private static native void nativeSetKeymapKeyMultitouchGesture(int keynum, int key);
private static native void nativeSetMultitouchGestureSensitivity(int sensitivity);
private static native void nativeSetTouchscreenCalibration(int x1, int y1, int x2, int y2);
public static native void nativeSetTouchscreenCalibration(int x1, int y1, int x2, int y2);
public static native void nativeSetEnv(final String name, final String value);
public static native int nativeChmod(final String name, int mode);
public static native void nativeChdir(final String dir);

View File

@@ -664,6 +664,9 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
mHeight = h - h % 2;
mGl = gl;
nativeResize(mWidth, mHeight, Globals.KeepAspectRatio ? 1 : 0);
if( Globals.TouchscreenCalibration[2] > Globals.TouchscreenCalibration[0] )
Settings.nativeSetTouchscreenCalibration(Globals.TouchscreenCalibration[0], Globals.TouchscreenCalibration[1],
Globals.TouchscreenCalibration[2], Globals.TouchscreenCalibration[3]);
}
int mLastPendingResize = 0;

View File

@@ -65,7 +65,7 @@ SwVideoMode=y
SdlVideoResize=y
# Application resizing will keep 4:3 aspect ratio, with black bars at sides (y)/(n)
SdlVideoResizeKeepAspect=n
SdlVideoResizeKeepAspect=y
# Do not allow device to sleep when the application is in foreground, set this for video players or apps which use accelerometer
InhibitSuspend=y
@@ -135,7 +135,7 @@ ScreenFollowsMouse=
GenerateSubframeTouchEvents=n
# Force relative (laptop) mouse movement mode, useful when both on-screen keyboard and mouse are needed (y) or (n)
ForceRelativeMouseMode=y
ForceRelativeMouseMode=n
# Show on-screen dpad/joystick, that will act as arrow keys (y) or (n)
AppNeedsArrowKeys=y
@@ -149,7 +149,7 @@ AppNeedsTextInput=y
# Application uses joystick (y) or (n), the on-screen DPAD will be used as joystick 0 axes 0-1
# This will disable AppNeedsArrowKeys option
AppUsesJoystick=n
AppUsesJoystick=y
# Application uses second on-screen joystick, as SDL joystick 0 axes 2-3 (y)/(n)
AppUsesSecondJoystick=n
@@ -225,7 +225,7 @@ RedefinedKeysScreenKbNames="0 1 2 3 4 5 6 7 8 9"
# 7 = SuperNintendo from RetroArch
# 8 = DualShock from RetroArch
# 9 = Nintendo64 from RetroArch
TouchscreenKeysTheme=3
TouchscreenKeysTheme=1
# Redefine gamepad keys to SDL keysyms, button order is:
# A B X Y L1 R1 L2 R2 LThumb RThumb Start Select Up Down Left Right LThumbUp LThumbDown LThumbLeft LThumbRight RThumbUp RThumbDown RThumbLeft RThumbRight
@@ -251,7 +251,7 @@ HiddenMenuOptions=''
# new SettingsMenuMisc.ShowReadme(), (AppUsesMouse \&\& \! ForceRelativeMouseMode \? new SettingsMenuMouse.DisplaySizeConfig(true) : new SettingsMenu.DummyMenu()), new SettingsMenuMisc.OptionalDownloadConfig(true), new SettingsMenuMisc.GyroscopeCalibration()
# Available menu items:
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.CommandlineConfig SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout SettingsMenuKeyboard.ScreenKeyboardAdvanced
FirstStartMenuOptions='SettingsMenu.DummyMenu'
FirstStartMenuOptions=''
# Minimum amount of RAM application requires, in Mb, SDL will print warning to user if it's lower
AppMinimumRAM=0

View File

@@ -29,7 +29,7 @@
----------------------------------------------------------*/
#define SCREEN_W 640
#define SCREEN_H 256
#define SCREEN_H 540
#define BALLS 300
@@ -635,8 +635,8 @@ int main(int argc, char* argv[])
continue;
r.x = touchPointers[i].x;
r.y = touchPointers[i].y;
r.w = 50 + touchPointers[i].pressure / 5;
r.h = 50 + touchPointers[i].pressure / 5;
r.w = 50;// + touchPointers[i].pressure / 5;
r.h = 50;// + touchPointers[i].pressure / 5;
r.x -= r.w/2;
r.y -= r.h/2;
SDL_FillRect(screen, &r, colors[i]);

View File

@@ -78,7 +78,7 @@ extern void SDL_ANDROID_MainThreadPushMouseMotion(int x, int y)
{
SDL_ANDROID_currentMouseX = x;
SDL_ANDROID_currentMouseY = y;
__android_log_print(ANDROID_LOG_INFO, "libSDL", "MainThreadPushMouseMotion: %4d %4d", x, y);
SDL_SendMouseMotion( ANDROID_CurrentWindow, 0, x, y );
}

View File

@@ -856,7 +856,7 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMotionEvent) ( JNIEnv* env, jobject t
return;
#endif
//__android_log_print(ANDROID_LOG_INFO, "libSDL", "Motion event: %4d %4d action %d ptr %d, force %d radius %d", x, y, action, pointerId, force, radius);
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Motion event: %4d %4d action %d ptr %d, force %d radius %d", x, y, action, pointerId, force, radius);
pointerId = BumpPointerId( pointerId );

View File

@@ -429,7 +429,7 @@ SDL_Surface *ANDROID_SetVideoMode(_THIS, SDL_Surface *current,
// and expects those 256 pixels to stretch 2x height like on a TV interlaced display.
SDL_ANDROID_sWindowWidth = SDL_ANDROID_sWindowHeight * 4 / 3;
SDL_ANDROID_TouchscreenCalibrationWidth = SDL_ANDROID_sWindowWidth;
//SDL_ANDROID_TouchscreenCalibrationWidth = SDL_ANDROID_sWindowWidth;
SDL_ANDROID_ForceClearScreenRectAmount = 2;
}

View File

@@ -197,10 +197,14 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeResize) ( JNIEnv* env, jobject thiz, jint
SDL_ANDROID_sRealWindowHeight = h;
SDL_ANDROID_sWindowWidth = w;
SDL_ANDROID_sWindowHeight = h;
SDL_ANDROID_ScreenKeep43Ratio = keepRatio;
if( SDL_ANDROID_ScreenKeep43Ratio )
SDL_ANDROID_sWindowWidth = (SDL_ANDROID_sFakeWindowWidth * SDL_ANDROID_sRealWindowHeight) / SDL_ANDROID_sFakeWindowHeight;
SDL_ANDROID_TouchscreenCalibrationWidth = SDL_ANDROID_sWindowWidth;
SDL_ANDROID_TouchscreenCalibrationHeight = SDL_ANDROID_sWindowHeight;
SDL_ANDROID_ScreenKeep43Ratio = keepRatio;
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Physical screen resolution is %dx%d", w, h );
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Physical screen resolution is %dx%d 43Ratio %d", w, h, keepRatio);
}
JNIEXPORT void JNICALL

View File

@@ -25,8 +25,6 @@ TODO, which will get actually done
- SDL: support for mounting OBB files as directories: https://developer.android.com/google/play/expansion-files.html
- SDL: SdlVideoResizeKeepAspect will draw mouse and DPAD touch point shifted.
- Debian: proot crashes on Shield TV arm64 box.
- Debian: add harldink simulation to proot, for Android 6.