Repository navigation
launcher: A/B buttons setting for the Nintendo or Xbox / PlayStation layout - #634
oliverames wants to merge 4 commits into
Conversation
376eb15 to
78f162f
Compare
78f162f to
5b4b45f
Compare
|
I think you might want to handle the pad_hid case also? |
5b4b45f to
aebe3e5
Compare
|
Thanks @tomcool420, good catch. The raw HID gamepad path ( |
04e2f96 to
ac05703
Compare
b7e81b9 to
c020c14
Compare
|
Rebased onto main 7f50222 with no conflicts (main's Pro Controller/HID changes kept; the DM_PAD_AB hook sits beside them in pad_hid_mac.h). t_pad_hid (30 checks), t_pad_apple, test_docs/test_settings/test_launcher_settings pass. |
c020c14 to
e74a684
Compare
…layout DM_PAD_AB=nintendo (the default) keeps the Switch's face buttons, A on the right and B at the bottom. DM_PAD_AB=xbox puts A (Cross) at the bottom and B (Circle) on the right, as Xbox and PlayStation controllers print them. The row is in dm/games/settings.tsv, so every generated launcher.json offers it on the iPhone and the Mac. The iPhone touch gamepad moves the A and B keys to the chosen positions, and physical controllers on both front ends swap their A/B mapping. X and Y keep their positions. Checked: test_launcher_settings, test_env_switches and test_docs (27 tests); the Mac host builds for Breath of the Wild; DmGamepad.m passes an iOS SDK syntax check. No device or controller testing (minor change, not requested).
e74a684 to
4b87662
Compare
…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. (cherry picked from commit ccff249)
|
Checked on a device: iPhone (A20 Pro, iOS 27.2) with a SCUF NOMAD mobile controller (Xbox-style labels, A at the bottom), Zelda: Ocarina of Time One difference to note: the build we ran also mapped X and Y by label (A=B, B=A, X=Y, Y=X, the same as the Mac's "Xbox Labels" Button Mapping preset), and the touch gamepad drew X left / Y top to match. In this PR X/Y stay positional ( |
|
@seedds I merged current main into this branch in f0b0d00. Main moved the HID code to per-layout button maps, so
|
|
Thanks @oliverames for the work on this and for keeping the branch rebased against the recent HID changes! Closing this PR because automatic Nintendo face-button detection is already on Still open: landing the four-button manual override (#3387 / shared controls in #386), and deciding whether the iPhone touch gamepad should also offer an alternate face-button layout. |
What and why
The face-button layout is fixed today: physical controllers map by position (right = A, bottom = B), a Nintendo pad by its labels (
dm_pad_labelled), and the iPhone touch gamepad draws A on the right, as on a Switch controller. On an Xbox or PlayStation controller the printed A / Cross is at the bottom, so pressing it sends the game's B (cancel), and the touch gamepad shows the opposite of the controller's labels.This adds a Controls → A/B buttons launcher row (
DM_PAD_AB), so every game gets it:The iPhone touch gamepad moves the A and B keys to the chosen positions; physical controllers on iOS and the Mac swap their A/B mapping. X and Y keep their positions. The value is read once at launch, like the other launcher settings.
This is the player-facing choice. #180 (controller detection) and #102 (the Mac-only
DM_PAD_LAYOUT=letters) are both closed, andmainnow detects a Nintendo controller by its labels (dm_pad_labelled). An explicitDM_PAD_AB=xboxshould win over that detection because the player chose it.Checked
python3 -m unittest dm.tools.tests.test_launcher_settings dm.tools.tests.test_env_switches dm.tools.tests.test_docs: 27 passed before the rebase onto main. After it,test_docs,test_settingsandtest_launcher_settingspass,t_pad_hid(30 checks) andt_pad_applepass, andtest_env_switchesfailed only for names that failed on main too at the time (DM_NVN_BC_ALIASand docs quoting removed switches); it passes on main now.make -C dm/host GAME=01007EF00011E000, passes.DmGamepad.mpasses an iOS SDK syntax check (xcrun --sdk iphoneos clang -fsyntax-only ...).scripts/regress.py check --games: not run (input-only change; no rendering, shader or game-facing host path).Front ends
None: no front end has to act on this. The choice reaches the front ends as the
DM_PAD_ABenv switch and a settings row, which git shows (docs/env_switches.tsv,dm/games/settings.tsv);front.his unchanged.Docs
docs/settings.md(Controls and the env table),docs/playing.md, anddocs/env_switches.tsv; no game note or symptom entry applies.dmsh_chain.py --headerwas run anddm/gfx/nvn/dmsh_chain.his part of the change. Not applicable: no chain tool changed.Rebased onto main
fd8188c9on 2026-11-10 with no conflicts (head4b876627). On that headtest_env_switches(1),test_docs(6),test_launcher_settings(17),test_xcode_workflow(7) andtest_settings(3) pass,t_pad_hidpasses 30 checks andt_pad_applepasses, the host builds, the unsigned iOS app builds, and clang-tidy has no finding in the changed files. The first commit carried the wrong author address by mistake; all commits are now under mine.