New input system, how to get current control scheme?

I have searched a lot but i cannot find how to check what control scheme i am using.

For example i have a variable that i need it to be different for keyboard & mouse from gamepad.

Is there any way to know that my last input was from gamepad?

I assume you use the Actions. If you do that, through the CallbackContext you can ask for the current control:
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/api/UnityEngine.InputSystem.InputAction.CallbackContext.html#UnityEngine_InputSystem_InputAction_CallbackContext_control

The control is an InputControl which has a path property. It tells you what is the control was used to trigger the action (for example wKey or something). You can use this path or you can walk back through the parent properties to the root InputControl which is the InputDevice itself.

1 Like

For example i have

    void Awake()
    {
        controls = new PlayerInputSystem();
        controls.RadialUI.Position.performed += mr_ctx => MousePos(mr_ctx.ReadValue<Vector2>(), mr_ctx);
        RadialMenuInitialize();
    }

and when i use

 public void MousePos(Vector2 mousePos, InputAction.CallbackContext context)
    {
            mousePosition = mousePos;
    }

i get what i need for the keyboard and mouse. My radial menu highlights what item i need.Now when i switch to gamepad the vector2 position is moving so slow and i cannot highlight my radial menu item.

The only solution i could use was increasing mousePosition = mousePos * 2000 and it works for gamepad but doesn’t work for keyboard and mouse.

So if could read what control scheme is , i can use mousePosition = mousePos; for keyboard&mouse and mousePosition = mousePos * 2000 for gamepad.

Thank you for all your help.

Well, have you tried InputAction.CallbackContext that Lurking-Ninja suggested?

You can use PlayerInput’s currentControlScheme property to get the name of the current scheme as a string.

1 Like

I see you are trying ot solve your problem with different deltas form mouse and gampad input in your code. I would suggest you that you use processors (scale vector 2) on your action for gamepad

4 Likes

very usefull thx