Skip to content

iOS: add Duo portrait and tabletop gameplay layouts - #230

Merged
v0lumehi merged 2 commits into
LNPANDY:mainfrom
jonochocki:ios/native-experience-duo-airplay
Nov 3, 2026
Merged

v0lumehi merged 2 commits into
LNPANDY:mainfrom
jonochocki:ios/native-experience-duo-airplay

Conversation

@jonochocki

@jonochocki jonochocki commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Add native iPhone Duo gameplay layouts. Portrait places the aspect-fitted 16:9 game picture above the virtual controls; a partially open horizontal hinge uses UIKit’s division region for tabletop play. Landscape retains the existing overlay when no tabletop division applies.

  • Observe UIHingeInteraction and reserved regions on iOS 27.1+, including inactive division boundaries. Other SDKs/OS versions retain the geometry fallback.
  • Reuse the existing Metal view, gamepad layers and input pipeline across pose changes. Touch coordinates follow the actual video rectangle, and layout changes release held virtual inputs.
  • Preserve multitouch, controller player slots and motion state. Existing landscape control positions remain intact.
  • Keep iPhone landscape-only for regular iPhones and the Duo outer display. The Duo inner display follows UIKit’s native orientation behavior and current bounds. iPad permits all four orientations without UIRequiresFullScreen; UILaunchScreen: {} replaces the empty storyboard entry. The existing launcher gets an orientation-capable hosting controller; its design and settings are unchanged.
  • Keep the approved portrait control placement, including the side-by-side joystick and D-pad. This placement was tuned by the contributor for handheld comfort.

