Repository navigation
Let the player remap controller buttons, with tap, toggle and aim modes - #35
Merged
Merged
Conversation
- runtime/controller_map.h: physical buttons named by position (south, east, west, north, shoulders, triggers, stick presses, menu, view, d-pad) map to Switch buttons or none. The default map keeps macOS's names, as before. Pure C, shared by launcher and runtime. - runtime/gamepad.m: applies the layout from TOTK_CONTROLS to every Mac controller. - app/launcher.m: points TOTK_CONTROLS at <data>/controls.txt and checks it before the game starts; a bad line shows an alert with its number instead of the game closing. - tests/test_controller_map.c (+ CI step with UBSan): default, Nintendo layout by position, comments, CRLF, case, none, repeated lines and each kind of bad line. - README: the file format and the Switch layout by position.
- tap: the Switch button is held for 400 ms after each press (run by tapping, as in GTA);
a dispatch_after releases it even when the controller sends no further event.
- toggle: one press turns it on, it ends when the left stick returns to center after moving
(a click at rest waits for the first move); attacking while running does not stop it.
- aim <fire>: held while the button is down except while the fire button is down
("l2 = zr aim r2": L2 draws the bow, R2 shoots); the fire button's own line applies
only while the aim button is up.
- Modes act on physical buttons, so two buttons sharing one Switch button keep their edges.
- Tests for each mode and its errors; README (EN, ZH) with the climbing caveat of a held B.
zecaro
force-pushed
the
feat/controller-remap
branch
from
October 19, 2026 10:28
4301224 to
6e5425e
Compare
DualSense and DualShock 4 touchpad clicks are physical button 16, unused by default
("touchpad = minus" opens the Purah Pad). The aim mode keeps the fire button in 5 bits.
ly05010419
added a commit
that referenced
this pull request
Oct 20, 2026
…ultrawide HUD, 1.4.3 survey, mods, controls.txt) into the Breath of the Wild branch Resolved by hand: nvn_mtl.m (PR #34's paged-bitmap serial sets keep the serial forgetting of 635fb31: totk_serial_del clears a bit; the memory line shows both; the BotW frame reset stays in mtl_present), build_app.py (make -j and the per-game launcher defines), the Makefile (the BotW targets and the Opus test), loader.c (the #57 stale-reference handler and 1.4.3's survey return address are TOTK-only: Breath of the Wild has no GAME_ADDR for them), world_survey.c (BotW keeps its stub, with runtime_survey_sync), README (both update-history rows). Found by the merged build: Breath of the Wild lacked runtime_output_size_current (frontend.m's shortcut text) and runtime_survey_sync (hle_nvn.c); and the add-on content file handles shared fs_host.c's 0x200000000 range, so closing a host file at the title ended the game ("close invalid add-on content handle"): they now start at 0x400000000. Tested on the merged binaries: TOTK 1.2.1 jump session (anomalies 0, occlusion normal, serial set 48,606 / 13 pages), Breath of the Wild DLC + key 3 (k3a6) and key 2 (k2c, 11 of 12 pairs within 5 px). Co-Authored-By: Claude Fable 5.1 <[email protected]>
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.
Mac players could not change which controller button does what. On a DualSense the Switch layout feels backwards, and holding a button to run is tiring.
Change
runtime/controller_map.h(pure C, shared by the launcher and the runtime): physical buttons are named by position (southeastwestnorth,l1r1l2r2l3r3,menu,view, d-pad, andtouchpad, the DualSense / DualShock 4 touchpad click, unused by default), and each one drives a Switch button ornone. With no file, the map is the identity, so nothing changes for existing players.~/Library/Application Support/MacNativeGames/TOTK/controls.txt: onephysical = switch [mode]line per change.#starts a comment, and names are case-insensitive.hold(default): held while the button is down.tap: held for 400 ms after each press, so tapping keeps the player running. Adispatch_afterreleases it when the controller sends no further event.toggle: one press turns it on. It ends when the left stick returns to center after moving, so a click at rest waits for the first move. Other buttons do not end it.aim <fire>: held while the button is down, except while the fire button is down.l2 = zr aim r2draws the bow with L2 and shoots with R2, and R2's own line applies only while L2 is up.app/launcher.m: pointsTOTK_CONTROLSat the file and checks it before the game starts. A bad line opens an alert with its number, so the game never closes at start over a typo.runtime/gamepad.m: loads the layout and applies it to every Mac controller.Tested
tests/test_controller_map.cwith UBSan (also a new CI step)none, repeated lines, every mode, and each kind of bad linegamepad.m,launcher.mwith-Wall -Wextra -Werror, rebased onmain33d7a12python -m unittest discover -s teststap,toggleandaimlinescontroller layout: ... (7 buttons changed); jump, attack, confirm, back, run on L3 and the bow on L2/R2 work in gameIn game
1.4.3 on a Mac with a DualSense and this layout:
south = x(jump),north = a(action),east = b,west = y,l2 = zr aim r2,r2 = zl. The PlayStation button icons come from a local RomFS mod generated from the samecontrols.txt(not part of this PR); they show that every action lands on the button the file names.Not tested
GCExtendedGamepad, so they should map the same way).