How to support as many joysticks as possible?

Hello! I’m currently developing a fighting game using MonoGame as the base for my engine.

My question is simple: how can I support as many different types of joysticks as possible? Arcade sticks in particular have numerous amounts of boards you can use to create your stick, including the PS360+, which I use.

However, I notice I have to plug it in as 360 mode to get it to recognize. I also have an 8bitdo that I also have to plug in as XInput mode in order for it to recognize.

Is there some other library or class I should/can be using in order to have support for more devices, including Bluetooth controllers such as 8bitdo and PS4? I intend to support Windows 10, Linux, and macOS.

Hey @Jesuszilla, welcome to the forum! :slight_smile:

DirectX projects only support XInput gamepads. If you switch to DesktopGL (cross-platform desktop project) you’ll be able to support a lot more. Seeing as you want to target Linux and Mac you’ll need to use DesktopGL either way. The mappings used by MonoGame are available here. They’re a bit outdated, so I just set up a pull request to update the mapping to the latest. You can browse through to see what’s supported. The latest mappings support PS360+ and 8bitdo, so MG will too after my pull request is merged. I’ll post back here so you know when you can grab a develop version with the new mappings! :slight_smile:

1 Like

Thanks @Jjagg! I wonder why I have to be in XInput mode even on Linux for it to recognize my joysticks, then. But I am using MonoGame 3.6 if that makes any difference. Should I switch to 3.7 that’s in development? Will this also support Bluetooth controllers, or is it all USB? Loss of Bluetooth support isn’t a big deal if that is the case but I am still curious.

Thanks once again, and do let me know when your pull request is accepted!

It’s been a long time since the 3.6 release, maybe your devices weren’t in the mapping yet. If you want to check, here’s the mapping file from 3.6: https://github.com/MonoGame/MonoGame/blob/v3.6/MonoGame.Framework/SDL/gamecontrollerdb.txt

So yeah, switching to 3.7 will get you a lot of bugfixes and support for more joysticks.

I’m not sure actually.

Hey @Jjagg, just noticed the pull request was merged! However my PS360+ 1.66 still doesn’t work. I made sure to replace the SDL-related DLL’s in my project, and no dice.

@Jesuszilla Did you get a develop build from the downloads page? It might not have been updated yet when you did.

You can also check if the SDL2 Gamepad Tool recognizes your controller: http://www.generalarcade.com/gamepadtool/
If it does, MonoGame should support it too (considering we use the same mapping with my PR merged).

I just redownloaded to be safe, the SDL DLL’s are from 5/15/2018 and they still don’t recognize my stick, it seems. The Gamepad tool does, however.

I even tested just to make sure the gamepad wasn’t on some weird index with the following snippet and the break statement was never reached:

var g = GamePad.MaximumGamePadCount; for (int x=0; x < g; x++) { if (GamePad.GetState(x).IsConnected) break; }

Can you check your MonoGame build version?

3.7.1521 IIRC. I’m not at home so I can’t double-check, but I believe that was it.

That should definitely have the changes. If you can confirm the version, I’m not sure what else might be the issue. Maybe @harry-cpp can think of something.

Are you sure the gamepad tool recognized your gamepad as gamepad, and not just as a joystick, that is did it correctly map out your controller?

Also can you try using MonoGames Joystick API (not GamePad API, Joystick API) to check if your device is getting recognized at all?

Pretty sure it’s being recognized as a Gamepad, since all the buttons were mapped to what they should have been.

Joystick API appears to recognize it just fine, though I’d have to do a lot of refactoring in order to get it to work with that. Suggestions?

I asked for that so I would know if the device is being recognized at all, now the issue is pinned down to the mapping. Give me the information from Joystick.GetCapabilities().Identifier.

For the PS360+1.66 it’s “00820010-0000-0000-0000-504944564944”

Found the problem, SDL database has an entry for your controller type, but not for that id (same controller can sometimes have multiple ids… I have no idea why tbh…): https://github.com/gabomdq/SDL_GameControllerDB/blob/4c86539a1b1420d072c4d370f6ef47797db7f3db/gamecontrollerdb.txt#L94

That is strange, considering when I plug it in to the gamepad utility, it shows as 03000000100000008200000000000000, just as we’d expect. Maybe MonoGame isn’t retrieving the correct identifier, or is interpreting it differently?