godotengine / godot

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

Nintendo Switch Pro Controller doesn't work #81191

Open miv391 opened 1 year ago

miv391 commented 1 year ago

Godot version

v4.2.dev3.official [013e8e3af]

System information

Godot v4.2.dev3 - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1060 6GB (NVIDIA; 31.0.15.3640) - Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz (4 Threads)

Issue description

Nintendo Switch Pro Controller doesn't work

Problems:

https://github.com/godotengine/godot/assets/49998025/79d991ce-b74b-4951-8d68-8042105190ce

Nintendo Switch Pro Controller doesn't work with Godot v3.5.2.stable.official [170ba337a] either.

Steps to reproduce

Connect Nintendo Switch Pro Controller and run the attached project.

Minimal reproduction project

g42_joypad.zip

AThousandShips commented 1 year ago

Related?

miv391 commented 1 year ago

Related?

Could be very likely related. Input seems to be similarly chaotic.

My first though was that maybe Nintendo Switch Pro Controller just isn't supported by Windows (as some Bluetooth controlles are not), but as the controller works with other applications (Steam and web browsers), I guess this has something to do with Godot.

I tested controller initially wired, but it doesn't work wireless (with Bluetooth) either. I just just works differently. If wireless, controlled is detected, but no input is detected at all, compared to the chaotic input when wired. Also my PS4 controller works fine with Bluetooth.

mieldepoche commented 1 year ago

your mrp works okay on my end (ubuntu, wired switch pro controller). Pluging the controller only after starting the app works too. I do remember having problems with the pro controller on windows with bluetooth though, in other games. Though no chaotic input, so maybe unrelated.

miv391 commented 1 year ago

I'm starting to think that this a Windows issue with non-Microsoft wireless controllers. I have tested Nintendo Switch Pro Controller with both Windows 10 and 11. Yesterday on Windows 11 Nintendo Switch Pro Controller worked initially just fine. Then I started Steam and the controlled stopped working altogether. Rebooting Windows didn't help. Today the controller works fine both on Win 10 and 11. But I have also seen a situation where buttons worked but axises didn't.

So if this is not reproducible, I'll say this is a Windows issue or maybe controller's battery level was low or something.

inhalt120g commented 1 year ago

Godot on Mac OS also can't recognize Nintendo Switch controller (using the project from the first post for testing, but also if I try to remap any inputs in the IDE and the "Listening" appears, nothing is registered no matter what I press). Here is a video showing the same controller immediately after switching to the site from the first post, where it can be see that the controller is both properly recognized (in the first few seconds of the video, sorry about not managing to catch a few more seconds of that but you can still see it I hope) and that the commands are registered on screen:

https://github.com/godotengine/godot/assets/106015575/921c0f6a-0445-40a9-83da-def29efbe995

Edit: forgot to mention, Godot V4.1 and controller connected via Bluetooth (but same thing when it's connected via cable too).

mrhebisan commented 1 year ago

I experience the same issue on MacOS M1 as described here, down to the weird interactions with Steam.

For slightly more information, I observe the following in comparison to other engines.

Wired controllers: Godot - Chaotic values while steam is running / no values when steam isn't running Unreal - No values Unity - New Input System perfect input / old input system Chaotic values

Wireless controllers: Godot - Same as wired Unreal - Perfect input Unity - New input system perfect input / old input system no values at all

Perhaps the Unity and Unreal have special drivers for MacOS and Pro Controllers, in the listed configurations? If so, they too are in finicky situations.

Wolve-3DTech commented 1 year ago

As an ex-Unity user, when i plugged my pro controller, unity printed a message in the console. The same thing occured when i unpluged it.

jmrain commented 11 months ago

Same issue here, figured it can't hurt to add my test results. M1 Pro MacBook Pro with Godot 4.1.2

Switch Pro Controller wired: (videos below show this connection method)

Switch Pro Controller Bluetooth:

https://github.com/godotengine/godot/assets/140655316/656e8474-778d-40af-b915-1dacfd33fd8d https://github.com/godotengine/godot/assets/140655316/f8c13700-249d-4dc7-ba8f-88a5600e6f64

miv391 commented 11 months ago

This is the best information what I found about the Nintendo Switch Pro Controller and Windows: https://www.pcgamingwiki.com/wiki/Controller:Nintendo_Switch_Pro_Controller

The controller is connected through DirectInput (old Microsoft API) instead of XInput (new Microsoft API), but it still doesn't work as a DirectInput controller. It can be get to work, but it needs quite lot a work. SDL has about 2300 lines of code for that: https://github.com/libsdl-org/SDL/blob/main/src/joystick/hidapi/SDL_hidapi_switch.c. Steam and web browsers probably have their own implementation for this.

I guess Godot will not get a Switch Pro Controller support unless Godot starts using SDL for game controllers.

(Disclaimer: I haven't actually tested that Pro Controller works with SDL.)

Meorge commented 11 months ago

On the topic of the chaotic/random values people have noticed when plugging in the Pro Controller: I experienced this same issue with Unity's new Input System a few years back, and eventually figured it out.

https://forum.unity.com/threads/using-nintendo-switch-pro-controller.617857/#post-7714327

This repository was invaluable, and specifically this section for the input format. One of the values the controller in its report is a "timer" value which increments each time, and causes that chaotic input.

Using this information, I attempted to implement better support for the Pro Controller in Unity's Input System. Last I remember, there were some strange issues I ran into with it, and those (along with other life stuff) caused me to drop the project. These days I'm more interested in Godot, and as a result want to take a stab at seeing if I could implement these things in Godot (unless there are others who would be better suited to do it, or think there is a reason to not do it). I'd personally love to have support for things like HD Rumble and gyro controls 😉

DaJinx commented 2 months ago

Im new to reporting on Git, but im also having this issue. Character is legit constantly jumping into the sky and going crazy. And firstly, none of the other controllers can even continue jumping like that in the air so no idea how the character is even doing that. Shouldnt be allowed to jump again until ive landed.

The pro controller is actually fine when paired through bluetooth. Its only when plugged in it goes berserk. Thirdparty switch controllers are also fine plugged in. Not even sure how to test the joycons plugged in.

I tried the hardware tester that jmrain said worked fine for them but for me even that in browser is spazzing out. Right stick not working, left stick only working left to right (but up and down controls them), and the entire face buttons, triggers and bumpers are just having a rave by flashing around like crazy. Which sounds accurate to the results in Godot.

It seems like all our values are different, cause mine worked fine wireless in godot, but mrhebisan says not for them. And mine is all opposite to jmrain for all but 1.

Meorge commented 2 months ago

That definitely sounds to me like the same issue that the Unity New Input system was experiencing due to the incorrect mapping (namely, the lack of the timer variable). What operating system are you using? I think figuring out a fix for that will be dependent on the OS, since the macOS implementation of controller support uses the Game Controller framework, which recognizes the controller correctly.

DaJinx commented 2 months ago

I'm using Windows 10.

Also just wanted to experiment, and a different cable in a different type of usb slot didn't change a thing so i don't think its the type of cable itself. ( USB 2.0 type c to c ) and ( USB SS10 type a to c )

fkeyzuwu commented 1 month ago

For me it did work on web browser Godot games, and on steam games, but not in Godot desktop. I managed to get a temporary fix my use case by adding my Godot editor executable as a non-steam game, seems to fix it. I would assume running the Godot official steam version would also work in the same way. I wonder what steam does that makes it work. Maybe worth investigating.

Steam also uses the Enable Steam input for Switch Pro Controllers option.