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 <[email protected]>
@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 <[email protected]>
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