godotengine / godot

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

Dance pad buttons detected as Joypad D-pad prevent left+right and up+down #99513

Open runningopenloop opened 14 hours ago

runningopenloop commented 14 hours ago

Tested versions

Reproducible in: v4.3.stable.official.77dcf97d8 v4.2.2.stable.official.15073afe3

System information

MXLinux 23.3; 6.1.0-11-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.38-4 (2023-08-08) x86_64 GNU/Linux

Issue description

I'm using a Mayflash GameCube controller to a Wii dance pad. Image

I mapped my inputs as seen here. Using the keyboard input, I have no problem generating left + right at same time and up + down at same time. Image

However, when using the dance pad:

    var pressed = ""
    if Input.is_action_pressed("Up"): pressed += "u"
    if Input.is_action_pressed("Down"): pressed += "d"
    if Input.is_action_pressed("Left"): pressed += "l"
    if Input.is_action_pressed("Right"): pressed += "r"
    print ("Pressed: " + pressed)

Shows that up + down and left + right will not work. up + down ==> down. left + right ==> right.

I think this is because GODOT think's it's a dpad and doesn't allow these combinations. --> SDL and OS level otherwise show things working.

But jstest-gtk [is this using SDL?] and sdl-jstest show all buttons working together: https://github.com/Grumbel/sdl-jstest

Image

Steps to reproduce

Use any(?) dance pad. I imagine any d-pad controller would not be physically able to reproduce this. (I did try re-mapping buttons as a work around, but failed --> perhaps you can re-map buttons the other way to succeed in reproducing if you don't have a dance pad?). Otherwise I used: https://www.amazon.com/gp/product/B00RSXRLUE Konami Wii dance pad. RU054 Image

As a side note, I could get all "directions" pressed using my keyboard arrow keys either, only two. Using wasd allowed me to get all depressed.

Of course dance pad should allow all buttons to be depressed at same time.

Minimal reproduction project (MRP)

This simple application will allow you to see the uplf (up, down, left, right) print in console. dance_pad_test.zip

There's also: Joypads (Gamepads) Demo: https://godotengine.org/asset-library/asset/2785

runningopenloop commented 8 hours ago

So I expect this is the code to blame... So for those in the know, what should the solution be for dance pads which register the arrows in the DPAD? Note, I imagine given the order here, it explains why when all buttons are down we get, down and right.

Note those buttons map from dp* highlighted below, button 11 to 14: Image

In godot/core/input/gamecontrollerdb.txt: 03000000790000004418000000010000,Mayflash GameCube Controller,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Mac OS X,

Since this is a general purpose device, a gamecube controller could be connected which arguably would then act as a DPAD?

runningopenloop commented 7 hours ago

So I'm curious what the experts have to say as far as how to deal with this in Godot engine or otherwise.

As for my workaround attempts: So trying to remap.... failed. Not sure why... don't know if anyone may provide some insight.

Made limited progress with gamepadtool --> The only tool which seemed to show the remapping having an effect. https://generalarcade.com/gamepadtool/

This will also help build remapping string. I used this tool and only this tool acknowledged the remap. Neither godot or sdl-jstest showed the button coming in at not 11, 12, 13, 14. I tried remapping to buttons A/B/X/Y.

Although after exporting a remap string generated by gamepadtool, I did get the remap string to be seen as associated with the joystick, but when testing button 0/1/2/3 never fired. Always 11/12/13/14.

$ ./sdl2-jstest  -l
error: failed to read gamecontrollerdb.txt: Invalid RWops
Found 4 joystick(s)

Joystick Name:     'limited MAYFLASH GameCube Controller Adapter'
Joystick GUID:     0300a011790000004418000010010000
Joystick Number:    0
Number of Axes:     6
Number of Buttons: 16
Number of Hats:     1
Number of Balls:    0
GameControllerConfig:
  Name:    'Mayflash GameCube Controller'
  Mapping: '0300a011790000004418000010010000,Mayflash GameCube Controller,a:h0.4,b:h0.2,x:h0.8,y:h0.1,back:b7,start:b9,leftshoulder:b2,rightshoulder:b1,platform:Linux,crc:11a0,'

I ultimately tried several remapping strings, but didn't seem to work. Even using Input's void add_joy_mapping(mapping: String, update_existing: bool = false)

I expected my code to no longer spit out u/d/l/r for existing mapping, but it still did.

The other strange thing is that sometimes it seems my GUID was identified as: 0300a011790000004418000010010000 --> sdl-jstest and gamepadtool id as this. And other times (which I originally reported): 03000000790000004418000000010000

Examples of other settings I tried...

export SDL_GAMECONTROLLERCONFIG="0300a011790000004418000010010000,Mayflash GameCube Controller,a:h0.4,b:h0.2,x:h0.8,y:h0.1,back:b12,guide:h0.0,start:b9,platform:Linux," export SDL_GAMECONTROLLERCONFIG="03000000790000004418000000010000,Mayflash GameCube Controller,a:h0.4,b:h0.2,x:h0.8,y:h0.1,back:b12,guide:h0.0,start:b9,platform:Linux,"

$ export SDL_GAMECONTROLLERCONFIG="03000000790000004418000000010000,Mayflash GameCube Controller,a:b14,b:b15,dpdown:b1,dpleft:b2,dpright:b0,dpup:b3,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b13,y:b12,platform:Linux,"

And with the add_joy_mapping:

"""
var mapping_string = '0300a011790000004418000010010000,Mayflash GameCube Controller,a:b15,b:b14,dpdown:b1,dpleft:b2,dpright:b0,dpup:b3,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b13,y:b12,platform:Linux,'
Input.add_joy_mapping(mapping_string, true)

mapping_string = '03000000790000004418000010010000,Mayflash GameCube Controller,a:b15,b:b14,dpdown:b1,dpleft:b2,dpright:b0,dpup:b3,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b13,y:b12,platform:Linux,'
Input.add_joy_mapping(mapping_string, true)
"""

"""
var mapping_string = '0300a011790000004418000010010000,Mayflash GameCube Controller DancePad,a:h0.4,b:h0.2,x:h0.8,y:h0.1,back:b7,start:b9,leftshoulder:b2,rightshoulder:b1,platform:Linux,'
Input.add_joy_mapping(mapping_string, true)

mapping_string = '0300a000790000004418000010010000,Mayflash GameCube Controller DancePad,a:h0.4,b:h0.2,x:h0.8,y:h0.1,back:b7,start:b9,leftshoulder:b2,rightshoulder:b1,platform:Linux,'
Input.add_joy_mapping(mapping_string, true)
"""

I guess my next attempt may be to try and remap a traditional game controller to see if I can get that to work.