Skip to content

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
seedds:mainfrom
earths-voluble:ios-portrait-layout
Closed

earths-voluble wants to merge 2 commits into
seedds:mainfrom
earths-voluble:ios-portrait-layout

Conversation

@earths-voluble

Copy link
Copy Markdown

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:

  1. Portrait layout (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_INSET moves 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.
  2. Upside down. iOS never turns an iPhone's interface upside down, so the front end turns a stage view (game view, pad, counter) half a turn itself. On the Duo's inner display the device orientation is a quarter turn from the picture (as in iPhone Duo Gyro issue #569): landscape left is upright and landscape right is upside down. So the upright orientation is learnt at a turn into portrait, per display. Across a system rotation, the stage spins the other way, so the picture turns the quarter turn the phone did. The phone's motion is turned with the stage, because Core Motion's deviceMotionBody does not follow a view's transform. Reference entry in docs/reference/services.md.

The change is limited to the iOS front end (front_ios.m, DmGamepad.m, main.m), one row in dm/games/settings.tsv, and docs.

Checked

  • Tests: 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).
  • Games run: Rhythm Heaven Groove (0100D9F01D474000), built from this branch on b64a5ff with Xcode 27.2. Checked upright and landscape, every turn between upright, upside down and both landscapes, the touch controls upside down, and Cloud saves still syncing.
  • Devices and OS: iPhone Duo, iOS 27.2, inner display.
  • regress.py: not run; nothing outside the iOS front end changes.
  • Not checked: the gyro in a game that reads it, the Duo's outer display, a TV with the stage.

Docs

  • The finding is in docs/reference/services.md (after iPhone Duo Gyro issue #569's motion entry), and python3 dm/tools/docs_symptoms.py was run
  • No game files, keys or data extracted from a game in the change or the attachments

The 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.

@github-actions github-actions Bot added ios The iPhone and iPad app (dm/ios) tools Tools and scripts (dm/tools, scripts) docs Documentation labels Nov 3, 2026
earths-voluble and others added 2 commits November 3, 2026 16:06
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

Copy link
Copy Markdown
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:

  1. Upside-down portrait on the Duo's inner display. iOS never turns an iPhone's interface upside down, and on the inner display the device orientation is a quarter turn from the picture (landscape left is upright, landscape right is upside down, as in iPhone Duo Gyro issue #569), so the front end has to turn its own view. Core Motion's deviceMotionBody does not follow a view's transform, so the phone's motion has to be turned with it. I'll rework this on top of DmLayout.h as a small PR.
  2. Device testing. e2fadf2 notes it was not tested on a device; I have an iPhone Duo (iOS 27.2) and will report how its portrait and tabletop layouts behave on iOS: adapt gameplay to Duo portrait and tabletop poses #683.

@earths-voluble

Copy link
Copy Markdown
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.

@earths-voluble
earths-voluble deleted the ios-portrait-layout branch November 4, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation ios The iPhone and iPad app (dm/ios) tools Tools and scripts (dm/tools, scripts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant