Distinguish between pointer and thumbstick for same action

I have a top-down crosshair that I can control with either a mouse or an analog stick. So I’ve created an Action called Aim that outputs a Vector2, and mapped it to <Pointer>/position and <Gamepad>/rightStick
Now the thing is, I want to process input differently based on the device sending it. For pointer I just use the position transformed to Viewport space, but for analogs I start with a value of (0.5, 0.5) and accumulate the analog value as a delta.

How can I detect what kind of device is behind the action? I’m polling the value like this:
playerInput.actions["Aim"].ReadValue<Vector2>();

And I’ve tried this:

// Use pointer logic, etc 
}```

But activeControl is null when I poll it.

Thanks!

Bump

What’s the value of the InputAction.phase property when polling activeControl?

One way to manually keep track is

InputControl m_LastControl;

// ...
{
    action.performed += ctx => m_LastControl = ctx.control;

For PlayerInput, another way way is to distinguish it by control scheme.

    bool m_GamepadUsed;

    void OnControlsChanged(PlayerInput playerInput)
    {
        var controlScheme = playerInput.currentControlScheme;
        m_GamepadUsed = controlScheme == "Gamepad";
    }

Hi Rene! Thanks for answering.

When the game tab (I just tested in-editor) it returns ‘Started’. When I take focus away, it returns ‘Waiting’. I read the docs more carefully and realised where my problem came from: In editor, focus is not always on the game tab, so i got NREs and this got me to dismiss the approach. Filtering the phase before checking seems to fix it!.

I tried to check the type of the control instead of the name of the scheme as it seemed more robust. I’m a bit wary about relying on strings for these kind of things.