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

Incorrect ButtonIndex in Xbox controller and MacOS #68976

Closed
avilches opened this issue Nov 21, 2022 · 22 comments
Closed

Incorrect ButtonIndex in Xbox controller and MacOS #68976

avilches opened this issue Nov 21, 2022 · 22 comments

Comments

@avilches
Copy link
Contributor

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.

Screen.Recording.2022-11-21.at.23.02.17.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

@pkdawson
Copy link
Contributor

I see normal button presses with a Switch Pro controller on macOS 13, so I suspect the issue is with one particular controller mapping.

@avilches
Copy link
Contributor Author

Mouse wheel up returns MaskMiddle in MacOS too.

@adamscott
Copy link
Member

@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.

@avilches
Copy link
Contributor Author

avilches commented Nov 22, 2022

@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

@rsubtil
Copy link
Contributor

rsubtil commented Jan 31, 2023

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
Copy link
Contributor Author

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.

@avilches
Copy link
Contributor Author

avilches commented Feb 3, 2023

I tried in Godot 4 beta 11 and it works. I'm closing this issue.
UPDATED: closed by mistake, it's still present

@avilches avilches closed this as completed Feb 3, 2023
@akien-mga akien-mga added this to the 4.0 milestone Feb 3, 2023
@avilches avilches reopened this Feb 6, 2023
@avilches
Copy link
Contributor Author

avilches commented Feb 6, 2023

