No support for android gamepads? (SOLVED)

I’ve gathered from the documentation and information on the forum that on screen touch controls, as shown with example below. That’s great, and it makes complete sense - most users need those on screen touch controls.

What I’m noticing though, is that there’s no way to bind actions to android gamepads - I can’t get the example below to work with any android bluetooth gamepads.

It’s obvious that the ‘gamepad triggers’ section of the input/default.input_binding file is for PC controllers - when testing the gamepad_tester example above, it works flawlessly when building for pc. However, when building for android and debugging on a physical device, it fails to register input from a bluetooth gamepad.

Oddly, if I remove all ‘touch-triggers’ and add a ‘key-trigger’ where ‘key-back’ is an action, I can trigger the action with the back button on my android device and the B button of the bluetooth gamepad - which I can see is bound to ‘BUTTON_B’ and ‘keycode 97’ on the device.

It seems like such a tease that I can bind to the B button of the gamepad by a weird coincidence, but can’t bind actions to the rest of the buttons.

Shouldn’t defold support android gamepads with the ‘gamepad triggers’, or at least have ‘key triggers’ which correspond to the rest of Android’s gamepad buttons like these?

KEYCODE_DPAD_UP, KEYCODE_DPAD_DOWN, KEYCODE_DPAD_LEFT, KEYCODE_DPAD_RIGHT etc

I wonder if those keycodes could be added to the possible input choices list for the ‘key triggers’ like the ‘key-back’ was?

Note: I think this other bug highlights that bluetooth android keyboards can’t be bound to either.

1 Like

Here’s an issue

It’s probably possible to properly support bluetooth gamepads on ios/android with native extensions.

2 Likes

I think the bluetooth gamepad is sending key events to Android that then gets translated into key triggers in Defold, but the key events may not map to any known key triggers. I wonder if you could instead set up a text trigger in your game?

When I add a text trigger (with or without a named action value), I see characters appearing when building for pc.

function on_input(self, action_id, action)
	if action_id then print("the id is " .. action_id) end
	if action.text then print("the text is " .. action.text) end

When building for android and using a bluetooth gamepad, now only the Y button is registering as a text trigger, and what I see in the console is "the text is " - with a blank action.text value. None of the other buttons on the gamepad are setting action.text to not nil, not even the X button which I mentioned was triggering the key-trigger ‘key-back’ before.

BUTTON_Y has a keycode value of 100 - very odd that just one button on the gamepad is binding to each of these trigger types. The gamepads I’m testing with are the Moga Pro 2 (in HID mode) and Ipega pg-9025 (xbox style android bt) and they have the same behavior.

Thanks for the support here, I’m really impressed with the framework and all of the features, especially the android build, it’s really fast!

Did you manage to solve your gamepad problem? I am trying to get an amazon fire stick remote to work.

Android Gamepads are now supported.

3 Likes