Hey folks,
tried looking for documentation on controller support but couldn’t find it.
Any suggestions tips on how to use it appreciated.
I have simple left right up down arrow key events set,
but don’t know how to integrate the usb controller to the same actions.
ok so the way I ended up doing it, was downloading a program called xpadder and I assigned keyboard buttons to the buttons on the controller. its not ideal. but if you want to get the controller feel for your gdevelop game then this was the best way I found to do it. it costs £5.99 and took 10 minutes to set up with a cheap SNES knock off controller. so it’ll work with pretty much anything you can plug in via USB. hope that helps
Hey thanks for the reply,
but was hoping that there was integrated controller support.
It is not an option for me to expect pc users to install xpadder.
yeah that’s why its not ideal gdevelop 5 is still in beta, and no controller support is there yet. but i’m hoping it’ll get put in the future, at the moment there are more important features that need implementing first I guess.
Ok that gd5 is still in beta. But I find it strange that controller support is not among the first features that is fixed. I think it seems like gd5 is more focused on creating smartphone games (which I personally is not interested in). I would gladly see that gd5 could offer all the things and more that gd4 can, regarding creating native pc games.
You can just use GD4, if you want. There isn’t much of a difference in terms of (ability to make games in gd way) to it, the main thing of GD5 is that you only need 1 project to export to all sources, while on GD4 it has separate ways, having different files. With that being said, you can also include a different javascript library for the controller support for that, thus you will need to script / code it.
To be specific GD5 is more into web, since the compiled ones that it creates are just being packed / run on that platform via web.
Even though they have the same cores, GD5 is aiming to be more user-friendly
Hey folks,
so I have just realised that the reason I was not seeing the joystick events in the menu (in GD4) was because I was working on a HTML5 project. Which leads me to ask, If I am using GD4 do I have to rebuild the entire project for windows as well as HTML5, so that I can add controller support ?
thanks
MobileNoob
EDIT: I just created a new native windows project and copied my scene over. The main glitch was that I had to reimport all my images to the imagebank, and then reassociate them by opening each resource, I was then able to apply joystick controls successfully. Is there a better way ?
I don’t know about the backwards compatability of projects but I can condfirm that controler support is doable in GDev 4 native (just added controller support for Hyperspace Dogfights over the course of the last month).
Some stuff to keep in mind:
Controller IDing like the number of buttons and which stick is considered as which Axis by GDev differ widely depending on controller model and platform. I wasted a lot of time on making fixed controll patterns only to later realize that they’ll be botched for half the user base. Make fully customizable game pad controlls from the get go for better results. In fact game pad controlls can be fully customizable with GDev, but it gets a little icky if you want to be able to assigne all inputs to both axes and buttons.
Making axes customizable can be a real hassle. My solution was to save the axis asigned to a specific action seperately from the axis sign (game_pad_axis_steer_left; game_pad_axis_steer_left_sign) and then have to seperate checks for positive/negative axis. Custom buttons can just be saved as a value, so those are way easier.
X-Box controllers and some off brand models treat their triggers as Axis (U;V i think) and on some models the default isn’t 0. That can totally mess up your custom axis’ since for all others the no-input position is at 0;0. I got around this by not allowing U;V as inputs on any controllers, but that will disable pads/sticks on some other models.
Not all systems will consider the controller as what GDev calls joystick 0, so even with non-customizable controlls you’ll need an event to detect the players controllers number, then use that as a variable for all controller input checks.
Overall proper controller support is a huge hassle, I wouldn’t recommend doing it at all.
This is so helpful thanks.
I bought a joystick and 2 buttons and usb controller from hobby electrical shop and have hooked it up to my game. Going to make a cabinet for it.
EDIT: I’ve worked out how to use your example function properly.
See the image.
All you need to do is change the parameter to UP or DOWN. The rest of my code must have been wrong in dealing with the Ladder. Now it works.
Currently using your example and my arcade joystick can move player left and right and has a button to jump.
I’m trying to add to your example to add an UP and DOWN response for the Vertical axis.
I tried playing around with the code but I’m out of my depth. Could you let me know which scripts I need to change?
Résumé
case 'UP':
switch (direction) {
case 'LEFT':
if (getNormalizedAxisValue(gamepad.axes[1]) < 0) {
eventsFunctionContext.returnValue = -getNormalizedAxisValue(gamepad.axes[1]);
}
break;
case 'RIGHT':
if (getNormalizedAxisValue(gamepad.axes[1]) > 0) {
eventsFunctionContext.returnValue = getNormalizedAxisValue(gamepad.axes[1]);
}
break;
case 'UP':
if (getNormalizedAxisValue(gamepad.axes[1]) < 0) {
eventsFunctionContext.returnValue = -getNormalizedAxisValue(gamepad.axes[2]);
}
break;
case 'DOWN':
if (getNormalizedAxisValue(gamepad.axes[1]) > 0) {
eventsFunctionContext.returnValue = getNormalizedAxisValue(gamepad.axes[2]);
}
break;
default:
break;
}
break;