I had to reopen it (I have different Xbox controllers, and some of them work, and others don't).

I have one specific Xbox controller which is failing in Godot 3.5.1 (this is the original one I was using when I opened this issue in the first place).
After the comment from @adamscott , I realized the GUI from my controller 030000005e040000200b000015050000 wasn't present in the SDL Database, so I've created a new mapping using the GamePad tool, and I've also opened an issue to include it in future version of Godot: mdqinc/SDL_GameControllerDB#661

Now, if use this new environment variable

export SDL_GAMECONTROLLERCONFIG="030000005e040000200b000015050000,Xbox Wireless Controller,platform:Mac OS X,a:b0,b:b1,x:b3,y:b4,back:b10,guide:b12,start:b11,leftstick:b13,rightstick:b14,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a5,righttrigger:a4,"

Then the X,Y are fixed, but the dpad doesn't work.

wrong-mapping-2

@rsubtil
Copy link
Contributor

rsubtil commented Feb 7, 2023

Does this issue also happen when you connect the controller with a cable? And just to confirm, this issue is present on both 4.0 and 3.5.1?

@offalynne
Copy link

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 mdqinc/SDL_GameControllerDB#660 (comment) ?

I've merged the mapping submitted for 030000005e040000200b000015050000 (mdqinc/SDL_GameControllerDB#661) here, though it is also using hat values for dpad.

@avilches
Copy link
Contributor Author

avilches commented Feb 8, 2023

Does this issue also happen when you connect the controller with a cable? And just to confirm, this issue is present on both 4.0 and 3.5.1?

The controller only works by bluetooh, I've tried with a microUSB to USBc conector with no success. I've tried with the godot-demo-projects/misc/Joypads app (branch 4.0-dev) with Godot 4 beta 11, and same behaviour

@avilches
Copy link
Contributor Author

avilches commented Feb 8, 2023

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.

@akien-mga
Copy link
Member

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

@akien-mga akien-mga modified the milestones: 4.0, 4.1 Feb 27, 2023
@avilches
Copy link
Contributor Author

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

Partially. The left digital pad is still not working well even with the patches: you press down and Godot shows down+left... If you update your copy from SDL_GameControllerDB just close this issue, and I will check again in the next version, opening an issue if it's still needed.

@YuriSizov YuriSizov modified the milestones: 4.1, 4.2 Jun 22, 2023
@YuriSizov
Copy link
Contributor

We've updated the database multiple times since this report. It's worth checking if Godot 4.2 still shows the same issue or not. But it's likely an upstream problem, if I understand correctly?

I guess we can close it and see any new reports happen.

@johnnyw
Copy link
Contributor

johnnyw commented Dec 22, 2023

Observing incorrect button mappings on macOS 14.2.1 with an Xbox One X controller and Godot 4.2.1.

@ZachLobato
Copy link

ZachLobato commented Jan 11, 2024

The Xbox Controller buttons are messed up on my Elite Series 2 Xbox Controller.

I upgraded to Godot v4.2.1.stable.official [b09f793f5] yesterday and ran into all sorts of controller issues.

The Event Configuration mostly works (details below), but for some reason there's a disconnect between that menu and the actual input grabbed from the running game.

The following are the results of my testing between Godot and the online Gamepad Tester (hardwaretester.com) and I'm using this documentation for the names of XBox buttons:

Testing

Godot

Event Configuration Menu

Not Working Correctly
DPad-Right and DPad-Down register an "Up" event when released.
Profile button -> Paddle 1 button just pressed

Actual Running Game

To test this, in the Project Settings, I mapped every registered button to an action of its same name (using the auto-detect in Godot with a controller press) and then started the game and just started clicking those same buttons

var all_buttons = [
	'A-Button',
	'B-Button',
	'X-Button',
	'Y-Button',
	'RB-Button',
	'LB-Button',
	'Menu-Button',
	'View-Button',
	'DPad-Up-Button',
	'DPad-Right-Button',
	'DPad-Down-Button',
	'DPad-Left-Button',
	'Profile-Button',
]

func _process(delta):
	for button in all_buttons:
		if Input.is_action_just_pressed(button):
			print(button + ' just pressed')
Not Working Correctly

When the game starts, the game registers DPad-Up and Profile buttons being pressed automatically.

Button Press -> Result

LB button -> Left and Menu buttons just pressed
View button -> View, Y, and RB buttons just pressed
Menu button -> Menu and DPad-Up buttons just pressed
Left Thumbstick Click button -> DPad-Left button just pressed
Right Thumbstick Click button -> DPad-Right button just pressed

X button -> X and Y buttons just pressed
Y button -> Y and View buttons just pressed

DPad-Up button -> DPad-Up and DPad-Right buttons just pressed

DPad-Right button just pressed -> DPad-Right and DPad-Down buttons just pressed
DPad-Right button Released -> DPad-Up button just pressed

DPad-Down button just pressed -> DPad-Down and DPad-Left buttons just pressed
DPad-Down button Released -> DPad-Up button just pressed
Working
Button Press -> Result

RB button -> RB button just pressed
B button -> B button just pressed
A button -> A button just pressed
DPad-Left button -> DPad-Left button just pressed

Profile button -> nothing registers on press (makes sense as it is supposed to change controller profiles)

Gamepad Tester (hardwaretester.com)

I only put this here as evidence that my controller doesn't have problems. Everything working except what's not on their UI, which is to be expected.

Not Working Correctly
Neither of the four paddle buttons on the back nor the Profile button register on this website.
Working

I only provide this in the event their mappings (i.e. B5, B4, etc) are helpful.

Button Press -> Result

RB button -> RB button just pressed (B5)
LB button -> LB button just pressed (B4)
View (Select) button -> View button just pressed (B8)
Menu (Start) button -> Start button just pressed (B9)

Left Thumbstick Click button -> DPad-Left button just pressed (B10)
Right Thumbstick Click button -> DPad-Right button just pressed (B11)

X button -> X button just pressed (B2)
Y button -> Y button just pressed (B3)
B button -> B button just pressed (B1)
A button -> A button just pressed (B0)

DPad-Up button -> DPad-Up button just pressed (B12)
DPad-Right button -> DPad-Right button just pressed (B15)
DPad-Down button just pressed -> DPad-Down button just pressed (B13)
DPad-Left button -> DPad-Left button just pressed (B14)

Haha after all this testing, would love to find out this is a me (or my hardware) problem. But crossing my fingers that this may also be helpful to understanding this issue.

Update ** I removed the issues with the paddle buttons as those get re-mapped and when I was pressing the Profile button it was messing with the test. Also, I have an 8BitDO SN30 pro+ controller that I ran these same tests with and it works perfectly fine.

@Cuddl3s
Copy link

Cuddl3s commented Jan 18, 2024

The Xbox Controller buttons are messed up on my Elite Series 2 Xbox Controller.

I upgraded to Godot v4.2.1.stable.official [b09f793f5] yesterday and ran into all sorts of controller issues.

The Event Configuration mostly works (details below), but for some reason there's a disconnect between that menu and the actual input grabbed from the running game.

The following are the results of my testing between Godot and the online Gamepad Tester (hardwaretester.com) and I'm using this documentation for the names of XBox buttons:

Testing

Godot

Gamepad Tester (hardwaretester.com)

Haha after all this testing, would love to find out this is a me (or my hardware) problem. But crossing my fingers that this may also be helpful to understanding this issue.

Update ** I removed the issues with the paddle buttons as those get re-mapped and when I was pressing the Profile button it was messing with the test. Also, I have an 8BitDO SN30 pro+ controller that I ran these same tests with and it works perfectly fine.

I can confirm, I ran into a similar problem with my Elite v2. x button did not register for me, but I found out that if I check for the Y button being pressed, that actually works when I press X.

@jplewe
Copy link

jplewe commented Feb 28, 2024

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

@nikoladigi
Copy link

I can report same behaviour @jplewe describes on godot 4.2.1 MacOs

@jplewe
Copy link

jplewe commented Feb 29, 2024

I can confirm that #80709 fixes the issue for me

@KurtDaill
Copy link

KurtDaill commented Sep 11, 2024

Still seeing this issue on Godot 4.3. Same exact issue, even down to "start" being mapped to the left shoulder button. Currently running Godot 4.3 for Linux, without .Net, using an Xbox One Controller.

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

No branches or pull requests