Skip to content

The Mac settings window starts the game with a controller's A and quits with its B, so couch play needs no mouse; the press that starts the game does not reach it and A never answers the cloud-save question - #2460

Open
PucaVaz wants to merge 1 commit into
seedds:mainfrom
PucaVaz:launcher-controller-play

Conversation

@PucaVaz

@PucaVaz PucaVaz commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What and why

The Mac settings window (dm/mac/Launcher.swift) could only be answered with the mouse or the keyboard (Play / Return, Quit / closing the window). With a controller only, the player had to reach for the Mac to start the game.

Now a controller's A is Play and its B is Quit. They are GameController's buttonA and buttonB on any controller, as the host's own quit and player prompts take them (front_mac.m hq_buttons, cp_buttons); main has no A/B layout setting (#634 is open), so none is added. The decisions are a small pure struct, LauncherPad, which a 60 Hz timer in common run-loop modes feeds with the buttons of every controller GameController lists:

  • A button counts on its release, after a press the window took. The settings go into the environment and the host is spawned only after that (launcher.c), in a new process whose GameController reads the controllers from scratch (pads_changed reads each one's state at its connection; with DM_PAD_PRESS_TO_JOIN a controller joins on a value change). The button is up by then, so the press that started the game reaches it neither as a button nor as a join.
  • A button already down when the window starts taking input (held at launch, or through an alert) counts only after it was seen up.
  • The window takes no button while it is not key, while an alert or a panel is modal (NSApp.modalWindow), with a sheet attached, or while a menu tracks (RunLoop.current.currentMode == .eventTracking). A press is dropped when any of these starts. So A never picks a save: the save-sync conflict alert keeps no default button on purpose (SaveCheck.ask), and it stays a mouse or keyboard choice.
  • A follows the Play button's state: it does nothing during the cloud-save check (Play disabled); B works then, as the Quit button does.
  • Play from A goes through the same start() as the button, so the cloud-save check and its questions still come first.

The window logs launcher: Play from a controller (A) / launcher: Quit from a controller (B).

Mac only. The iPhone/iPad launcher (dm/ios/Sources/Launcher.swift) runs the host in the same process, whose DmGamepad.m handlers take the controllers when the game starts, and an iOS app has no Quit. It needs its own check of those handlers and a device test, which an unsigned IPA cannot get from this change, so it is left for a separate PR. Moving through the settings rows with the d-pad is not part of this change either.

Not covered: controllers the host reads outside GameController (raw HID pads, pad_hid_mac.h; Switch 2 controllers over the host's own transport) are not seen by the window.

Checked

  • Tests: dm/ios/tests/test_launcher_storage.py now also compiles launcher_pad_check.swift: 14 decisions (release, not press; B; a button held at the start; after it is let go; a press across an alert, in an alert, held after it; a new press after an alert; the first sample after an alert; A while Play is disabled; B during the cloud-save check; a Play disabled before the release; A and B together; each button its own click). On main the check does not compile (LauncherPad does not exist), so all 14 fail. test_docs.py (6), test_nsp_mac_app.py (63), test_launcher_settings.py (17), every dm/ios/tests/test_*.py: pass. The launcher sources typecheck with no warning in Swift 5 mode.
  • The Mac launcher built with pack_app.py's build_launcher (macOS 26.6 target), in a copy of Ocarina of Time's app (0400486024DEC000) with its own bundle ID and home folder: the window opens (launcher: 18 settings shown, a 560 × 737 window on screen), and the idle timer costs about 0.4 % of a core while the window is not key and about 0.5 % while it is key and in front (CPU time over 10 s). Return and Play were not pressed in this run: keys posted to the app from a script were not delivered (the script has no accessibility permission), so the game was not started from the window. The Play button and its Return shortcut are unchanged lines.
  • A real controller on the same Mac, in that copy's settings window: A starts the game and B quits the window.
  • Devices and OS: Apple silicon Mac, macOS 27.2.
  • regress.py: not run; the change is in the Mac app's settings window and its packer only, which no game run in regress.py goes through.
  • Lint: not run.

Docs

  • docs/settings.md (The Mac settings window): A is Play, B is Quit, on release; held buttons and the cloud-save question; what it does not do.
  • docs/playing.md (On the Mac): one line.

…ts with its B, so couch play needs no mouse; the press that starts the game does not reach it and A never answers the cloud-save question

## What and why

The Mac settings window (`dm/mac/Launcher.swift`) could only be answered with the mouse or the keyboard (Play / Return, Quit / closing the window). With a controller only, the player had to reach for the Mac to start the game.

Now a controller's A is Play and its B is Quit. They are GameController's `buttonA` and `buttonB` on any controller, as the host's own quit and player prompts take them (`front_mac.m` `hq_buttons`, `cp_buttons`); main has no A/B layout setting (seedds#634 is open), so none is added. The decisions are a small pure struct, `LauncherPad`, which a 60 Hz timer in common run-loop modes feeds with the buttons of every controller GameController lists:

- A button counts on its **release**, after a press the window took. The settings go into the environment and the host is spawned only after that (`launcher.c`), in a new process whose GameController reads the controllers from scratch (`pads_changed` reads each one's state at its connection; with `DM_PAD_PRESS_TO_JOIN` a controller joins on a value change). The button is up by then, so the press that started the game reaches it neither as a button nor as a join.
- A button already down when the window starts taking input (held at launch, or through an alert) counts only after it was seen up.
- The window takes no button while it is not key, while an alert or a panel is modal (`NSApp.modalWindow`), with a sheet attached, or while a menu tracks (`RunLoop.current.currentMode == .eventTracking`). A press is dropped when any of these starts. So A never picks a save: the save-sync conflict alert keeps no default button on purpose (`SaveCheck.ask`), and it stays a mouse or keyboard choice.
- A follows the Play button's state: it does nothing during the cloud-save check (Play disabled); B works then, as the Quit button does.
- Play from A goes through the same `start()` as the button, so the cloud-save check and its questions still come first.

The window logs `launcher: Play from a controller (A)` / `launcher: Quit from a controller (B)`.

Mac only. The iPhone/iPad launcher (`dm/ios/Sources/Launcher.swift`) runs the host in the same process, whose `DmGamepad.m` handlers take the controllers when the game starts, and an iOS app has no Quit. It needs its own check of those handlers and a device test, which an unsigned IPA cannot get from this change, so it is left for a separate PR. Moving through the settings rows with the d-pad is not part of this change either.

Not covered: controllers the host reads outside GameController (raw HID pads, `pad_hid_mac.h`; Switch 2 controllers over the host's own transport) are not seen by the window.

## Checked

- Tests: `dm/ios/tests/test_launcher_storage.py` now also compiles `launcher_pad_check.swift`: 14 decisions (release, not press; B; a button held at the start; after it is let go; a press across an alert, in an alert, held after it; a new press after an alert; the first sample after an alert; A while Play is disabled; B during the cloud-save check; a Play disabled before the release; A and B together; each button its own click). On main the check does not compile (`LauncherPad` does not exist), so all 14 fail. `test_docs.py` (6), `test_nsp_mac_app.py` (63), `test_launcher_settings.py` (17), every `dm/ios/tests/test_*.py`: pass. The launcher sources typecheck with no warning in Swift 5 mode.
- The Mac launcher built with `pack_app.py`'s `build_launcher` (macOS 26.6 target), in a copy of Ocarina of Time's app (0400486024DEC000) with its own bundle ID and home folder: the window opens (`launcher: 18 settings shown`, a 560 × 737 window on screen), and the idle timer costs about 0.4 % of a core while the window is not key and about 0.5 % while it is key and in front (CPU time over 10 s). Return and Play were not pressed in this run: keys posted to the app from a script were not delivered (the script has no accessibility permission), so the game was not started from the window. The Play button and its Return shortcut are unchanged lines.
- **Not tested: a real controller press.** No controller was connected to this Mac (an 8BitDo and a DualSense are paired but not connected), and macOS has no `GCVirtualController`. A press on a real controller, and the host seeing nothing of it, still have to be tried.
- Devices and OS: Apple silicon Mac, macOS 27.2.
- regress.py: not run; the change is in the Mac app's settings window and its packer only, which no game run in `regress.py` goes through.
- Lint: not run.

## Docs

- `docs/settings.md` (The Mac settings window): A is Play, B is Quit, on release; held buttons and the cloud-save question; what it does not do.
- `docs/playing.md` (On the Mac): one line.
@github-actions github-actions Bot added packing Building an IPA or a Mac app: the NSP script, extraction, the shader split, the packers ios The iPhone and iPad app (dm/ios) mac The Mac front end and app (dm/mac, front_mac.m) docs Documentation labels Nov 12, 2026
@PucaVaz
PucaVaz marked this pull request as ready for review November 12, 2026 12:33
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) mac The Mac front end and app (dm/mac, front_mac.m) packing Building an IPA or a Mac app: the NSP script, extraction, the shader split, the packers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant