I have not being able to find this event in the documentation. Suppose that I launch the application with a gamepad ALREADY connected, do I receive this in on_input? In other words, may I use this event to figure out if a gamepad is connected (at start)?

Many, many thanks!

1 Like


If I recall correctly, my memory is a bit blurry;

You need to add a binding for Connected in your .input_binding file:

And you should receive this input event, even for gamepads that are already connected at start. But remember that you need to acquire input focus for the script.



Yes, I see! Many many thanks Sven!



I’ve added this to the Gamepad section of the Input manual.



I have a related question about this.

Is it possible to know the type of gamepad that has been connected? For example I would like to know if a Playstation3 gamepad or an Xbox360 gamepad has been connected. I need this since I have to display the button on screen while the player is setting the controls. It would be quite strange to show ABXY instead of square, circle, X, triangle…

In other words, I would like to know which of the mapped gamepad has been connected.



Could be done with a simple NE. Odds are though you will see mostly Xbox gamepads used on PC since Playstation ones usually take extra software to get working.

1 Like


I don’t know how to write NE… nor I have the time to learn this…

This control configuration is getting more and more complicated. But it is something that almost all our test players have asked.

The game requires diagonal input; so there is no “canonical” default key scheme. We have tried IOKL that in our opinion was optimal for right hand playing. But some players prefer WESD and some other want to play with two hands… nor to speak about the “action” button…

I have already lost an incredible amount of time on this… And now, without the right buttons on screen I have to go back to a fixed configuration.

Any idea?



You can ask the user which button style they intend to use, make it an option in the config/options/settings. It does not have to be auto-detected.

1 Like


I am not sure I understand what you are proposing. Let me try to rewrite it: I prepare some fixed configurations (for keyboard and controllers) and the player may chose which one to use.

(And I have to depict “generic gamepad” pictures since I cannot detect the gamepad type.)




Giving multiple config options may be good, but there are people with alternative keyboard layouts where none of them will work. You can still use all input and dynamically detect keys and let players remap them if you want to invest time into making that.

For the gamepad images, generic may be enough, but again you can let users pick which style they want to see. The buttons are still in the same places.

1 Like


Ah! Now I see. You are suggesting that the player may chose its own controller type, in order to have the
right button names on screens! Is this?

If so indeed this could be a solution. But note that this is a clear indication that my code is not able to detect the type of controller and I have never seen this in any game.

If I manage to solve the controller side of the problem then I will use the full customizable option for keyboard. Otherwise I have to prepare a list of multiple configurations.

But now let me thank you for your help! Really really appreciated!


1 Like


It is not currently, but I’ve encountered it recently as well.
I should be able to add that feature on that branch soon though, and hopefully be able to merge it back to dev soon.



So I will go on with keyboard only configuration for the moment, then I will come back to controller configuration later.

Many many thanks!

1 Like


And here we are again…

There is a problem with the Defold input and my Mac keyboard with Italian layout. Almost all non-alphanumeric keys are wrong. Here is a list of pairs k , a where k is the key I press on the keyboard and a is the action_id I get:
< , key_grave
-, key_slash
ò, key_semicolon
à, key_singlequote
ù, key_backslash
è, key_lbracket
+, key_rbracket
', key_minus
ì, key_equals

How can I know which keyboard layout the player is using? Again, this is a blocker for control configuration. And this time for keyboard input. The same problem with gamepad layout now for keyboard layout. What a mess! Or am I doing something wrong?

Should I exclude all non alphanumeric keys?



*nods sadly…

…and I think the only possible workaround at the moment is the same: let the user set their keyboard layout in the game and you manually translate them.

The proper solution would be for Defold to send scancodes as well as keycodes and have functions to translate between them (like Love2D).

I’m curious though, have you tried other games with your keyboard? Do they work? I almost never see this issue mentioned, so I assumed most people using other layouts who play games just switch to Qwerty before playing.

[Edit] Actually, now that I look at your list again, maybe it is using scancodes, so you get american layout no matter what. That’s probably better than the other way around, but still a problem.



Yes, I think I get only scan code. Instead Defold should (also?) send Key code.

My keyboard is QWERTY and only the keys I listed are wrong.

1 Like


Games today can usually handle different layouts. If not, I do switch to qwerty, but usually while muttering “stupid game” under my breath.



I have decided to go with only alphanumeric keys for configurable keyboard input. And no configuration at all for the gamepads.

I’ve been using Defold for over a year and a half now, and I love it deeply. But, in my opinion, its input system for keyboard and gamepads should be rethought.

The low-level part doesn’t handle keyboard layouts and doesn’t let me know what kind of controller the player is using. On the other hand there is the binding system which is too high-level and too rigid to be used except for prototyping.

I didn’t expect these difficulties with the input as everything else in the engine has always been very easy and pleasant to use.

I hope my words are not misunderstood, I’m just trying to give an opinion to improve the engine.



This should be fairly easy to solve. I think we should be able to add another field to the Connected input binding for gamepads. Please create a ticket for this!

This isn’t great at all. I’m sure it is solvable. Again, please create a ticket and we can take a look!



Done! Not sure if I have done it right however… :sweat_smile: