godot: Incorrect ButtonIndex in Xbox controller and MacOS

Godot version

v4.0.beta5.mono.official.89a33d28f

System information

Macos Monterey 12.6

Issue description

InputEventJoypadButton.ButtonIndex return incorrect values for buttons.

  • If X is pressed, it returns Y
  • If Y is pressed, it returns Back

All the buttons return wrong codes, except A(0) and B(1), where it returns the right ButtonIndex.

https://user-images.githubusercontent.com/194074/203168530-6b209573-7332-41a6-8ce5-d21362c48173.mov

Steps to reproduce

This snippet is enough to see the buttons and check if they are correct or wrong:

public override void _Input(InputEvent e) {
    if (e is InputEventJoypadButton b && b.IsPressed() && !b.IsEcho()) {
        GD.Print($"Button {(int)b.ButtonIndex} {b.ButtonIndex}");
    }
}

Minimal reproduction project

wrong-button-index-xbox-controller-on-mac.zip

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 21 (15 by maintainers)

Most upvoted comments

I’m confused by @avilches’s conflicting reports here, based on all the above it looks like the hat mapping for dpad aren’t working, but they may have resolved that issue somehow on their end per gabomdq/SDL_GameControllerDB#660 (comment) ?

Sorry @offalynne and thanks for your time. I have two different controllers:

  • A Xbox Series, which the mapping is ok in the SDL database, so I closed the #660 issue
  • A Xbox Wireless, which is the one I have an issue right now with Godot and the dpads. This controller had a wrong mapping but you have fixed it with the merge.

I can confirm that #80709 fixes the issue for me

Apologies: I’m new here. Not sure if I should revive a closed thread or make a new one, but I’m definitely still getting this incorrect mapping behavior with an Xbox One controller on MacOS 14 with Godot 4.3dev3.

For example: I create a new empty project, go to Project Settings > Input Map, and create an Action. Then when I press what should be the Start button (Xbox Menu) on my controller, it reads as D-pad Up, as shown in the image. If I press the left bumper, that reads as the Start button.

Screenshot 2024-02-27 at 11 57 03 PM

So if I understand correctly this issue is fixed? We might just need to update our copy of SDL_GameControllerDB?

It’s likely a wrong mapping. Check this for steps on creating a controller mapping. It it fixes the issue, you should contribute it to the SDL_GameControllerDB

The controller worked before in Godot 3.5. I tried with a Xbox One controller and Xbox Series S, both failed. Even the mouse wheel up returns MaskMiddle in MacOS too, so I guess it’s a general configuration issue in Godot 4 only.

It’s likely a wrong mapping. Check this for steps on creating a controller mapping. It it fixes the issue, you should contribute it to the SDL_GameControllerDB

@avilches Can you test using GDScript? Or add a MRP that uses GDScript? Just to be sure that the issue lies with Godot and not the C# bindings.

Yes, it’s a Godot problem. I’ve changed the code to GDScript like the screenshot and, after pressing A B X Y, it prints 0,1,3,4 instead of 0,1,2,3

image