Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed top button mapping for Switch Pro and dual Joy-Con controllers #3

Open
wants to merge 1 commit into
base: macos_switch
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions platform/macos/joypad_macos.mm
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,9 @@ - (void)setControllerInputHandler:(GCController *)controller {

int joy_id = [self getJoyIdForController:controller];
Joypad *joypad = [self getJoypadForController:controller];

// NOTE: The individual Joy-Cons don't seem to use the extendedGamepad
// profile type, so they never reach this code.
bool switch_joycon = (joypad != nil) ? joypad.switch_joycon : false;
bool switch_pro = (joypad != nil) ? joypad.switch_pro : false;

Expand All @@ -483,10 +486,11 @@ - (void)setControllerInputHandler:(GCController *)controller {
gamepad.buttonB.isPressed);
}
} else if (element == gamepad.buttonX) {
if (switch_pro) {
Input::get_singleton()->joy_button(joy_id, JoyButton::B,
gamepad.buttonX.isPressed);
} else if (switch_joycon) {
if (switch_pro || switch_joycon) {
// Apple mismapped the Switch Pro Controller's top button
// (labeled "X" on the controller) to the left button
// (which Apple calls "X").
// So this should actually be the Y button (top button).
Input::get_singleton()->joy_button(joy_id, JoyButton::Y,
gamepad.buttonX.isPressed);
} else {
Expand Down