Input System Control Scheme Bug?

I am currently using the input system with two control schemes. One for mouse, pointer, and keyboard. The other is gamepad. I am using Invoke C# Events. I could just not understand, but my understanding is that the control schemes are supposed to detect when input devices change and then change to that control scheme. Which I can see in the player input component when the game is running.

I am working on a top down shooter. In my input actions I have a Look action. The gamepad control scheme is set to Right Stick [Gamepad] and my KBaM control scheme is set to Position [Pointer].

My issue is when I set the Look action type to Value, even though unity detects when the control scheme has changed in the player input component , the player only looks at the Position [Pointer]. If I use the mouse and click off screen to disable the mouse pointer then the gamepad works just fine.

If I use the action type Pass Through it works as intended but the player snaps to -90 after the user stops using the Right Stick [Gamepad]. If I use Value this does not happen.

My Code:

public class PlayerMovement : MonoBehaviour
{
    private InputMaster input;
    private InputAction Look;
    private Rigidbody2D _rigidbody;

    private void Awake()
    {
        _rigidbody = GetComponent<Rigidbody2D>();
        input = new InputMaster();
    }

    private void DoLook(InputAction.CallbackContext cont)
    {
        if (cont.control.displayName == "Right Stick")
        {
            Vector3 targetPosition = cont.ReadValue<Vector2>();
            Vector2 lookDir = targetPosition.normalized;
            float angle = Mathf.Atan2(lookDir.y, lookDir.x) * Mathf.Rad2Deg - 90f;
            _rigidbody.MoveRotation(angle);
        }
        else if (cont.control.displayName == "Position")
        {
            Vector3 targetPosition = cont.ReadValue<Vector2>();
            Vector3 ObjPos = Camera.main.WorldToScreenPoint(_rigidbody.transform.position);
            Vector3 dir = targetPosition - ObjPos;
            float rotZ = Mathf.Atan2(dir.x, dir.y) * Mathf.Rad2Deg;
            _rigidbody.MoveRotation(-rotZ);
        }
    }

    private void OnEnable()
    {
        Look = input.Player.Look;
        Look.Enable();

        input.Player.Look.performed += DoLook;
        input.Player.Move.Enable();
    }

    private void OnDisable()
    {
        Look = input.Player.Look;
        Look.Disable();

        input.Player.Look.performed -= DoLook;
        input.Player.Move.Disable();
    }
}


I have the exact same issue. Look.ReadValue() always returns the mouse position regardless of PlayerInput.currentControlScheme or which control is physically being used.

I found a similar issue posted over 3 years ago that this might be a bug. Gamepad Right stick returning the same value as the Mouse position after switching Input schemes - Unity Forum Is this still the case, or is there some intended behavior that I am missing here?

Suggested Workaround
As a workaround, I created two separate actions for Look; LookGamepad and LookMouse. Then I could decide which value to read using PlayerInput.currentControlScheme. It is not the prettiest because I will have to code this at various locations where the Aim action is concerned, it would be nicer to just have it work correctly in the InputSystem. But it does the job.

Here is some sample code, I used the generated C# code instead of the C# Events, but the gist of it should be the same. Hope this helps!

private float GetAimDirection(float currentAim)
    {
        if (playerInput.currentControlScheme == "Controller")
        {
            Vector2 aim = inputActions.PlayerControl.AimController.ReadValue<Vector2>();
            if (aim.magnitude == 0) { return currentAim; }
            return Mathf.Atan2(aim.y, aim.x);
        }
        else
        {
            Vector2 aim = inputActions.PlayerControl.AimMouse.ReadValue<Vector2>();
            // Mouse input is in screen coords
            Vector3 rbCameraPos = Camera.main.WorldToScreenPoint(transform.position);
            aim -= new Vector2(rbCameraPos.x, rbCameraPos.y);
            return Mathf.Atan2(aim.y, aim.x);
        }
    }


Make sure to check to corresponding boxes for ‘use in control scheme’ at both bindings.