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

ABXY button mapping incorrect for Nintendo Switch Pro Controller #88693

Open
Meorge opened this issue Feb 23, 2024 · 10 comments · May be fixed by #89001
Open

ABXY button mapping incorrect for Nintendo Switch Pro Controller #88693

Meorge opened this issue Feb 23, 2024 · 10 comments · May be fixed by #89001

Comments

@Meorge
Copy link
Contributor

Meorge commented Feb 23, 2024

Tested versions

Reproducible in Godot v4.3.dev (b15105a)

System information

Godot v4.3.dev (b15105a) - macOS 14.3.1 - Vulkan (Forward+) - dedicated AMD Radeon Pro 5500 XT - Intel(R) Core(TM) i7-10700K CPU @ 3.80GHz (16 Threads)

Issue description

The mappings for the A, B, X, and Y buttons on the Nintendo Switch Pro Controller are off. The A and B buttons are switched, as are the X and Y buttons. I've attached a short video of my pressing the buttons on the controller and seeing what the editor picked up.

Godot.Switch.Pro.Button.Mapping.Issue.mov

Steps to reproduce

  1. Use a very recent version of Godot (presumably one since Fix controller vibration in macOS and migrate to GameController API #80709 was merged).
  2. In a fresh project, go to Project Settings > Input Map, add a new action, and open the Event Configuration window for that action.
  3. Connect a Nintendo Switch Pro Controller to the computer.
  4. Press the A, B, X, and Y buttons on the controller, and see what button Godot registers.
    • If you press A, Godot will register Joypad Button 0 (Bottom Action, Sony Cross, Xbox A, Nintendo B), despite it being the Right Action button.
    • If you press B, Godot should register Joypad Button 1 (Right Action, Sony Circle, Xbox B, Nintendo A), despite it being the Bottom Action button.
    • If you press X, Godot should register Joypad Button 2 (Left Action, Sony Square, Xbox X, Nintendo Y), despite it being the Top Action button.
    • If you press Y, Godot should register Joypad Button 3 (Top Action, Sony Triangle, Xbox Y, Nintendo X), despite it being the Left Action button.

Minimal reproduction project (MRP)

N/A

@jplewe
Copy link

jplewe commented Feb 28, 2024

I get similar mapping errors with an Xbox One controller on Mac, using a similar system and Godot 4.3.dev setup, as in #68976

@Calinou
Copy link
Member

Calinou commented Feb 28, 2024

I get similar mapping errors with an Xbox One controller on Mac, using a similar system and Godot 4.3.dev setup, as in #68976

Which 4.3.dev commit are you using? #80709 was merged after 4.3.dev3 was released, so I suggest building master from source and testing this again.

@Meorge
Copy link
Contributor Author

Meorge commented Feb 28, 2024

I tested my Xbox Wireless Controller (model 1708) on 4.3.dev3, and its inputs appear to be working as expected:

CleanShot.2024-02-28.at.09.52.07.mp4

On v4.3.dev.gh [b15105a], the Xbox Wireless Controller's ABXY buttons all seem to be mapped correctly for me as well. However, Godot no longer recognizes controller inputs when it is not focused:

Xbox.Controller.on.v4.3.dev.gh.b15105a35.mp4

I'm not sure if this is something I should open a new issue for...? 😅

@Calinou
Copy link
Member

Calinou commented Feb 28, 2024

However, Godot no longer recognizes controller inputs when it is not focused:

This may be a design decision in the GameController API. cc @bruvzg

However, many people may actually welcome this new behavior, even though it's inconsistent with other platforms: #16832

@bruvzg
Copy link
Member

bruvzg commented Feb 28, 2024

It should be possible to enable background listening (it's off by default on macOS 11.3+).

@Meorge
Copy link
Contributor Author

Meorge commented Feb 28, 2024

I was able to clone, build, and run the Godot source today for the first time! 😁 I might see spots in the code that could be responsible for the button mapping issue, so I'll see if I can fix it.

@jplewe
Copy link

jplewe commented Feb 29, 2024

I get similar mapping errors with an Xbox One controller on Mac, using a similar system and Godot 4.3.dev setup, as in #68976

Which 4.3.dev commit are you using? #80709 was merged after 4.3.dev3 was released, so I suggest building master from source and testing this again.

You are correct, this version fixes the xbox one controller mapping issue for me. Thanks!

@Meorge
Copy link
Contributor Author

Meorge commented Feb 29, 2024

Okay, so upon a little further investigation, I have good news and bad news.

The good news: this doesn't appear to be a bug in Godot or #80709 !

The bad news: it's just how Apple decided the Pro Controller should be mapped. 🙃
In this video, I'm pressing A, B, Y, X in order. But the controller test website displays the same wrong mapping, until I go into the Game Controllers section of System Settings and manually remap the buttons.

Switch.Pro.Controller.Mapping.Messed.Up.By.Apple.mp4

I assume Apple did this with the intent of preserving the "semantic meaning" of the buttons - the right button is "confirm" everywhere, the bottom button is "cancel" everywhere, etc. But it's quite frustrating that this no longer has a consistent physical mapping across controllers. How should the Godot side proceed with this?

If anyone else happens to be familiar with the GameController API and knows a good solution to this, then that would be great! Otherwise, over the coming days, I may see what I can learn about it and if there's a way to query the controller for the hardware-level buttons instead of going through the inputs after they've been processed by the API and profiles. Don't know if that'll lead anywhere, but I suppose it's worth a shot.

@bruvzg
Copy link
Member

bruvzg commented Feb 29, 2024

SDL have remapping for these buttons hardcoded (based on controller name), we probably should do the same:

https://github.com/libsdl-org/SDL/blob/0c6a1b636e42b7193027383d75f509a9e5d00214/src/joystick/apple/SDL_mfijoystick.m#L1786-L1806

@bruvzg bruvzg linked a pull request Feb 29, 2024 that will close this issue
@bruvzg
Copy link
Member

bruvzg commented Feb 29, 2024

#89001

@AThousandShips AThousandShips added this to the 4.3 milestone Feb 29, 2024
@akien-mga akien-mga modified the milestones: 4.3, 4.4 Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants