Skip to content

Orientation settings in MAUI Android are not working #6576

@Frederisk

Description

@Frederisk

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions