Community Forum

How to detect gamepad controller button presses?

Forum Overview >> Scripting

Created29.09.2020 23:48

Loki Laufeyson (loki_79) 29.09.2020 23:48
If we have in the inputBinding.xml file:
<binding device="0_XINPUT_GAMEPAD" input="BUTTON_3" axisComponent="+" neutralInput="0" index="1"/>

I am trying:

But that does not return true. The in-game actions work with the same controller bindings.
Does any one know the correct function or usage?

Bilbo Beutlin (BBeutlin) 30.09.2020 11:50
The method with "Input.isKeyPressed()" works with standard input only, like keyboard, mouse, some joystick axis.
For all other translation tables are used. In first step from 'inputDevices', which assigns physical to logical events. In second step from 'inputBindings', which assigns device events to actionBindings.
So most events are only noticed if you register these explicitely by 'InputAction.INPUT_NAME'. See LUADOCs for reference and examples.

Loki Laufeyson (loki_79) 30.09.2020 18:22
Thank you for the guidance. I don't have a controller to test with, so I have been sending scripts to someone else and it is quite slow as you can imagine. I will buy a controller and do the testing myself.

Note: Log in to post. Create a new account here.