Skip to content

Commit

Permalink
init _currentOrientation
Browse files Browse the repository at this point in the history
  • Loading branch information
nkast committed Feb 21, 2025
1 parent 9e4411f commit 81d5f1e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Platforms/Game/.Android/AndroidGameWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,20 @@ public AndroidGameWindow(AndroidGameActivity activity, Game game)
}

_clientBounds = new Rectangle(0, 0, size.X, size.Y);

// init _currentOrientation
DisplayOrientation currentOrientation = AndroidCompatibility.Current.GetAbsoluteOrientation(activity);
// Android 2.3 and above support reverse orientations
int sdkVer = (int)Android.OS.Build.VERSION.SdkInt;
if (sdkVer < 10)
{
if (currentOrientation == DisplayOrientation.LandscapeRight)
currentOrientation = DisplayOrientation.LandscapeLeft;
if (currentOrientation == DisplayOrientation.PortraitDown)
currentOrientation = DisplayOrientation.PortraitDown;
}
_currentOrientation = currentOrientation;
_activity.RequestedOrientation = XnaOrientationToAndroid(currentOrientation);

GameView = new AndroidSurfaceView(activity);
GameView.LayoutChange += GameView_LayoutChange;
Expand Down

0 comments on commit 81d5f1e

Please sign in to comment.