oddstream / lsol

A polymorphic solitaire engine in Lua and LÖVE
13 stars 4 forks source link

Mobile app ignores device rotation settings #4

Closed Bett-A-Fish closed 2 years ago

Bett-A-Fish commented 2 years ago

When using the mobile app with device settings locked to portrait, the app still rotates.

I'm not familiar with what kinds of things require permissions to access. So I think the best thing would be to have a setting in game for locking screen orientation to portrait or landscape.

This seemed relevant: https://github.com/love2d/love-android/issues/175 Though it is for love-android which I'm not sure is used here? but it is a port of love2d, so I think something similar would be usable.

oddstream commented 2 years ago

Tried adding a 'lockRotation' setting that causes love.displayrotated() to take no action, but it seems in LÖVE this function is called after a rotation has taken place, so the lockRotation setting has no effect. Need to find a way to trap orientation changes in LÖVE; is this even possible?

Bett-A-Fish commented 2 years ago

I found this but it looks like it's how to lock the rotation in general rather than by user setting. https://love2d.org/forums/viewtopic.php?t=92177

do you use love-android? as this looks relevant

(I'm not familiar with lua or love, so idk how much help I'll manage to be here)

oddstream commented 2 years ago

Don't use love-android, because it's a version behind the main version of LÖVE.

Working on a way of doing this that doesn't require the dreaded 'requires restart', with 'Lock portrait' and 'Lock landscape' settings.

Bett-A-Fish commented 2 years ago

Can understand that.

It does look like UpdateMode or SetMode would still work though? or does that require the restart? It looks like it avoids the config portion and is useable in the main app. Especially since update mode mentions it would clear the canvas and you need to trigger a redraw.

https://love2d.org/wiki/love.window.updateMode https://love2d.org/wiki/love.window.setMode

oddstream commented 2 years ago

Since (I don't think) LÖVE can read Android system settings, I've added an 'Allow orientation' setting that will fix the orientation to whatever-it-was when the app starts. It achieves this by doing a cheeky app restart behind the scenes.