godotengine / godot

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

Nintendo Switch Pro Controller doesn't work #81191

Open miv391 opened 10 months ago

miv391 commented 10 months 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 10 months ago

Related?

miv391 commented 10 months 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 10 months 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 10 months 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 10 months 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 9 months 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 8 months 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 7 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 7 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 7 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 😉