[Released as extension] Controller Support?

Hey everyone :slight_smile: is there a way to make a controller work with gdevelop? xbox or ps4, generic USB controllers?
great engine, really enjoying using it

Admin edit:
If you search how add controller/gamepad support, you can now add an extension to your game. Follow this link for know how..
And this link for see the change log of the extension.

Gdevelop 4.x has controller support. I once posted a button map for the PS3 controller here:
http://compilgames.net/forum/viewtopic.php?f=19&t=7163&p=53687&hilit=ps3#p53687
But it looks like gamepad support hasn’t landed in GD5 Beta yet.

1 Like

Wow ok! so hopefully the future of Gdevelop 5 may bring it back :slight_smile: along with the tile map editor too i hope :slight_smile:

1 Like

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.

thanks

MobileNoob

1 Like

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. :slight_smile: hope that helps

1 Like

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.

MobileNoob

1 Like

yeah that’s why its not ideal :frowning: 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.

1 Like

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.

1 Like

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

1 Like

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 ?

1 Like

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:

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. Overall proper controller support is a huge hassle, I wouldn’t recommend doing it at all. :open_mouth: :stuck_out_tongue: :smiley:

1 Like

If this can help you : In GD5 i created a example with javascript for support gamepad :slight_smile:

1 Like

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. :star_struck:

2 Likes

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.

Hi,

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;

All was describe in the editor of this condition.

I close this request because it released as extension.
If you need to know how add this extension to your game please follow this link.

Admin edit:
If you search how add controller/gamepad support, you can now add an extension to your game. Follow this link for know how..
And this link for see the change log of the extension.

1 Like