PerformInteractiveRebinding and exclude full gamepad axes?

My game offers separate move forward/back/left/right bindings, because I want to support binding four separate keyboard keys to these commands as well as a gamepad.

Taking Move Forward as an example I have bindings in my Input Actions asset for “W [Keyboard]” and “Left Stick/Up [Gamepad]”. This works fine. But after following the Rebinding example and implementing a screen that calls PerformInteractiveRebinding, pushing up on the left gamepad stick simply maps “LS” to my forward command.

PerformInteractiveRebinding is very configurable but I do not immediately see a way to restrict the rebinding to a single direction of an axial input.

Is this possible?

Note that I tried using WithControlsExcluding to exclude “/leftStick”, but this also excludes “/leftStick/up” …

Continuing my conversation with myself: it seems possible to do this using OnPotentialMatch and manually filtering out any candidate that ends with “leftStick” or “rightStick”!

But I wonder if there could be a general way to filter out certain classes, such as all axes, all device-brand-specific (for example I don’t want leftStick/Y to be an option just b/c I have an Xbox controller attached; generic leftStick/up seems better).

Make sure to the set the action type and value type. For rebinding, this is the single most important information to guide the rebinder.

With the action type set either to Button or with it set to Value and the control type set to Axis, the rebinder should automatically ignore the stick control and instead only consider its axes individually.

2 Likes

How do you get this to work with a Vector2 value? The PerformInteractiveRebind is returning say Left Stick/Y instead of Left Stick/Up or Down on the bindings, and for some reason if you have the same Binding off Left Stick/Y for the Up and Down part of the Action the number of controls for that action is reduced from 4 to 3 internally, which nicely messes things about. If you add code to check for duplicate bindings then how do you tell if Left Stick/Y is +ve or -ve so you can bind it to the Up and Down controls correctly. Seems a bit of a hit and miss system in this regards unless I am missing something obvious?

1 Like