Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

How to use keyboard input with composite controls?

Discussion in 'New Input System' started by sunrisebacon, Dec 31, 2018.

  1. sunrisebacon

    sunrisebacon

    Joined:
    Jul 15, 2017
    Posts:
    11
    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:
    Code (CSharp):
    1. IndexOutOfRangeException: Index was outside the bounds of the array.
    2. 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)
    3. 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)
    4. 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)
    5. 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)
    6. 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)
    7. 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)
    8. 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)
    9. 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)
    10. 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)
    11. 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)
     
  2. Aresak

    Aresak

    Joined:
    Dec 28, 2013
    Posts:
    13
    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 ;)

    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.

     
  3. sunrisebacon

    sunrisebacon

    Joined:
    Jul 15, 2017
    Posts:
    11
    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!
     
  4. Aresak

    Aresak

    Joined:
    Dec 28, 2013
    Posts:
    13
    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
     
  5. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    825
    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.
     
    sunrisebacon likes this.