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

[macOS] Remap Switch controller buttons. #89001

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bruvzg
Copy link
Member

@bruvzg bruvzg commented Feb 29, 2024

Should fix #88693, not tested, based on SDL code.

@Meorge
Copy link
Contributor

Meorge commented Feb 29, 2024

Just tested it. The button mapping looks good, except that the top (X) button on the Pro Controller (and the Joy-Cons, when both are connected at the same time) is mapped to Joypad Button 1 (Nintendo A).

When an individual Joy-Con is connected, the south button (when holding it like a standalone controller) maps correctly to Joypad Button 0 (Nintendo B), but the other buttons don't seem to have a mapping at all.

@Meorge
Copy link
Contributor

Meorge commented Mar 16, 2024

I'm learning a bit more about the Game Controller framework, and happened upon GCControllerLiveInput.unmapped:

https://developer.apple.com/documentation/gamecontroller/gccontrollerliveinput/4165510-unmapped

This could potentially be used to get around the system-level remapping that macOS provides. From there, getting the correct button mappings for the face buttons should be straightforward: https://developer.apple.com/documentation/gamecontroller/gcextendedgamepad

  • buttonA is always the bottom/south button
  • buttonB is always the right/east button
  • buttonX is always the left/west button
  • buttonY is always the top/north button

@Meorge
Copy link
Contributor

Meorge commented Mar 16, 2024

I've submitted a PR to the branch that fixes the top button mapping!

@akien-mga akien-mga modified the milestones: 4.3, 4.x Jun 21, 2024
@Calinou
Copy link
Member

Calinou commented Aug 22, 2024

I've submitted a PR to the branch that fixes the top button mapping!

@bruvzg Bump 🙂

For context, the PR is bruvzg#3.

@Meorge
Copy link
Contributor

Meorge commented Aug 23, 2024

Thanks for the bump! Unfortunately, I'm not sure if it would make sense to merge this currently. From the investigation I did back in February and March, it appeared that the bad button mapping was something built in to macOS, not Godot.

Here is a snippet from the bug report I submitted to Apple on March 16:

The documentation for GCExtendedGamepad (https://developer.apple.com/documentation/gamecontroller/gcextendedgamepad) states that the four face buttons are based on their position. The "A button" is the bottom button, the "B button" is the right button, the "X button" is the left button, and the "Y button" is the top button. However, Nintendo Switch controllers have these labels in different positions; the right button is labeled "A", for example. My guess is that the person in charge of mapping these controllers saw that they were labeled with the same letters as in the documentation, and went along with those instead of mapping them according to their position.

For the Switch controllers, the mappings for buttonA and buttonB should be swapped, as should the mappings for buttonY and buttonX.

I just tried the Pro Controller again on the latest macOS Sonoma, 14.6.1, and the issue is still there (just using an online gamepad tester, no Godot involved).

Hopefully for the sake of games on Apple platforms, they'll fix it on their end. But I'm not sure if it makes sense for Godot to implement an edge-case workaround for these controllers, because they'll conflict with OS-level overrides and such.

While I think we could theoretically revert the macOS controller support to use systems other than the Game Controller framework (basically undoing #80709), that seems like a bad idea:

  • It would separate Godot's controller settings from OS-level settings specifically for game controllers. A user might have configured their OS to remap some controller buttons, but without the Game Controller framework, Godot wouldn't recognize that.
  • It sounds like the use of Game Controller fixes/improves haptics support for controllers, and I like haptics a lot.
  • It was this person's first merged contribution to Godot and I don't want to take that away from them 🥲 💔

Wiser and more experienced minds than myself may have stronger opinions about how to proceed here. The two feasible paths I see are:

  • Merge this for now, and then when (if?) Apple fixes the mapping on their end, we make another PR that undoes this edge case handling.
  • Don't merge this and hope that Apple fixes the bug soon. I don't know how common it is for players to try to use a Pro Controller with Godot games, so it might just be that no one (or at least an insignificant number of people) notices until Apple pushes a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ABXY button mapping incorrect for Nintendo Switch Pro Controller
4 participants