This is the Duo-only portion of the previously combined contribution, split at the maintainer’s request. It includes no AirPlay scene, launcher redesign, artwork fetching/bundling, accent extraction or desktop-builder changes. The AirPlay follow-up is prepared separately; the launcher redesign is deferred for discussion with NX2Apple’s shell work (#226 / #144).

Checked

Rebased onto current main. The fork retains the ee6648cb upstream pin, existing patches 0030 and 0031, and Duo patch 0033. The patch and commits use the contributor’s own Git identity. The redundant g_root assignment is removed; upstream’s Nintendo-controller mapping is retained.

  • Physical Duo: the contributor tested build 1.3.19 from the extracted Duo work. The outer display stays landscape in both directions; the inner display retains both portrait directions, landscape and tabletop layouts.
  • iPad windowing: native Stage Manager gestures resize the existing launcher and gameplay window before and after Play. Narrow and wide windows select the appropriate layout from current bounds. The 16:9 Metal viewport and drawable dimensions follow resizing, and newly delivered native center taps reach normalized video coordinates near (0.5, 0.5) after resizing and rotation.
  • Regression coverage: repeated production-root resizing through six sizes checks Metal drawable scaling, button hit centers and normalized game touches. Existing coverage includes safe areas, native division regions, multitouch, pose-change input release, controller slots and motion-state preservation.
  • Upstream Duo harness: 27 passed, zero failures or skips.
  • Fork iPad harness: 26 passed, one iOS 27.1 hinge-API availability skip on the iOS 27.0 runtime, zero failures.
  • Documentation, environment registry, orientation policy and patch tooling: 31 checks passed in the fork.
  • Forwarded patch reproduction: 22 patches reproduce 2,446 vendored files.

The iPad checks use synthetic Metal frames through the production presentation and input code. Full-game testing on a physical iPad and game-performance measurements under resizing remain outstanding. The existing launcher’s two-column layout wraps long titles heavily in narrow windows; this PR does not redesign it.

Earlier device-SDK compile/link smoke checks passed with synthetic game modules and resources; those checks and physical Duo 1.3.19 acceptance predate this rebase. No shader, game-profile or guest-code changes are included. Existing screenshots below are from the previously approved physical Duo build; no new 1.3.19 screenshots are claimed.

Screenshots

Owner-provided physical Duo gameplay; the launcher and external-display screenshots are intentionally excluded.

Inner display: portrait game above controls Inner display: portrait game above controls
Inner display: landscape overlay Inner display: landscape overlay
Outer display: landscape overlay Outer display: landscape overlay

Scope

  • Vendored changes are carried by patches/0033-ios-adapt-gameplay-to-duo-portrait-and-tabletop.patch; existing patches 0030 and 0031 retain their order ahead of 0033.
  • Forwarded upstream first: iOS: adapt gameplay to Duo portrait and tabletop poses seedds/nxnative#683. The patch header names that PR.
  • No keys, game binaries, ROMFS, shaders or IPAs in the change. The linked screenshots are owner-provided gameplay evidence.

No app-identity or save-data migration. The approved local combined IPA is preserved separately.

@jonochocki
jonochocki marked this pull request as ready for review October 29, 2026 23:06
@v0lumehi

Copy link
Copy Markdown
Collaborator

Thanks a lot for this, @jonochocki. The Duo layouts and the external display support are things we wanted, and testing on a physical Duo with screenshots from the device is exactly the evidence that helps. The work looks careful.

We'd like to review and merge it, but in this form it is hard to do well:

  • Size: about 4,500 lines of real code and tests (plus the patch file that repeats the vendored changes), in one PR. Our template asks for one change per PR, mainly so each part can be reviewed properly and reverted on its own.
  • Three independent features: the Duo gameplay layouts, AirPlay and external displays, and a redesigned per-game launcher, plus the builder change that bundles the banner.
  • The launcher overlaps with ongoing work: iOS shell: art-led library, Cover Flow, settings and the host layer for iPhone and iPad #226 builds the iOS shell for Route C (Route C M1: the game's modules as a framework (opt-in) #144), one app for several games, which will replace the per-game launcher, with its own design (16:9 banners, Cover Flow in landscape, settings on demand). Merging a second launcher design now would leave us maintaining two.

Could you split it into three PRs, in this order?

  1. Duo gameplay layouts: hinge and reserved regions, portrait video above the controls, the tabletop split, live re-layout of controls and touch coordinates. This one is independent of the launcher, so we'd review it first.
  2. AirPlay and external displays: the game-only external scene, the device as controller, the ready screen.
  3. The launcher: let's talk about this one first, in iOS shell: art-led library, Cover Flow, settings and the host layer for iPhone and iPad #226 or Route C M1: the game's modules as a framework (opt-in) #144. The piece that fits the shell directly is bundling the game's art into the IPA at build time, since the shell needs exactly that to show 16:9 art on the device. It should come from the same chain the Mac library uses (GameLibrary.artwork: the player's own pick, then the cached eShop banner, then docs/images, then the icon), so the Mac and the iPhone always show the same picture. The shell keeps one fixed accent and its own layout (a library with settings on demand), so the per-game accent color and the Game and Settings tabs would not carry over.

For each part, the same flow as you did here: a PR to seedds/nxnative first (splitting #683 the same way would help seedds too) and a forwarded patch here. Note on numbering: 0032 is taken by another fork patch that merges first, so please use the next free number when you rebase.

CI has not run yet because this comes from a fork. We'll approve the runs once the split PRs are up. Thanks again, this is a big step for the iPhone side.

@v0lumehi v0lumehi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes only to mark the state: please split this into the three PRs described in the comment above. Happy to review the Duo gameplay layouts first.

@jonochocki
jonochocki force-pushed the ios/native-experience-duo-airplay branch from 95488b0 to 4f7b1ee Compare October 29, 2026 23:57
@jonochocki jonochocki changed the title iOS: add iPhone Duo layouts, AirPlay and a native launcher experience iOS: add Duo portrait and tabletop gameplay layouts Oct 29, 2026
@v0lumehi

Copy link
Copy Markdown
Collaborator

Thanks for the split, @jonochocki, this is much easier to review. The Duo layout itself reads well: the hinge and reserved-region handling behind the availability checks, the aspect-fitted video, touch coordinates following the video rectangle, and releasing held inputs on a pose change. We want the Duo portrait and tabletop layouts, the near-square inner display really benefits from video above the controls.

One change in scope, about orientations. project.yml now declares all four orientations for the iPhone too, and dm_layout() splits into video above controls for any portrait bounds. So every regular iPhone would switch to the portrait layout when held upright. We'd like to keep regular iPhones landscape as today and treat the Duo as the special case:

  • Please keep the iPhone UISupportedInterfaceOrientations landscape-only as before. Per Apple's Duo guidance the inner display does not honor an app's supported orientations, so the unfolded Duo still gets portrait and your layout, while regular iPhones and the folded Duo stay landscape. Could you confirm that on your device?
  • The iPad keys are fine as you have them (all four orientations, no UIRequiresFullScreen). Since games can then run in Split View and small Stage Manager windows, please check that the picture, the touch controls and their coordinates follow a resized window (a quick check on the iPad simulator with Stage Manager is enough), or tell us if something does not.
  • UILaunchScreen: {} instead of the empty storyboard name is fine.

With that, this is good to go from our side once CI is green. @LNPANDY, could you take a look as well? It changes the orientation policy and the window behaviour of every iOS game, so a second pair of eyes would be good before it merges.

@v0lumehi
v0lumehi requested a review from LNPANDY October 30, 2026 00:07
@v0lumehi v0lumehi added ios iPhone or iPad patch-queue Changes the patch queue or the upstream pin enhancement New feature or request labels Oct 30, 2026
@jonochocki

Copy link
Copy Markdown
Contributor Author

Good callout. I’ll restore landscape-only orientations for iPhone and confirm on Duo that the outer display stays landscape while the inner display retains portrait and tabletop layouts; missed that check during the PR splits. Regarding Split View and small Stage Manager window behavior too: I’ll check that the video, controls and touch coordinates follow window resizing on the iPad before submitting an update. 👍

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Oct 30, 2026
@jonochocki

jonochocki commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I’ve restored landscape-only orientations for iPhone and confirmed the behavior on my physical Duo:

  • The outer display stays in landscape in both directions.
  • The inner display retains both portrait directions, landscape and tabletop layouts.
  • iPad keeps all four orientations, without UIRequiresFullScreen. UILaunchScreen: {} is retained.

I also checked iPad window resizing before and after Play. The production Metal viewport stays aspect-fitted at 16:9, controls follow the current window proportions, and newly delivered touches map correctly after resizing and rotation. This covers the gameplay presentation and input path, in addition to the launcher.

I’ve added regression coverage for repeated window-size changes, Metal drawable dimensions, button hit targets and normalized video touches. The Duo harness passes all 27 tests. The iPad harness passes 26 tests, with one hinge-API availability skip on iOS 27.0 and no failures. Patch-queue validation also passes.

@v0lumehi

Copy link
Copy Markdown
Collaborator

I'll review in a bit

@v0lumehi v0lumehi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick update, @jonochocki. This addresses everything from my earlier review, so I'm approving.

  • Orientations: regular iPhones stay landscape-only, and only the iPad list (~ipad) adds portrait. The Duo inner display ignores the list, so portrait and tabletop still work there. Thanks for checking both displays on your Duo.
  • test_orientation_policy.py keeps the iPhone landscape-only, the iPad on all four orientations and UIRequiresFullScreen out of both projects. Our tests workflow already runs dm/ios/tests/test_*.py, so it is enforced in CI.
  • Code: the split only applies to portrait bounds or a partially open hinge with a valid horizontal division, so landscape keeps today's overlay. Held keys and game touches are released on a pose change. Game touches map through the actual video rectangle. The hinge and reserved-region code sits behind __has_include and @available(iOS 27.1, *), so it still builds with older SDKs.
  • Upstream: patch 0033 is forwarded seedds/nxnative#683, as it should be.

Two small things, neither blocks the merge:

  1. The patch header says From: seedds <[email protected]>. It should name you as the author. If you regenerate the patch with your own git identity, the credit is right in the queue too.
  2. startGame now sets g_root = self, which viewDidAppear: already does. It is harmless, but the line can go.

@LNPANDY, this changes the iOS builds players get: iPads gain all four orientations plus Split View and Stage Manager windows (without UIRequiresFullScreen), and the Duo inner display gets portrait and tabletop layouts. iPhones stay landscape-only. Please have a look before it merges. It is a feature, so it waits until the 48 hours are up (2026-10-31, 23:03 UTC) and the CI run on the latest commit is green.

@v0lumehi

v0lumehi commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

@jonochocki, one more step before this can merge: the branch now conflicts with main. Since you opened it, main moved the upstream pin to seedds ee6648cb (#238) and added patches 0030 and 0031, so patches/series and the regenerated tree no longer apply cleanly.

Could you rebase onto current main and regenerate patch 0033 against the new pin (scripts/patches.py apply, then your change, then scripts/patches.py export, see patches/README.md)? If you regenerate it with your own git identity, that also fixes the From: line I mentioned. Keep the number 0033, it is still free. I'll approve the CI run once you push.

@LNPANDY

LNPANDY commented Oct 30, 2026

Copy link
Copy Markdown
Owner

Thanks for splitting the Duo layouts and for testing the orientation and resize behaviour on your devices. We want to keep this contribution for review, rather than close it. As noted above, it currently conflicts with main after the upstream sync; please rebase and regenerate the patch on the latest pin, preserving the Nintendo controller mapping and the current patch queue. Please also keep your own author identity on the patch so the credit is correct.

After that, we will recheck CI and the Duo/iPad harness. Real iPad gameplay while resizing is still an open validation item. AirPlay can remain a separate follow-up.

@jonochocki
jonochocki force-pushed the ios/native-experience-duo-airplay branch from ceb9d18 to e879a9c Compare October 30, 2026 13:34
@jonochocki

Copy link
Copy Markdown
Contributor Author

Thanks, both, for the thoughtful reviews and guidance. The commit identity instructions were a little confusing to read, so I appreciate the clarification and the update in #244. The regenerated patch now uses my own Git identity.

I’ve rebased onto current main and regenerated 0033 against the latest upstream pin, preserving the existing patch queue and Nintendo-controller mapping. I also removed the redundant g_root assignment. Local validation passes; real iPad gameplay while resizing remains an open validation item, and AirPlay stays a separate follow-up.

Happy to help contribute. My background also includes UX and design philosophy, so as the launcher progresses through design iterations, I’d be glad to lend a hand wherever useful.

Thanks again for keeping this moving and helping get the contribution into a maintainable shape.

@v0lumehi v0lumehi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick rebase, @jonochocki, and sorry that the identity instructions were confusing. That was on us, and #244 and #245 fixed the wording.

I checked the new head e879a9c3 against my earlier review:

  • Patch 0033 is regenerated on the current pin with your own identity in From: and still forwarded seedds/nxnative#683.
  • The code is the same as what I approved, minus the redundant g_root assignment. It also picks up what main changed meanwhile: the Nintendo pad mapping note from pad_apple.h and the front_ios_device_message stub in the Duo harness runtime.
  • I approved the CI runs for this commit.

So my approval stands. Once CI is green it can merge after the 48 hours (2026-10-31, 23:03 UTC), unless @LNPANDY has objections. Real iPad gameplay while resizing stays the open validation item, as noted.

And beyond this PR: this is exactly the kind of help we can use. Careful work, tested on real hardware, with the evidence attached. If you like, you are very welcome to give feedback and ideas on the design too. The iOS shell that will hold several games in one app (#226, with screenshots) is still taking shape, and an eye from someone who owns a Duo and cares about how things feel on the device would help a lot. Comments there, or new issues with ideas, are both welcome.

@v0lumehi

Copy link
Copy Markdown
Collaborator

I rebased this onto main. The engine changes are now patch 0054, because the repo builds the engine from patches/ instead of tracking dm/ and docs/. The author stays jonochocki. I merged the layout code with the layout editor and TV support that landed in the meantime, and I added a dm_set_opmode stub so the Duo harness links again. The harness passes on an iOS 27.0 simulator (27 tests, 1 skipped because it needs 27.1).

Adds patches/0054: portrait puts the 16:9 picture above the touch controls, native horizontal folds separate game and controls, and a Duo test harness under dm/ios/tests/duo.
@v0lumehi
v0lumehi force-pushed the ios/native-experience-duo-airplay branch from 647d418 to 35cdc63 Compare October 31, 2026 19:23
@v0lumehi

Copy link
Copy Markdown
Collaborator

@jonochocki The layout editor (patches 0035 and 0036) was taken out of main in #345 because it scattered the in-game controls. So I rebuilt patch 0054 on the layout without it. The DmGamepad.m part is now exactly your original change again, with your original face button hit test and positions. The only addition is the TV support check in front_ios.m that main needs. The Duo portrait and tabletop layouts look the same as before. I checked them on the simulator, and the Duo harness and the iOS smoke build pass. You stay the author of the commit.

@v0lumehi

v0lumehi commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

@jonochocki we will very likely include this in the release after 0.8.0, I need to see how this integrates with the new iPhone app before

@v0lumehi v0lumehi modified the milestones: v1.1.0, v1.4.0 Nov 1, 2026
@v0lumehi v0lumehi mentioned this pull request Nov 3, 2026
1 task done
Renumber patch 0054 to 0061 and refresh its context for the new pin.
@v0lumehi

v0lumehi commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

I merged main into this branch to clear the conflict. Two things changed:

  • The patch is renumbered from 0054 to 0061. main uses 0054 to 0060 now.
  • Three hunks needed fresh context because upstream moved under them: two in dm/ios/Sources/front_ios.m and one in docs/reference/rendering.md. The logic is yours and is unchanged.

python3 tools/engine.py check passes with 38 patches at the current pin. I did not run the layout on a Duo. The upstream pull request seedds/nxnative#683 is still open.

@v0lumehi
v0lumehi merged commit 3a5b74a into LNPANDY:main Nov 3, 2026
17 checks passed
v0lumehi added a commit to Haseenesss/NX2Apple that referenced this pull request Nov 3, 2026
LNPANDY#230 took patch 0061 (Duo layouts). The button-mapping patch is now
0062, the next free number on main, and applies after it unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request ios iPhone or iPad patch-queue Changes the patch queue or the upstream pin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants