Skip to content

Map Nintendo controller buttons by label on Mac and iOS - #650

Closed
peterkmet wants to merge 2 commits into
seedds:mainfrom
peterkmet:fix/nintendo-pad-labels
Closed

peterkmet wants to merge 2 commits into
seedds:mainfrom
peterkmet:fix/nintendo-pad-labels

Conversation

@peterkmet

@peterkmet peterkmet commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

macOS and iOS name the face buttons of a Switch Pro Controller or Joy-Con by their labels, not by their position. The host mapped every pad by position, so A/B and X/Y were swapped on Nintendo pads. pad_nintendo() detects these pads by productCategory and maps their buttons by label; other pads keep the position mapping. Checked with a Pro Controller on the Mac and on iOS.

@peterkmet
peterkmet force-pushed the fix/nintendo-pad-labels branch from 988a7af to 52ce0ed Compare October 29, 2026 18:41
seedds added a commit that referenced this pull request Oct 30, 2026
… and iOS (PR #650)

GameController names a Switch Pro Controller's and Joy-Con's face buttons by their printed labels, every other pad's by position, so the host's position mapping swapped A/B and X/Y on Nintendo pads. pad_apple.h holds the rule for both front ends (dm_pad_face), with a test; a single Joy-Con held sideways is matched too and is untested (open, in the header).

Co-authored-by: Peter Kmet <55005408+peterkmet@users.noreply.github.com>
@seedds

seedds commented Oct 30, 2026

Copy link
Copy Markdown
Owner

Thanks! Landed in 90eca2f with you as co-author. Your detection and label mapping are kept as they were. The rule now lives in one shared header, dm/host/pad_apple.h (dm_pad_face), which both front ends use, and it has a test (dm/host/tests/t_pad_apple.m). The comments and docs that still said "by position" are updated.

One open point: containsString:@"Joy-Con" also matches a single Joy-Con, and a sideways single Joy-Con hasn't been tried. If you have one, could you check whether its face buttons come out right when it's held sideways? If GameController keeps the printed labels there instead of rotating them with the controller, they'd be a quarter turn off.

@seedds seedds closed this Oct 30, 2026
subyoung added a commit to subyoung/nxnative that referenced this pull request Oct 30, 2026
With each controller a player of its own on iOS (fdea829), a pair of Joy-Con still could not be held sideways as two players, as on a Switch: iPadOS hands the pair over as one combined controller ("Joy-Con (L/R)") and does not offer the halves separately. There was also no way to see or change which controller is which player before the game starts.

Held sideways, the pair now becomes two players: the left half on the controller's own player, the right half on the next free one (a second slot in pad_slots.h, freed with the controller). Each half's stick is turned a quarter and its four buttons are read by their new positions. GameController names a Joy-Con's face buttons by their printed labels (pad_apple.h, PR seedds#650) and does not turn them with the pair: a button log on the iPad gave buttonY, buttonX, buttonA and buttonB for the right half's top, right, bottom and left. So its X, A, Y and B are its right, bottom, top and left buttons. SL and SR are not in the combined profile, so each half's own shoulder buttons stand in: L or R is L, ZL or ZR is R. The pair's gyro goes to the left half's player.

The launcher's new Players section (LauncherControllers.swift) lists the players as the game will get them. It lets the player hold each pair upright or sideways (players.joyconSideways.<pair>) and change the order (players.order); DmGamepad.m takes the controllers in that order. After a run it greys out the controllers past what the game takes: hle_hid.c's new dm_pad_players_accepted counts that from SetSupportedNpadIdType, and the app keeps it as players.max. DM_JOYCON_SIDEWAYS=0|1 in the environment overrides the hold.

A pair held upright maps its face buttons through dm_pad_face (pad_apple.h), as any other Nintendo pad.

Checked: make -C dm/host/tests run (t_hid gains t_accepted, 123 checks), dm/tools/tests test_docs and test_env_switches, DmGamepad.m with -Wall -Wextra -Werror and the launcher's Swift files for iOS. On an iPad Air 13-inch (M3), iPadOS 27.2, with Super Mario Bros. Wonder 1.2.1: one Joy-Con pair held sideways as players 1 and 2.
@peterkmet
peterkmet deleted the fix/nintendo-pad-labels branch October 30, 2026 10:26
@peterkmet

Copy link
Copy Markdown
Contributor Author

Thanks! I have Switch Joy-Cons and will test a single Joy-Con held sideways over the weekend.

Know-It-All-Brother pushed a commit to Know-It-All-Brother/nxnative that referenced this pull request Nov 9, 2026
… and iOS (PR seedds#650)

GameController names a Switch Pro Controller's and Joy-Con's face buttons by their printed labels, every other pad's by position, so the host's position mapping swapped A/B and X/Y on Nintendo pads. pad_apple.h holds the rule for both front ends (dm_pad_face), with a test; a single Joy-Con held sideways is matched too and is untested (open, in the header).

Co-authored-by: Peter Kmet <55005408+peterkmet@users.noreply.github.com>
acarpe pushed a commit to acarpe/nxnative that referenced this pull request Nov 28, 2026
The host maps face buttons by position, as on a Switch controller
(right A, bottom B, top X, left Y), on every pad but Nintendo's, so on
a pad lettered as an Xbox pad the button marked X presses the game's
Y: in Ocarina of Time (0400486024DEC000, v131072) with a Steam
Controller, X swung the sword and Y jumped. That is by design (PR seedds#650)
and keeps the game's prompts pointing at the right place; the only way
to the letters was swapping buttons in the Mac's Game Controllers
settings, which changes every app and does not reach a controller
GameController does not list.

A new setting, Buttons by letter (DM_PAD_LETTERS=1, off by default),
makes a pad with an Xbox pad's letters press the Switch button of the
letter it shows (dm_face_by_letter, dm_input.h): GameController's pads
other than Nintendo's by the names GameController gives their buttons
(pad_apple.h, Mac and iOS), raw HID pads in the default and Xbox 360
maps by usage (pad_hid.h; DM_HID_MAP entries still replace them), and
the Steam Controller (pad_steam.h). Nintendo's controllers, report 0x3F
and the Switch wired layout keep their maps. New reference entry: Face
buttons by position, not by an Xbox pad's letters; playing.md points to
the setting. regress.py impact maps pad_hid.h to the games' hid
functions (dm/tools/impact_map.tsv).

Checked: t_pad_apple (an Xbox, a DualSense and a generic pad by letter,
a Pro Controller unchanged, 0 by position), t_pad_hid (the default and
Xbox 360 maps, DM_HID_MAP over them, Nintendo's report and the
Switch wired layout unchanged), t_pad_steam, make run in dm/host/tests,
the Mac host build, test_docs, test_env_switches,
test_launcher_settings, test_usage. With the setting on, the Steam
Controller's A reached Ocarina of Time as A (DM_HID_LOG), over
Bluetooth LE too each face button pressed its letter's Switch button,
and the player reported its face buttons by letter. Not run: iOS, an
Xbox pad or a DualSense, regress.py check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acarpe pushed a commit to acarpe/nxnative that referenced this pull request Nov 28, 2026
The host maps face buttons by position, as on a Switch controller
(right A, bottom B, top X, left Y), on every pad but Nintendo's, so on
a pad lettered as an Xbox pad the button marked X presses the game's
Y: in Ocarina of Time (0400486024DEC000, v131072) with a Steam
Controller, X swung the sword and Y jumped. That is by design (PR seedds#650)
and keeps the game's prompts pointing at the right place; the only way
to the letters was swapping buttons in the Mac's Game Controllers
settings, which changes every app and does not reach a controller
GameController does not list.

A new setting, Buttons by letter (DM_PAD_LETTERS=1, off by default),
makes a pad with an Xbox pad's letters press the Switch button of the
letter it shows (dm_face_by_letter, dm_input.h): GameController's pads
other than Nintendo's by the names GameController gives their buttons
(pad_apple.h, Mac and iOS), raw HID pads in the default and Xbox 360
maps by usage (pad_hid.h; DM_HID_MAP entries still replace them), and
the Steam Controller (pad_steam.h). Nintendo's controllers, report 0x3F
and the Switch wired layout keep their maps. New reference entry: Face
buttons by position, not by an Xbox pad's letters; playing.md points to
the setting. regress.py impact maps pad_hid.h to the games' hid
functions (dm/tools/impact_map.tsv).

Checked: t_pad_apple (an Xbox, a DualSense and a generic pad by letter,
a Pro Controller unchanged, 0 by position), t_pad_hid (the default and
Xbox 360 maps, DM_HID_MAP over them, Nintendo's report and the
Switch wired layout unchanged), t_pad_steam, make run in dm/host/tests,
the Mac host build, test_docs, test_env_switches,
test_launcher_settings, test_usage. With the setting on, the Steam
Controller's A reached Ocarina of Time as A (DM_HID_LOG), over
Bluetooth LE too each face button pressed its letter's Switch button,
and the player reported its face buttons by letter. Not run: iOS, an
Xbox pad or a DualSense, regress.py check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants