List of possibilities from "GamePad.GetCapabilities(0).DisplayName" ?

I’d like to detect what controller is being used and show buttons accordingly. Been searching the repo for possible names but without luck.

I have a PS5 controller myself and when it’s used the string says “PS5 Controller”.
I’d like to know what the string says if any of these are used:

  1. Xbox 360 Controller
  2. Xbox One Controller
  3. Xbox Series X Controller
  4. PlayStation 4 Controller
  5. Nintendo Switch Pro Controller
  6. Nintendo Joy Con

The values that populate that variable come from SDL_GameControllerDB’s gamecontrollerdb.txt (used by MonoGame DesktopGL build).

You’d need to check the specific version of SDL_GameControllerDB that is in your version of MG to get the exact copy of gamecontrollerdb.txt being used.

Also, just my 2 cents, instead of matching on exact strings I would recommend using a bit more robust of an approach and checking for things like does the name contain both “xbox” and “one” when trying to match against an Xbox One controller (parse the DisplayName as lowercase first). That way your code will recognize non-official controllers as well like “Afterglow Xbox Controller for Xbox One” or whatever else. Not to mention if the end-user is using stuff like Steam Input or other controller UUID spoofing stuff it would still be recognized.

1 Like

Hi @MonoGame_Apprentice, Welcome to the Community!

Could you provide the code you use to get the display name of the controller, and I can confirm what is displayed for the XBOX ONE gamepad.

Happy Coding!

1 Like

That’s a rather extensive list, but it was exactly what I was looking for! Thanks for linking to it.
I think you are exactly right, instead of exactly matching, the best approach would be to DisplayName.LowerCase() → Contains(“PART OF NAME”).
Probably always default to Xbox buttons since we are on PC, pick another button images if we detect, and maybe even have a manual option desired buttons in options.

Thanks, this is a very welcoming community!
I use this code to get the name:

GamePad.GetCapabilities(0).DisplayName

I can confirm an original PS5 controller connected, both via cable and via Bluetooth, will have the display name of

PS5 Controller

As @TheKelsam mentioned, the complete list of possible names is here: https://github.com/gabomdq/SDL_GameControllerDB/blob/7a1035b928b7ce0c925e21f4ae954748499b2eff/gamecontrollerdb.txt

1 Like

Hey @TheKelsam I noticed you wrote

Is there also a list if you build for Desktop DirectX? (Or is the list different)

Just throwing my code in here but:


            // get the displayname of gamepad 1
            GamePadCapabilities capabilities = GamePad.GetCapabilities(PlayerIndex.One);
            Log("GamePadCapabilities Created" + " _{0}", gameTime.TotalGameTime);

            // store each item from the capabilities object to the log
            Log("GamePadCapabilities: " + capabilities.DisplayName + " _{0}", gameTime.TotalGameTime);
            Log("GamePadCapabilities: " + capabilities.GamePadType + " _{0}", gameTime.TotalGameTime);
            Log("GamePadCapabilities: " + capabilities.HasAButton + " _{0}", gameTime.TotalGameTime);
            Log("GamePadCapabilities: " + capabilities.HasBackButton + " _{0}", gameTime.TotalGameTime);
            Log("GamePadCapabilities: " + capabilities.HasBigButton + " _{0}", gameTime.TotalGameTime);

Which throws out:

GamePadCapabilities Created _00:00:00.0166667
GamePadCapabilities:  _00:00:00.0166667
GamePadCapabilities: GamePad _00:00:00.0166667
GamePadCapabilities: True _00:00:00.0166667
GamePadCapabilities: True _00:00:00.0166667
GamePadCapabilities: False _00:00:00.0166667

With an XBOX ONE gamepad :confused:

With Index 0 it still shows no display name

EDIT

DesktopDX

My understanding is DesktopGL used SDL and DDX uses XINPUT

1 Like

I am also unable to get my controller to work with DirectX. -Even when I use ‘DS4Windows’ which converts the input to XInput, I cannot get any readings in MonoGame

I posted code in the Community Magazine [Issues 1 and 2]

magazine:magazine [MonoGame Community Wiki]

Code to Try sections

@MonoGame_Apprentice It’s been a while since I’ve used a DX build, but as far as I’m aware it won’t have a DisplayName value or it will always just be something plain like “Xbox Controller” or “XInput”; because the DX build uses XInput which does not have a controller DB and will only recognize x-input-friendly devices. That said, you shouldn’t have an issue using your PS4 controller with it while using DS4Windows. Perhaps try a vanilla project and just poll all indexes for controllers and see what you get.

@MrValentine if you want to try this you need to use a GL build and during initialization fire the GamePad.InitDatabase function.

2 Likes

Oh, I figured it would work for DGL, but I want to see how to get it working for DGX.

Well, if it helps, here’s a bit more data:

Top left is actually a dongle that allows connecting up to 4 XBOX 360 controllers to PC. The full string should read:

“Controller (Xbox 360 Wireless Receiver for Windows)”

The one on the right is the same series X you have
The bottom left is one of my original PS4 controllers, so I am quite intrigued you have a different string there since mine reads:

“PS4 controller”

Bottom right is the right joycon from my Nintendo Switch so it reads:

“Joy-Con (R)”

I don’t know whether your project is cross-platform, but if it is, I’d really appreciate if you can tell me whether you were able to get information with GamePad.GetCapabilities of any kind on Linux. For me, it’s a null object. True enough, I haven’t tested extensively since I am on a release deadline and pushed this for later, but if you happen to have that information around, please share. :slight_smile:

1 Like