Want to use a controller in your games?
First of all this script is for a single controller on the GD5 version only!
I use a Xbox controller.
I have created an external event that you must add to your scene so that you can use the controller.
Download the project below it contains the example “Platformer” with the support of the controller.
You can move the player with the left joystick and jump with RT.
The other buttons are not configured but you can already see how the events work!
The signal passes through scene variables that are created in the script directly.
(Tips : When you call a variable that does not exist GD will create this variable automatically)
This variable is then used in events, see “Axes” and “Buttons” groups.
This is now included with extension inside GDevelop 5, for know how find extension follow this link :
Thanks a lot, I was also trying to get this working
I have changed your example a little and mapped my PS4 controller and added two more buttons so we can also use the PS button and the Touch button on the PS4 controller
I did some testing with my Xbox controller and adding two buttons made it all buggy.
So I added conditions to know if the last two buttons exist.
And makes the debug texts more meaningful.
I corrected my nickname too:’)
For the addition of an extension I wouldn’t know how to do it alone like that, I prefer to do crafts with GD for the moment.
I’m looking at how the code works in the game engine but I’m not sure I’m contributing to it yet really great. GDevelop5_controller-input.zip (372 KB)
Sorry, it was not intentional, even now that you mentioned I saw a t there for a moment
Thanks, I didn’t thought of that. Wish we could use arrays in GD then we could just loop through all the buttons exists and store them in an array and people could use it with any controller with any number of buttons
When I run this example, I run into the following problem. When I hit a button on the controller, the correct action happens (jumping, moving, etc.), but it keeps doing that action and does not stop. For example, it repeatedly jumps or continues moving after I’ve let go of the button. From what I can gather, the variable is not being changed back to “false” when the button is released. The debugger text confirms this.
Also: after a first button press, no other buttons will work.
If it helps anybody, I found a solution that worked for me:
Put the requestAnimationFrame line outside of the gameLoop function (right after the closing } bracket). Somehow this allowed the function to repeat on each frame as desired. I also took out all of the code that did not pertain to buttons relevant to the specific controller I was coding for.
Sorry for up this topic, but I am having some trouble.
This extension only works with PS and Xbox joysticks? Because I can’t use with my generic controllers, and even with x360ce I cant emule to make work.
The extension is available in the extension list directly in GDevelop.
It supports 100% PS4 and Xbox360 and Xbox one controllers.
I cannot take into account all types of controllers. There are thousands of mapping for hundreds of different controllers.
You can connect your controller to this site (https://html5gamepad.com/) you can have the number that corresponds to the buttons and remap by modifying the extension.
Thanks! Maybe I am making some mistake, because my generic Joystick uses the same buttons than a PS (I am using a Twin USB Joystick). Just to be clear, the extension works even in testing inside GDevelop or need to ‘build/compile’ the project and play in a browser to make joystick work? Sorry I am noob at GDev and game development.
How could I remap extension?
I checked, my Twin USB Joystick axis are working in Gdev, but not the buttons…
I tried the website you write, when I press ‘cross’ he changes the value of B2 from 0 to 1.0, and in drivers ‘cross’ are showed as button 3, how can I make this work?
How do we remap the extension?
I have an old school NES USB controller and when I press the DPad left and right I see it moves axis #4 and #5. But I don’t know where to plonk those into the extension. Cheers
You can’t really without change ids related to buttons in the code of the extension.
I work on the extension for add more events.
And the next version of the extension require the next release of GD for working.
I just use the extension for first time with Xbox pad for windows and its working flawlessly . Great extension i will use it for every project from now on . Thank you man for making it . I appreciated this a lot. Excuse my English.