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

D-pad gets stuck on Retrolink SNES controller #44100

Closed
cheshirecat416 opened this issue Dec 4, 2020 · 4 comments
Closed

D-pad gets stuck on Retrolink SNES controller #44100

cheshirecat416 opened this issue Dec 4, 2020 · 4 comments

Comments

@cheshirecat416
Copy link

cheshirecat416 commented Dec 4, 2020

Godot version:
3.2.3 official

OS/device including version:
Windows 10 home

Issue description:
I am attempting to demonstrate controller support on my project. I have a new Retrolink SNES controller. This controller works properly when I run the SDL2 Gamepad Tool. I can generate a mapping for it.

03000000790000001100000000000000,Retrolink SNES Controller,platform:Windows,a:b2,b:b1,x:b3,y:b0,back:b8,start:b9,leftshoulder:b4,rightshoulder:b5,dpup:-a4,dpdown:+a4,dpleft:-a3,dpright:+a3,

When I attempt to use this controller in Godot, all buttons work properly with the exception of the D-pad. When I press a D-pad button it registers being pressed but never registers being raised. I see this issue not only in my own project, but also in the standard Godot "Joypads Demo" project. It may be a unique issue to this controller, but the controller works fine in the SDL2 Gamepad tool, as well as with ZSNES.

This image shows all of the D-pad arrows stuck in the depressed position on the Joypads Demo.
controller_issue

This is the controller:
https://www.amazon.com/gp/product/B01MYUDDCV/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1

Steps to reproduce:
I am not sure how someone can reproduce the error without the controller, but any help would be appreciated.

Minimal reproduction project:
See above.

@davthedev
Copy link
Contributor

I can confirm this bug was introduced in 3.2.3 too.

In 3.2.2:
This gamepad model returns "USB Controller" as name.
D-pad presses are seen as left stick axis direction changes.

In 3.2.3:
Gamepad model is "Retrolink USB controller"
D-pad presses are seen as D-pad presses which are never released.
Some button mappings are also changed in comparison with 3.2.2.

It may be caused by the SDL2 Gamepad module on top of which Godot is built.
This modules uses a translation table to map generic gamepad buttons to a standardized gamepad layout, in a quite similar fashion as XInput.
Gamepads are matched using a combination of variables, including the operating system. This is why the same gamepad may behave differently in the same Godot game on Windows and Linux, for example.

For instance the table says "Button 3 on that brand of controller on operating system X = A button / button 0 (not sure) on the standardized layout".

The translation table is updated from time to time, and Godot 3.2.3 may have used an updated version.
Here is the project that contains the mapping table: https://github.com/gabomdq/SDL_GameControllerDB

The good news is that, as a workaround, it is possible to override those mappings at runtime.

  1. Use SDL Gamepad Tool to generate a mapping string: https://generalarcade.com/gamepadtool/ . Repeat this step on each different operating system you plan to release your game on.
  2. In your project, call Input.add_joy_mapping() to take the updated mapping into account. You probably need to call it multiple times to feed the fixed mapping for each operating system. A good place is an autoload's ready() call.

My approach for this gamepad model:
`

var mappings = [
    "03000000790000001100000010010000,Retrolink SNES Controller,a:b2,b:b1,x:b3,y:b0,back:b8,start:b9,leftshoulder:b4,rightshoulder:b5,leftx:a0,lefty:a1,platform:Linux,",
    "03000000790000001100000000000000,Retrolink SNES Controller,platform:Windows,a:b2,b:b1,x:b3,y:b0,back:b8,start:b9,leftshoulder:b4,rightshoulder:b5,leftx:a0,lefty:a4,",
]
for mapping in mappings:
    Input.add_joy_mapping(mapping, true)

`

@akien-mga
Copy link
Member

Can you test 3.2.4 beta 3?

@madmiraal
Copy link
Contributor

Duplicate of #43603, fixed with #42799, and backported to 3.2 (#42800) and included in 3.2.4.beta2.

@cheshirecat416
Copy link
Author

I can confirm it worked in 3.2.4 beta 3. Thanks!

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

5 participants