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!
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.