godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.89k stars 21.04k forks source link

Controller doesn't work as expected in v3.2.3RC3 #41065

Closed salvob41 closed 3 years ago

salvob41 commented 4 years ago

Controller DPad and Analogic don't work as expected in Godot v3.2.3RC2

It works as intented in Godot v3.2.2 stable

Godot version: Godotv3.2.3RC2

OS/device including version: macOS Catalina

Minimal reproduction project:

I created a mainScene with a few buttons in a grid. In Godot v3.2.2 I can move around those buttons with my controller with DPad or Analogic.

When I open it with Godot v3.2.3RC2 I cannot move around, and when I press ANY key on the Dpad it seems like I pressed the button.

(The mapping of the controller I am using is already in https://github.com/godotengine/godot/blob/57e3d04ea2e2d5da5e66384aca6ebb59b2a07f8e/core/input/gamecontrollerdb.txt#L316 )

test323RC2.zip

salvob41 commented 4 years ago

I realized that now we are in RC3, but the issue still applies

madmiraal commented 4 years ago

It sounds like your controller is now working like a controller, whereas before it wasn't. The mapping you reference includes half-axis mappings. Since half-axis mappings weren't supported before, they were simply being ignored. What's interesting is that the D-Pad buttons were being picked up as arrow keys before i.e. a side effect of the controller not working as a controller.

If you use the Joypads Demo, what results do you get with 3.2.2 vs 3.2.3-rc3?

salvob41 commented 4 years ago

thanks for the reply, @madmiraal

I put here two GIFs, on the left the scene from Godot, and on the right the mapping on SDL2.
this is the try with Godot v3.2.2

joypad3 2 2

This is with Godot3.2.3-RC3

joypad3 2 3-RC3

The two are compleetely different. What should I do ? Is the mapping not working ?

salvob41 commented 4 years ago

I double checked the SDL2 mapping in gamecontrollerdb.txt file and the one from the SDL2Gamepad-tool and matches. So I don't know if it's something within Godot that doesn't make it work :/

madmiraal commented 4 years ago

I'm confused. The mappings for controllers with half axes '+' or '-' or inverted axes '~' mapping entries were unsupported and discarded in 3.2.2 including 030000008f0e00000300000009010000:

// WARNING - DISCARDED UNSUPPORTED MAPPING TYPE FROM DATABASE ...gamecontrollerdb.txt: Mac OS X 030000008f0e00000300000009010000,2In1 USB Joystick,+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Mac OS X,

Are you using your own custom mapping in 3.2.2?

With regards 3.2.3, looking at the second gif and the mapping itself, the difference between the two gifs is that the mapping is reversing the D-Pad and the left stick. It is mapping D-Pad buttons to the left stick half axes and the left stick half axes to the D-Pad buttons. The first problem this causes is that the rest point for the axis is not exactly zero, so it will result in a button press when released. The SDL Gamepad tool appears to be struggling with the opposite i.e. when the D-Pad button is released it's not resetting the left stick to zero.

That been said, there does appear to be other issues. The left stick movements appear to be picked up as face button presses not D-Pad button presses. To facilitate troubleshooting it would be appreciated if the following table could be completed:

Controller Joypad Demo
Left stick – Left  
Left stick – Right  
Left stick – Up  
Left stick – Down  
D-Pad – Left  
D-Pad – Right  
D-Pad – Up  
D-Pad – Down  
salvob41 commented 4 years ago

@madmiraal

Are you using your own custom mapping in 3.2.2?

Nope, just using the classic build. No custom mapping

That been said, there does appear to be other issues. The left stick movements appear to be picked up as face button presses not D-Pad button presses. To facilitate troubleshooting it would be appreciated if the following table could be completed:

For some reason seems that once connected buttons 13 and 15 are being pressed and hold.

Controller Joypad Demo
Left stick – Left button 0
Left stick – Right button 0
Left stick – Up button 1
Left stick – Down button 1
D-Pad – Left   Nothing
D-Pad – Right  Nothing
D-Pad – Up   Nothing
D-Pad – Down Nothing

I tested also with this website https://gamepad-tester.com/ This is what it looks like when plugged in. image

For completion, with this website I get the following values

Controller gamepad-tester
Left stick – Left Axis 9: 0.71429
Left stick – Right Axis 9: -0.42857
Left stick – Up Axis 9: -1.0000
Left stick – Down Axis 9: 0.14286
D-Pad – Left   Axis 0: -1.0000
D-Pad – Right Axis 0: 1.0000
D-Pad – Up   Axis 1: -1.0000
D-Pad – Down Axis 1: 1.0000
essial commented 4 years ago

I'm also having this issue. ui_up is constantly being triggered with is_action_just_pressed because of this bug. Godot 3.2.3.stable.official on MacOSX Catalina with an XB1X controller. There is nothing wrong with this controller. GameMaker Studio, javascript joypad api, GeforceNOW and all local games work just fine with the controller.

Screen Shot 2020-10-02 at 4 17 44 PM

Pressing only DPad down...

Screen Shot 2020-10-02 at 4 18 12 PM

Pressing nothing at all...

Screen Shot 2020-10-02 at 4 18 33 PM
essial commented 3 years ago

Is there any work being done on this? Not being able to use the DPAD is a pretty annoying issue. I don't mind helping fix this but I'd need a mentor or something as I have not contributed to this project before.

Calinou commented 3 years ago

cc @madmiraal

@essial Can you reproduce this bug in 3.2.2 or earlier?

essial commented 3 years ago

3.2.2-stable: Broken 3.2.1-stable: Broken 3.2.0-stable: Broken 3.1.2-stable: Broken 3.1.1-stable: Broken 3.1.0-stable: Broken

I couldn't run the joypad test program in 3.0.6 or earlier.

essial commented 3 years ago

When I run the SDL2 gamepad tool, it works just fine. "Xbox Wireless Controller", 030000005e040000fd02000003090000 (mapping available)

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

Adding the following does not fix the issue in the test app: Input.add_joy_mapping("030000005e040000fd02000003090000,Xbox Wireless Controller,a:b0,b:b1,back:b16,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,", true)

salvob41 commented 3 years ago

@essial try compare the output of the demo with gamepad-tool and gamepad-tester.com as @madmiraal suggested.

That might help them identifying the issue.

essial commented 3 years ago

I can say that on the debug tester site, Up Down Left Right is B12 B13 B14 B15.

Controller Joypad Demo
Left stick – Left  Axis 0 -1
Left stick – Right  Axis 0 +1
Left stick – Up  Asix 1 - 1
Left stick – Down  Axis 1 + 1
D-Pad – Left  B14 AND B12
D-Pad – Right  B13 AND B15
D-Pad – Up  B12 AND B15
D-Pad – Down  B13 AND B14

Note that B12 is always pressed if there is nothing being touched on the controller. Also vibration doesn't seem to work (it does on other games).

bram-dingelstad commented 3 years ago

Having the same issue on OSX Catalina as explained by @essial. Done a lot of research around the net, seems to be related to an Apple patch that changed the way that USB works.

Besides the issues outlined here, I can't use the Left and Right trigger and they don't register for Godot. Pressing the button in the latest GamepadTool does register. I've tried everything even manually remapping SDL Gamepad entries, nothing works.

Let me know if I can be of any help or if this issue needs to be tested. I have the issue in 3.2.1, 3.2.2 and the new 3.2.3 release.

akien-mga commented 3 years ago

CC @bruvzg

bruvzg commented 3 years ago

Apple has changed APIs for the drivers, and "360Controller" XBox controller driver was not updated for the long time, is crashing the system right now.

macOS Catalina 10.15.7 (19H2), without any custom drivers - wired XBox One controller seems to be completely dead, it's listed in the USB devices as "Controller", "X" button on the controller is blinking, and it's not detected by any software including Godot and GamepadTool. AFAIK old wireless XBox controllers with the USB dongle never worked on macOS. Bluetooth controllers should work.

essial commented 3 years ago

I'm using a bluetooth connected xbox one controller (no dongle). It's unusable given the DPAD constantly reports a button press with nothing pressed. Works on all non-godot games/apps.

madmiraal commented 3 years ago

I've created a PR (master: #42799 and 3.2: #42800) to provide support for D-pads and buttons mapped to half axes, which should fix @salvob41's original issue. However, it needs testing by someone with a 2In1 USB Joystick controller or another controller that maps buttons or D-pads to half axes.

The issue described by @essial appears to be something else, because it's not about mapping buttons to axes and it isn't working in earlier versions either; so I suggest opening a separate issue to capture that.

salvob41 commented 3 years ago

Thank you @madmiraal. I tested with a custom build for the 3.2.4-custombuild and doesn't work unfortunately :(

bram-dingelstad commented 3 years ago

@bruvzg I have been able to make it work on Catalina with the 360Controller drivers, they don't seem to crash my setup. Using the Xbox One S controllers with usb cables (making them wired) seems to work if I enable the "fake 360 controller" option.

Might be a specific problem with the mapping of the Xbox One S controllers perhaps?