From 3feb92e7884b99beb3aa5b1c712d23ee3100fdbc Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 6 Sep 2022 22:07:44 -0500 Subject: [PATCH] Force landscape mode when using OSC --- app/src/main/java/com/limelight/Game.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/limelight/Game.java b/app/src/main/java/com/limelight/Game.java index 9dcc3d4f..c4f69d18 100644 --- a/app/src/main/java/com/limelight/Game.java +++ b/app/src/main/java/com/limelight/Game.java @@ -199,9 +199,6 @@ public class Game extends Activity implements SurfaceHolder.Callback, getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN); } - // Enter landscape unless we're on a square screen - setPreferredOrientationForCurrentDisplay(); - // Listen for UI visibility events getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(this); @@ -219,6 +216,9 @@ public class Game extends Activity implements SurfaceHolder.Callback, prefConfig = PreferenceConfiguration.readPreferences(this); tombstonePrefs = Game.this.getSharedPreferences("DecoderTombstone", 0); + // Enter landscape unless we're on a square screen + setPreferredOrientationForCurrentDisplay(); + if (prefConfig.stretchVideo || shouldIgnoreInsetsForResolution(prefConfig.width, prefConfig.height)) { // Allow the activity to layout under notches if the fill-screen option // was turned on by the user or it's a full-screen native resolution @@ -526,9 +526,10 @@ public class Game extends Activity implements SurfaceHolder.Callback, } private void setPreferredOrientationForCurrentDisplay() { - // If the display is somewhat square, allow any orientation. Otherwise, request landscape. + // If the display is somewhat square and OSC is disabled, allow any orientation. Otherwise, request landscape. + // The OSC code assumes a landscape display, so we force landscape if OSC is enabled. Display display = getWindowManager().getDefaultDisplay(); - if (PreferenceConfiguration.isSquarishScreen(display.getWidth(), display.getHeight())) { + if (!prefConfig.onscreenController && PreferenceConfiguration.isSquarishScreen(display.getWidth(), display.getHeight())) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_USER); }