Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable screen rotation while in active gameplay #5331

Open
ticotaco72 opened this issue Jul 11, 2019 · 5 comments · May be fixed by #31153
Open

Disable screen rotation while in active gameplay #5331

ticotaco72 opened this issue Jul 11, 2019 · 5 comments · May be fixed by #31153

Comments

@ticotaco72
Copy link
Contributor

ticotaco72 commented Jul 11, 2019

Describe the new feature: while in gameplay, rotating your device should be blocked on Android and ios

@Joehuu
Copy link
Member

Joehuu commented Oct 12, 2020

I think the OS rotation lock is enough? This will cause a UX problem if we disable rotation in certain screens (i.e. gameplay), or settings bloat if we make it toggleable.

Also to note, I don't see a gameplay benefit with rotating in the middle of play, only a disadvantage if screen accidentally rotates (which OS rotation lock is there for).

@peppy
Copy link
Member

peppy commented Oct 12, 2020

This has recently been fixed on android to respect the user rotation lock setting. It has always done so on iOS.

Agree that we may want to block rotation during gameplay (when LocalUserActive) though.

@peppy peppy changed the title rotating while in gameplay Disable screen rotation while in active gameplay Oct 12, 2020
@frenzibyte frenzibyte assigned frenzibyte and unassigned frenzibyte Dec 8, 2024
@frenzibyte
Copy link
Member

frenzibyte commented Dec 8, 2024

This turned out to be extremely convoluted for multiple reasons, in a cascading manner:

  • UIKit does not directly support locking current screen orientation
  • UIKit allows controlling the allowed screen orientations dynamically by overriding supportedInterfaceOrientations and returning a different mask if the game is requesting a lock, but I can't directly override on the root view controller class as it is prepared and provided by SDL.
  • SDL overrides rootViewController.supportedIntefaceOrientations and reads the hint value of SDL_HINT_ORIENTATIONS there, so sounds like we're winning right? we can just set the hint whenever we want and it'll just work...right? So that actually just doesn't work, whatever value I set there is still bypassed and the game can still freely rotate around.
  • Random google searches show that we can control the orientation on a higher level by overriding UIApplicationDelegate.supportedInterfaceOrientationsForWindow:, but...since we migrated to SDL, we can no longer override any method of the app delegate, as the app delegate is privately set up by SDL.

I can double down and start inventing Obj-C weirdness to make SDL use a custom app delegate subclass we provide, but that is not simple to achieve at all. As such, I've just un-assigned as not worth the time/effort for now.

@peppy
Copy link
Member

peppy commented Dec 16, 2024

I'm guessing now that you have an AppDelegate again this becomes more feasible?

@frenzibyte
Copy link
Member

Yeah I'll look into this again.

@frenzibyte frenzibyte self-assigned this Dec 16, 2024
@frenzibyte frenzibyte linked a pull request Dec 16, 2024 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants