Skip to content

Commit

Permalink
Ignore device orientation events on non-mobile platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSpydog committed Jan 3, 2024
1 parent 4b4b822 commit c6683ee
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/FNAPlatform/SDL2_FNAPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ internal static class SDL2_FNAPlatform

private static bool SupportsGlobalMouse;

private static bool SupportsOrientations;

#endregion

#region Game Objects
Expand Down Expand Up @@ -236,6 +238,10 @@ public static string ProgramInit(LaunchParameters args)
OSVersion.Equals("Mac OS X") ||
videoDriver.Equals("x11") );

// Only iOS and Android care about device orientation.
SupportsOrientations = ( OSVersion.Equals("iOS") ||
OSVersion.Equals("Android") );

/* High-DPI is really annoying and only some platforms
* actually let you control the drawable surface.
*/
Expand Down Expand Up @@ -915,7 +921,7 @@ FNAWindow window

public static bool SupportsOrientationChanges()
{
return OSVersion.Equals("iOS") || OSVersion.Equals("Android");
return SupportsOrientations;
}

#endregion
Expand Down Expand Up @@ -1166,16 +1172,19 @@ ref bool textInputSuppress
// Orientation Change
if (evt.display.displayEvent == SDL.SDL_DisplayEventID.SDL_DISPLAYEVENT_ORIENTATION)
{
DisplayOrientation orientation = INTERNAL_ConvertOrientation(
(SDL.SDL_DisplayOrientation) evt.display.data1
);
if (SupportsOrientationChanges())
{
DisplayOrientation orientation = INTERNAL_ConvertOrientation(
(SDL.SDL_DisplayOrientation) evt.display.data1
);

INTERNAL_HandleOrientationChange(
orientation,
game.GraphicsDevice,
currentAdapter,
(FNAWindow) game.Window
);
INTERNAL_HandleOrientationChange(
orientation,
game.GraphicsDevice,
currentAdapter,
(FNAWindow) game.Window
);
}
}
else
{
Expand Down

0 comments on commit c6683ee

Please sign in to comment.