I have connected 6 controllers (XINPUT) to WIndows, they are recognized fine in System Settings.
However when I call GamePad.GetState(int x).IsConnected I get False for x>3.
2 of them are 8BitDO controllers and I tried reconnecting them as DINPUT to make use of Joystick.GetState.
But the Joystick API doesn’t see them at all if 4 XINPUT controllers are connected.
Is there an internal limit of 4 Controllers in Monogame?
OK. I found this in the Monogame source code (Platform\Input\GamePad.XInput.cs):
private static int PlatformGetMaxNumberOfGamePads()
But why 4? Can I just increase that and recompile MonoGame?
I use GamePad.GetState(index) with indexes ranging from 0-15 on Windows/Mac/Linux without issue (DesktopGL), and 0-7 on Xbox (UWP).
Can be seen in our game, Cymatically Muffed.
My understanding is this is a limitation of XInput although I haven’t tried more myself.
“Applications can use the XInput API to communicate with these controllers when they are plugged into a Windows PC (up to four unique controllers can be plugged in at a time).”
The interfaces each platform use are as follows:
WindowsDX = XInput
DesktopGL = SDL (combines XInput, DirectInput, WGI, etc where permitted for each platform)
UWP = WGI
Personally I use WindowsDX but with the DesktopGL gamepad code directly in my game with a hidden SDL window. Probably not ideal but it allows non XInput controllers (like the PS4 bluetooth controllers) to work with WindowsDX.
OK, thanks everyone, especially @TheKelsam !!!
Indeed, Monogame.OpenGL supports up to 16 controllers, and WIndowsDX only 4!!!
I managed to change my project to OpenGL and now it works!!!
(how? I just used Nuget Manager to remove the dependency to WIndowsDX and add the one for OpenGL. Nothing else. Took 5minutes. The only thing I had to do was converting my mp3s to OGG, as OpenGL does not support loading mp3 on the fly).
Could it be that the OpenGL implementation is gennerally more… fleshed out/advanced etc???
Is it the recommended one? (when targeting windows only)
It’s difficult to say as both implementations have some issues.
It’s probably not the best comparison but on GitHub there are 75 open issues for OpenGL and 27 open issues for DirectX. Also as DesktopGL uses OpenAL there are a number of issues related to that as well (such as panning and XACT implementation). Another issue is that holding the titlebar with DesktopGL will freeze the game which can be particularly bad for networked games (although threading can be used to solve this).
Personally I have found that WindowsDX has better performance as well with the fps being double that of DesktopGL at least for my devices.
It’s really a case of trying both and seeing what works best for your project.