How to use keyboard input with composite controls?

I saw this video from Brackeys

where he uses a Composite Dpad to implement movement via keyboard input.

I got the latest 0.1.2 version of the Input system and I am not able to get a Vector2 from a DpadControl via keyboard input.
As far as I understand the source code it’s supposed to return a Vector2 but with keyboard input I always get an exception that it returns float only.

Is this a bug in the implementation or are we supposed to only use simple bindings with keyboard input?

I also tried Axis control with a similar result. Only one side works and I also get this exception:

IndexOutOfRangeException: Index was outside the bounds of the array.
UnityEngine.Experimental.Input.InputActionMapState.GetActionOrNull (UnityEngine.Experimental.Input.InputActionMapState+TriggerState& trigger) (at Library/PackageCache/com.unity.inputsystem@0.1.2-preview/InputSystem/Actions/InputActionMapState.cs:985)
UnityEngine.Experimental.Input.InputActionMapState.GetActionOrNoneString (UnityEngine.Experimental.Input.InputActionMapState+TriggerState& trigger) (at Library/PackageCache/com.unity.inputsystem@0.1.2-preview/InputSystem/Actions/InputActionMapState.cs:954)
UnityEngine.Experimental.Input.InputActionMapState.ThrowIfPhaseTransitionIsInvalid (UnityEngine.Experimental.Input.InputActionPhase currentPhase, UnityEngine.Experimental.Input.InputActionPhase newPhase, UnityEngine.Experimental.Input.InputActionMapState+TriggerState& trigger) (at Library/PackageCache/com.unity.inputsystem@0.1.2-preview/InputSystem/Actions/InputActionMapState.cs:938)
UnityEngine.Experimental.Input.InputActionMapState.ChangePhaseOfAction (UnityEngine.Experimental.Input.InputActionPhase newPhase, UnityEngine.Experimental.Input.InputActionMapState+TriggerState& trigger, UnityEngine.Experimental.Input.InputActionPhase phaseAfterPerformedOrCancelled) (at Library/PackageCache/com.unity.inputsystem@0.1.2-preview/InputSystem/Actions/InputActionMapState.cs:837)
UnityEngine.Experimental.Input.InputActionMapState.ProcessControlStateChange (System.Int32 mapIndex, System.Int32 controlIndex, System.Int32 bindingIndex, System.Double time, UnityEngine.Experimental.Input.LowLevel.InputEventPtr eventPtr) (at Library/PackageCache/com.unity.inputsystem@0.1.2-preview/InputSystem/Actions/InputActionMapState.cs:569)
UnityEngine.Experimental.Input.InputActionMapState.UnityEngine.Experimental.Input.LowLevel.IInputStateChangeMonitor.NotifyControlStateChanged (UnityEngine.Experimental.Input.InputControl control, System.Double time, UnityEngine.Experimental.Input.LowLevel.InputEventPtr eventPtr, System.Int64 mapControlAndBindingIndex) (at Library/PackageCache/com.unity.inputsystem@0.1.2-preview/InputSystem/Actions/InputActionMapState.cs:455)
UnityEngine.Experimental.Input.InputManager.FireStateChangeNotifications (System.Int32 deviceIndex, System.Double internalTime, UnityEngine.Experimental.Input.LowLevel.InputEvent* eventPtr) (at Library/PackageCache/com.unity.inputsystem@0.1.2-preview/InputSystem/InputManager.cs:2963)
UnityEngine.Experimental.Input.InputManager.OnUpdate (UnityEngine.Experimental.Input.InputUpdateType updateType, UnityEngine.Experimental.Input.LowLevel.InputEventBuffer& eventBuffer) (at Library/PackageCache/com.unity.inputsystem@0.1.2-preview/InputSystem/InputManager.cs:2693)
UnityEngine.Experimental.Input.LowLevel.NativeInputRuntime+<>c__DisplayClass6_0.<set_onUpdate>b__0 (UnityEngineInternal.Input.NativeInputUpdateType updateType, System.Int32 eventCount, System.IntPtr eventPtr) (at Library/PackageCache/com.unity.inputsystem@0.1.2-preview/InputSystem/NativeInputRuntime.cs:110)
UnityEngineInternal.Input.NativeInputSystem.NotifyUpdate (UnityEngineInternal.Input.NativeInputUpdateType updateType, System.Int32 eventCount, System.IntPtr eventData) (at C:/buildslave/unity/build/Modules/Input/Private/Input.cs:91)

Hi,
I’m having the same problem. It looks that it is caused by multiple action maps in one asset. The first map works but every other doesn’t.

The current workaround I’m doing is temporarily I got an input asset for each map that should be in there and after it will get fixed I will just change the asset to go into 1 which will have all the maps.

Try if it works with just one map :wink:

As in the image: The first 3 actions are from the 1st map and then I try an action from the 2nd map. With ChangePhaseOfAction exception once and then GetActionOrNull either on every press of the button from any map or once and then the input system stops working not receiving any updates anymore.

Hello Aresak
You are correct. I had two action maps configured.
I moved all actions to the same map and now things work as expected.
Thanks for the heads up!

No problem, happy to help you.
It is issued on github, but thanks to holidays we will gat a fix soon hopefully.

For me it was frustrating too, because I had to do a new assets where I had 8 maps

Sorry about that. I whacked a couple of indexing problems related to multiple action maps but apparently I still didn’t get them all. I’ll go and take a look.

1 Like