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

Add support for using more than 4 simultaneous controllers on Windows #8620

Open
zolrath opened this issue Dec 8, 2023 · 4 comments
Open

Comments

@zolrath
Copy link

zolrath commented Dec 8, 2023

Describe the project you are working on

An up to 8 player, single screen, local multiplayer versus game.

Describe the problem or limitation you are having in your project

With an Xbox Wireless Adapter it's quite easy to connect 8 Xbox controllers to my computer and have them recognized by Windows. Unfortunately, the XInput API has a maximum of 4 controllers at one time so any controller beyond the 4th is not recognized by Godot's Input system.

I've created an Issue/Reproducible Project here: godotengine/godot#85937

Edit: Found a previous Issue before the proposal system was implemented that requested the same feature: godotengine/godot#19173

Describe the feature / enhancement and how it helps to overcome the problem or limitation

If more than 4 controllers are connected fall back to alternative input APIs to allow them to be recognized seamlessly.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

DirectInput supports more controllers and is used by various engines/games as the fallback input method.
On Windows the Windows.Gaming.Input is a new API allows for more than 4 controllers.

If there are any limitations with the fallback, create a project setting that must be enabled to enable this system.

If this enhancement will not be used often, can it be worked around with a few lines of script?

No, the additional controllers don't register in any way with the Input system. at the moment.

Is there a reason why this should be core and not an add-on in the asset library?

The Input system is a core part of Godot.

@Calinou
Copy link
Member

Calinou commented Dec 9, 2023

DirectInput is a legacy API, so it may not be the best way to go forward. The GameInput API is promising, but it requires a recent Windows 10 build or Windows 11. This is probably not an issue as long as we have a fallback on older Windows versions (as Godot still aims to support Windows 7+ on a best-effort basis for now).

The larger issue I see with GameInput is that it's part of the GDK, which we'd need to link the entirety of to be able to use it in Godot. It may not be buildable with MinGW either, which we use for official Godot Windows binaries.

@Calinou Calinou changed the title Support more than 4 simultaneous xbox/xinput controllers Add support for using more than 4 simultaneous controllers on Windows Dec 9, 2023
@zolrath
Copy link
Author

zolrath commented Dec 9, 2023

GameInput is definitely the more modern way to move forward, but what is the current handling of non-XInput controllers?

I can use my Switch Pro controllers that I've paired via bluetooth and I can use them in addition to my 4 xbox controllers to bypass the 4 XInput controller limit. This works fine for testing but not as a requirement for players.

This would lead me to believe we've already got DirectInput handling built in, just no way to apply it to XInput controllers, is that the case?

@lemonJumps
Copy link

The problem for the longest time were different APIs. DirectInput is old, Xinput supports only 4 controllers, GameInput is only windows 11, some are manufacturer APIs proprietary and only work on windows...

Ultimately there is a way, as far as i know most if not all controllers are HID devices.
HID is a usb specification, and I think it's also now supported via Bluetooth LE.
And it can be accessed from windows as well as linux.

This is also the only way to support stuff like flightsticks, that have like 11 axis, and 50 buttons + force feedback.
There's info here: https://www.usb.org/hid
As well as this: windows hid api and concepts and Adafruit guide on HID reports

The actual advantage of hid is that it works with everything, and everywhere, If the device is a hid device by default it doesn't (or shouldn't) need a driver to work.
The disadvantage is that because it works with everything, and its API is basically just exchanging structured data between devices, it can be hard to wrap your head around.

As for how godot would deal with hid, essentially the device descriptor tells the user what data it sends so that isn't hard, the only "hard part" is keeping up with the specification.
It's technically hard because there's a lot of data but the specification doesn't change that often, especially for things like gamepads, and in case users would want to support a new/obscure device, they can use raw hexcodes instead of relying on defines.

@schemesmith
Copy link

schemesmith commented Dec 11, 2024

DirectInput is old but new games are still coming out that use it to enable 8 controllers on windows. This is a critical feature for many local multiplayer games and Godot would benefit greatly from having some way (no matter how hacky) to use 8 controllers.

GameInput is definitely the more modern way to move forward, but what is the current handling of non-XInput controllers?

I can use my Switch Pro controllers that I've paired via bluetooth and I can use them in addition to my 4 xbox controllers to bypass the 4 XInput controller limit. This works fine for testing but not as a requirement for players.

This would lead me to believe we've already got DirectInput handling built in, just no way to apply it to XInput controllers, is that the case?

I'm also curious how Switch Pro controller can be used to exceed the 4 controller limit. Thank you!

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