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

Feature: lock GameViewController from rotating if an External Game Controller is connected #155

Conversation

ianclawson
Copy link

This is lighter attempt at solving https://trello.com/c/bO57L3PN, which asks to lock the screen orientation to a fixed position when the Backbone (or Razer Kishi) is connected, since they have a fixed orientation.

It's a simple idea in practice, but iOS unfortunately does not give us an easy way to do this dynamically. You can override the supportedInterfaceOrientations per-controller, but I'm not finding a way for that to be conditional; you override the var and are done with it. Likely I could use a local variable, monitor the device's orientation and set the local var, but to do that for every controller (or to subclass every controller) is likely more trouble than it's worth.

In light of that, this change gets you most of the way there (for the GameViewController at least), and is significantly less effort.

@ianclawson ianclawson changed the title Feature: lock] GameViewController from rotating if an External Game Controller is connected Feature: lock GameViewController from rotating if an External Game Controller is connected Nov 4, 2021
@lonkelle
Copy link
Collaborator

lonkelle commented Feb 1, 2022

This shouldn’t be merged unless a third conditional is in there on line 171:

return !self.isGyroActive && !isExternalGameControllerConnected

should be something like:
return !self.isGyroActive && (!isExternalGameControllerConnected && UIDevice.current.orientation.landscapeLeft)

this will allow users to use their phone vertically to select and play their games and then when they rotate it to landscape, it’ll lock.

It seems small but I open most games in vertical mode because the interface is better that way and then switch to landscape in game but the current PR keeps it locked to vertical which I don’t see a use case for.

@ianclawson
Copy link
Author

This shouldn’t be merged unless a third conditional is in there on line 171.

return !self.isGyroActive && (!isExternalGameControllerConnected && UIDevice.current.orientation.landscapeLeft)

this will allow users to use their phone vertically to select and play their games and then when they rotate it to landscape, it’ll lock.

It seems small but I open most games in vertical mode because the interface is better that way and then switch to landscape in game but the current PR keeps it locked to vertical which I don’t see a use case for.

Love it. I'll update that next chance I get.

@ianclawson
Copy link
Author

Closing this to clean up my work list of Open PRs

@ianclawson ianclawson closed this Aug 6, 2022
@lonkelle
Copy link
Collaborator

lonkelle commented Dec 28, 2022

Implemented the more thorough version which gets rid of my nitpick of this current PR getting stuck in portrait mode all the time when using a controller: lonkelle@440c748

Tho, it could be more thorough if I checked if the controller was physically connected (https://developer.apple.com/documentation/gamecontroller/gccontroller/1458868-isattachedtodevice), I just have no way to test wireless controllers rn vs my Backbone so my hands are tied but here are the TODOs for final polish of this feature: lonkelle@fac39db

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants