Control Pad for PC -how to configure?

Hi, I’m making a platform game, and I managed to do the correct setup for using the keyboard and DualShock4, but I’m having problems with the “generic” controls (USB Control PAD) used on the PC. They work but with the buttons swapped. I tried to setup the Xbox controllers, but the problem still persists. Is there any way to specify the face buttons on PC control? (Like 1, 2, 3 and 4)?

Check this example GDevelop 5
Plus: here all the examples https://gdevelop-app.com/game-examples-starters

Thanks Ulises, but the example you gave only uses PS4 and XBOX controls, I needed a way to identify and use the face buttons of a generic PC control pad.

Unfortunately, there is likely something either odd with your gamepad or the drivers on your PC.

All buttons in the gamepad extension are actually identical and mapped the same. They just allow for detecting the type of controller and using the controller-specific naming for them.

As an example, on the backend, the square button on the PS4 controller is detected the same as the X button on a 360 controller, and is detected the same as the button 1 on a (standard) generic controller.

So as an example, if you have events set up that detected “Cross” being pressed (Ps4 button), it’ll work with a 360 pad without any new evets if you press A.

If your gamepad or drivers have these buttons placed elsewhere, there’s no way for the system to know that.

You can use here to test your gamepads, but I’ve used a PS4, 360, XSX, and generic gamepad and they’re all mapped to the same button detection. https://gamepad-tester.com

Any gamepad that doesn’t adhere to this standard is unfortunately outside the scope of what anyone can work with. You could always set up remappable controls in your game and let the player set their buttons, though.

Thanks for the help Silver-Streak, I used the Gamepad-test, and also the Windows tester itself (in the control panel/ Devices and Printers), and with different generic USB control pads, the result of the 4 face buttons is the same, it goes from B0 to B4, with B0 in the “triangle” button, B1 in “Circle”, B2 in “X” and B3 in “square”. And from what I’ve seen on the websites I’ve been able to find, it’s the same layout you usually use printed on the buttons on these generic USB controls. (I’m sending a photo of one of the controls I have here so you can see what I’m talking about)

But, in the case of the PS4, the scheme is this: B0 in the “X”, B1 in the “Circle”, B2 in the “square” and B3 in the “triangle”. I don’t have an Xbox controller here to test, but if it works on the same scheme, it’s not a problem. If there were a way to DIRECTLY reference the buttons on the PC’s control pad, as we do on the PS4/XBOX, it would be a lot less complicated.

Anyway, do you have an example of button remapping in Gdevelop? Sorry for my newbie question, I’m still trying to learn.

Just to add some clarity:
The gamepad tester will not map to what you see in windows, as far as button numbers.

Gamepad ← will give you more detail about how buttons are mapped using the Gamepad API.

The Gamepad API (which the GDevelop extension uses) maps these buttons for all known controllers, and most unknown ones, to be in the same positions (not number).

If using the gamepad tester the buttons all map to the same thing when you press them on the different controllers, than they will behave the same in GDevelop. You can look at the Not A Vanie example in the engine. There are only controls set up for an Xbox controller, but they work in the exact same positions for my PS4 controller, as well as for my generic controller (and even my Stadia controller).

If they are NOT behaving the same for you in the extension, something else is impacting it, and I’m not 100% sure we can assist with that since the API isn’t maintained by GDevelop.

That said, you can look at the example’s controls set up as well, as it uses variables instead of directly input buttons, and this is how you would set up custom controls. By using variables, you can set up events to have the player press a button they want, and have it overwrite the variable.

1 Like

Thanks again, I tested it here on another PC, but I’m getting the same results.

Anyway, I found out that I need to use the GlobalVariableString command, to determine how the buttons will behave. What I don’t understand yet, is how I can change which button triggers each variable, in a game’s “settings” menu or something. In the Not-a-Vania example, each GlobalVariableString points to a specific, fixed button.

(In the Not-a-Vania example, it’s set the XBOX buttons. I tested it here and as you said, it works great with the PS4 controller, but when I try to put the generic PC USB controller, the controls don’t even work!)

So how can I allow the player to change the “button” of each GlobalVariableString? Forgive me the novice doubt, as I said I’m really learning.

No worries.

As far as your generic controller, that seems to indicate something wrong with that specific controller. Not sure we can help there. (You made me go dig up my steam gamepad which has been in the box since that thing was released, and even that thing works. :laughing:)

As far as implementation, you’ll need to figure out how you want to display it, but there is an expression in the gamepad extension that basically shows up as “Last Button pressed”. You can prompt the user to define a new button, then just use the “Any button pressed” condition, a trigger once condition, and update the global variables to the Last Button pressed expression.

How you go about prompting the user is way too specific to your game, so not really sure I can give you an example or guidance there.

Edit: Make sure you use the expression builder rather than typing anything. You can learn more about expressions here: Expressions [GDevelop wiki]

Ok, I’m trying something else, I’m trying to detect the gamepad type, but the system doesn’t give me any feedback, do you know how it works?

I apologize for bumping this thread, but I was reading the comments from Silver- Streak here.

My game was originally designed for keyboard and mouse only.
But I recently added full controller support and it can now be played as a twin-stick shooter… However, I only have a dualshock ps4 controller to test it with, which works perfectly.

But you are saying that testing with other controllers is not really necessary, as the buttons are all in the same position?

I need the game to support the most popular controllers used on Steam.

Correct, if you set up a button to use “Triangle” on a Dualshock 4, it will automatically work with the “Y” button on an Xbox 360 controller.

There are exceptions to this (odd generic controllers that don’t follow most standard OS gamepad APIs), but you can basically test over on https://gamepad-tester.com
The below image is me hitting the X button on my dualshock 4, and that same button is shown when I press A on my Xbox Series X controller. Both of them work the same in my game even if I’ve only set it up for the XSX controller.
image

If your events are explicitly looking for a dualshock for controller ("Controller type = “PS4” condition), you will need to change those. But actual button names you will not need to update.

1 Like

Very nice, thanks for confirming