Repository navigation
iOS: an opt-in portrait layout (picture above, touch controls below), upside down included on iPhone Duo - #1082
Closed
earths-voluble wants to merge 2 commits into
Closed
earths-voluble wants to merge 2 commits into
earths-voluble wants to merge 2 commits into
Conversation
The iPhone app runs in landscape only, with the touch controls over the picture. On the iPhone Duo's inner display (about 7:10 held upright) that leaves wide black bars and still covers the game. Held upright, the screen has room for a full-width 16:9 picture with the controls below it, as on a Nintendo 3DS, and the Duo's fold runs across the middle of that screen. Portrait layout (DM_PORTRAIT; Controls in the launcher, iOS only, off by default) lets the app turn upright once the game starts: the app delegate and the root view controller return front_ios_orientations(), landscape until then, so the settings screen stays in landscape and Info.plist is unchanged. front_ios_picture() gives the picture's rect and the controls' area. Upright, the picture fills the width of the top half, centred in it when it fits; the controls get the bottom half, less DM_PORTRAIT_INSET percent (default 6) from the sides and the bottom. DmGamepad lays out the same 2D / 3D controls in that area: the unit is limited by its width (470 u across) as well as its height, the colours are a little stronger on black, the right stick's area is the right third of the controls' area, and only touches on the picture reach the game's touch screen. While a TV shows the picture (tv_attach), the phone keeps the pad over the whole screen, upright too. In landscape, or with the setting off, the layout is the one before. The gyro map already covers portrait. Upside-down portrait does not turn on the Duo's inner display, even with every orientation allowed in the app and in Info.plist; Apple's "Prepare your app for iPhone Duo" tech talk says the inner display doesn't honor an app's supported orientations. Turning the view ourselves on UIDevice's upside-down notice did not help either, so the layout allows every orientation but upside down. Checked: built and run with Xcode on an iPhone Duo (iOS 27.2) with Rhythm Heaven Groove, upright and in landscape, with the setting on and off; the touch controls and the game's input work in both. env_switches.py --check, test_launcher_settings, test_env_switches and test_player_env pass. compile_check.py, the host tests and dm/ios/tests were not run. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KUMMLKgvSYoFP8ZHtTj3Ex
iOS never turns an iPhone's interface upside down, iPhone Duo's inner display included, so the portrait layout stayed the wrong way up when the phone was turned over. Logging the device and interface orientations on the Duo showed why turning on UIDeviceOrientationPortraitUpsideDown never fired there: as in seedds#569, the inner display's hardware frame is a quarter turn from the picture. The device reports landscape left with the picture upright and landscape right with it upside down, and portrait upside down is one of the landscapes. The front end now puts the game view, the pad and the counter on a stage view and turns the stage half a turn itself. The device orientation at a turn into portrait is taken as upright, kept per display in the app's preferences (DmPortraitUp.<native size>), and its opposite turns the stage; the upright one turns it back, flat or sideways leaves it. Held in landscape, the opposite, which the system does not turn to, asks for portrait through requestGeometryUpdate once it has held for 0.35 s (not while passing through it between the two landscapes), and the stage turns when portrait comes. When the stage's turn changes across a system rotation, the stage spins the other way along with it (viewWillTransitionToSize, the coordinator's target transform), so the picture turns the quarter turn the phone did instead of three quarters. The pad lays out in the turned stage's safe-area insets (front_ios_insets), and the phone's motion is turned half a turn while the stage is: Core Motion's deviceMotionBody does not follow a view's transform. A TV's detach puts the game view back on the stage. Reference entry in docs/reference/services.md, after the motion entry of seedds#569; docs/settings.md says what the setting does upside down and on a TV. Checked on an iPhone Duo (iOS 27.2), inner display, with Rhythm Heaven Groove, built from this commit on b64a5ff with Xcode 27.2: upright to upside down and back, each landscape to upside down, upside down to each landscape, landscape to landscape, the touch controls upside down; Cloud saves still sync. On the tree before the rebase, the log showed the expected device orientations and no refused portrait request. Not checked: the gyro in a game that reads it, the outer display, a TV (tv_attach / tv_detach with the stage). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KUMMLKgvSYoFP8ZHtTj3Ex
earths-voluble
force-pushed
the
ios-portrait-layout
branch
from
November 3, 2026 16:07
cc29881 to
b1634a8
Compare
Author
|
Closing this in favour of e2fadf2 (#683, #1083), which lays the picture above the controls on the Duo with the real fold from UIHingeInteraction and the tabletop pose, so the first commit here is no longer needed. Two things from this PR are not in main, and I'll follow up on both:
|
Author
|
Correction to the above: on main as of 4e0333a, the Duo's inner display turns upside down on its own (tested on an iPhone Duo, iOS 27.2, with Rhythm Heaven Groove: all four orientations unfolded). So the upside-down follow-up isn't needed, and "iOS never turns an iPhone's interface upside down" held only for this PR's build, which still had UIRequiresFullScreen; main dropped it in e2fadf2, which looks like the difference. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Proposed in #557. On iPhone the app is landscape only, with the touch controls over the picture; on iPhone Duo's inner display that leaves wide black bars and still covers the game. Two commits:
DM_PORTRAIT, Controls → "Portrait layout", iOS only, off by default). Once the game starts, the app also accepts portrait. Held upright, the picture fills the width of the top half and the existing 2D / 3D touch controls take the bottom half (front_ios_picture,DmGamepad.m's area).DM_PORTRAIT_INSETmoves the controls in from the edges. While a TV shows the picture, the phone keeps the pad over the whole screen. Landscape, or the setting off, is laid out as before.deviceMotionBodydoes not follow a view's transform. Reference entry indocs/reference/services.md.The change is limited to the iOS front end (
front_ios.m,DmGamepad.m,main.m), one row indm/games/settings.tsv, and docs.Checked
dm/tools/tests/test_launcher_settings.py,test_env_switches.py,test_player_env.py,test_docs.py;env_switches.py --check;docs_symptoms.py. Not run:compile_check.py, the host / gfx tests and the C lint (no host, shader or tool change; CI covers the compile).regress.py: not run; nothing outside the iOS front end changes.Docs
docs/reference/services.md(after iPhone Duo Gyro issue #569's motion entry), andpython3 dm/tools/docs_symptoms.pywas runThe code was written with help from an AI assistant (Claude) and tested by me on the device. #433, #500 and #258 also touch
DmGamepad.m; I'm happy to rebase onto whichever lands first, or to adapt this to the touch-control redesign discussed in LNPANDY/NX2Apple#347.