osu-framework icon indicating copy to clipboard operation
osu-framework copied to clipboard

Orientation settings in MAUI Android are not working

Open Frederisk opened this issue 7 months ago • 0 comments

In the Android project, the game's Android.App.ActivityAttribute.ScreenOrientation property, and the RequestedOrientation property in the AndroidGameActivity.OnCreate method, have no effect on screen orientation.

Essentially, after debugging, I found that they actually all execute as expected. However, SDL exhibits an unexpected behavior (at least for me, as I couldn't find any mention in o!f documentation, nor any usage examples or comments in osu!) where if SDL_HINT_ORIENTATIONS is not assigned any valid value, SDLActivity will assign a default value for orientation, which is typically FullUser. This assignment occurs after OnCreate, thus overriding any previous assignments.

Specifically, this process is initiated by the SDL3Window.Create() method.

A viable solution is to add such a call in the OnCreate method:

SDL.SDL3.SDL_SetHint(SDL.SDL3.SDL_HINT_ORIENTATIONS, "LandscapeLeft LandscapeRight"u8);

However, it's clear that we cannot assign arbitrary desired values, such as Nosensor, to the program via the SDL_HINT_ORIENTATIONS. Furthermore, mixing SDL mode declarations in MAUI might lead to some unexpected side effects, which I will describe in a subsequent issue. And frankly, this approach seems somewhat counter-intuitive and ugly.

Frederisk avatar May 19 '25 13:05 Frederisk