Skip to content

iOS front end: DM_PAD_MAP moves the buttons of physical controllers (on #386) - #955

Open
Haseenesss wants to merge 2 commits into
seedds:mainfrom
Haseenesss:ios-pad-map
Open

Haseenesss wants to merge 2 commits into
seedds:mainfrom
Haseenesss:ios-pad-map

Conversation

@Haseenesss

Copy link
Copy Markdown
Contributor

What and why

Depends on #386. This branch is #386's commit plus one new commit, the last one (iOS front end: DM_PAD_MAP moves the buttons of physical controllers). Review only that one. I will rebase onto main once #386 lands.

The Mac front end applies DM_PAD_MAP to controller buttons (#386). The iOS front end ignored it, so a front end that offers a button mapping, for example Swap A and B, had no effect on an iPhone or iPad.

dm/ios/Sources/DmGamepad.m now:

  • parses DM_PAD_MAP with input_map.h when the pads start, and logs it (malformed entries are left out and named in the log, as on the Mac)
  • passes each physical controller's buttons through pad_map_apply before dm_pad_set_player

The touch gamepad is not mapped. As on the Mac, only physical controllers are. docs/env_switches.tsv and docs/development.md now say the switch works on iOS too.

The need comes from NX2Apple's iOS shell, which now offers a global and a per-game button mapping and passes it as DM_PAD_MAP (LNPANDY/NX2Apple#494, LNPANDY/NX2Apple#495). There it is carried as a patch until this lands.

Checked

  • Tests: dm/tools/tests test_docs, test_env_switches and test_player_env pass. The change adds no parser code: t_input_map.c from Mac front end: DM_KEYMAP and DM_PAD_MAP move buttons to other keys and controller buttons #386 covers pad_map_parse and pad_map_apply.
  • Games run, with title ID and version: three games in an iOS shell build on the iPad below, with a controller. DM_PAD_MAP=A=B,B=A swaps A and B in game. Without DM_PAD_MAP the buttons are as before. The touch gamepad is unchanged.
  • Devices and OS: iPad mini (A17 Pro), iPadOS 27.2. Built with Xcode 27.2, Release.
  • regress.py: none. The change is in dm/ios only, which no Mac build compiles, and it does nothing unless DM_PAD_MAP is set.
  • Not checked: an iPhone, and controllers other than the one used.

Docs

  • The finding is in its game note or its docs/reference/<subsystem>.md entry, and python3 dm/tools/docs_symptoms.py was run (the symptom index): no finding, the switch's entries in docs/env_switches.tsv and docs/development.md are updated
  • A chain tool changed: dmsh_chain.py --header was run and dm/gfx/nvn/dmsh_chain.h is part of the change (no chain change)
  • No game files, keys or data extracted from a game in the change or the attachments

🤖 Generated with Claude Code

v0lumehi and others added 2 commits October 31, 2026 04:39
…d controller buttons, and a Mac app keeps them as saved choices

The keyboard's keys and the controllers' buttons were fixed in
front_mac.m (key_bit and pad_read), so a player who wanted A on another
key, the camera on the keyboard, or A and B swapped on a controller had
no way to get it. Both maps now come from input_map.h, a pure header the
front end reads at start:

- DM_KEYMAP=<name>=<key code>,... puts a function on another key. The
  names are those of DM_KEYS (A ... Down, LUp ... RRight, Shake); the
  key code is the macOS virtual key code, or "none". One key holds one
  function: a key's earlier function is left on no key, so A=40,B=38
  swaps A and B. The defaults are the keys as before; the right stick,
  which had no keys, can now have some.
- DM_PAD_MAP=<name>=<name>,... makes the button that sends the first
  name by default send the second, after the default mapping by
  position, so it composes with however that mapping is made.

Unset, both maps are the previous assignments, and the keyboard's held
keys still release on focus loss and for the text box. A malformed
entry is left out with a [RED] line; the rest still applies.

A Mac app's launcher also reads launcher.DM_KEYMAP and
launcher.DM_PAD_MAP from the app's preferences domain, in the same pass
and order as the other saved choices (launch environment, env.txt files,
saved choices) and with DM_SAVED_CHOICES=0. They are no launcher.json
rows, so DMSettings cannot check them: the launcher includes
input_map.h and asks input_map_valid(), the host's own parser without
its log lines or a map. A value the host would not take whole (an
unknown name, a key code past 127, a button where a key code belongs,
empty, not a string) is ignored and logged. The controls are read
whether or not the settings window ran, as the window does not offer
them. pack_app.py lists input_map.h and dm_input.h among the launcher's
inputs, so a change to them repacks.

t_input_map (30 checks) covers the defaults, moves, swaps, none,
case-insensitive names, the malformed entries and input_map_valid.
test_nsp_mac_app.test_saved_controls starts a packed app with saved
values: applied, environment and env.txt winning, DM_SAVED_CHOICES=0,
invalid values ignored. The Mac host builds
(make -C dm/host GAME=010015100B514000). The switches are in
docs/env_switches.tsv (env_switches.py --check), the development guide's
input row and docs/frontends.md (Saved choices); impact_map.tsv gets a
rule for input_map.h.
The Mac front end applies DM_PAD_MAP to controller buttons (seedds#386), the iOS
one ignored it, so a front end that offers a button mapping, such as Swap A
and B, had no effect on an iPhone or iPad. DmGamepad.m now parses
DM_PAD_MAP with input_map.h when the pads start, logs it, and passes each
physical controller's buttons through pad_map_apply before
dm_pad_set_player. The touch gamepad is unchanged, as on the Mac only
physical controllers are mapped. docs/env_switches.tsv and
docs/development.md say so.

Checked: built into an iOS app (Release, Xcode 27.2) on an iPad mini
(A17 Pro), iPadOS 27.2, with a controller: DM_PAD_MAP=A=B,B=A swaps A and
B in game, no DM_PAD_MAP leaves the buttons as they were.
Haseenesss added a commit to Haseenesss/NX2Apple that referenced this pull request Nov 2, 2026
The upstream pull request builds on seedds/nxnative#386, which is patch
0009 here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added host The Horizon host: SVCs, services, threads, memory (dm/host) 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) tools Tools and scripts (dm/tools, scripts) docs Documentation labels Nov 3, 2026
eyasbzour added a commit to eyasbzour/nxnative-online that referenced this pull request Nov 13, 2026
…s#955)

DmGamepad.m parses DM_PAD_MAP with input_map.h when the pads start and maps
each controller's buttons before dm_pad_set_player; the touch gamepad is not
mapped. Applied after press-to-join and the controller prompt.
lucaszhongsj pushed a commit to lucaszhongsj/nxnative that referenced this pull request Nov 19, 2026
Upstream-Status: forwarded seedds#955 (on seedds#386, patch 0009)
Reason: the iOS host ignores DM_PAD_MAP, so the shell's button mapping (global and per game) never reaches physical controllers. The Mac host applies it already
Issue: LNPANDY/NX2Apple#494
sofianbll pushed a commit to sofianbll/nxnative that referenced this pull request Nov 28, 2026
Upstream-Status: forwarded seedds#955 (on seedds#386, patch 0009)
Reason: the iOS host ignores DM_PAD_MAP, so the shell's button mapping (global and per game) never reaches physical controllers. The Mac host applies it already
Issue: LNPANDY/NX2Apple#494

Taken from LNPANDY/NX2Apple a79d397 (MIT), patches/0011-ios-apply-controller-button-mappings-to-physical.patch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation host The Horizon host: SVCs, services, threads, memory (dm/host) 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 tools Tools and scripts (dm/tools, scripts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants