I want change input icon immediately.
When i use gamepad,icon change to gamepad icon.
When i use keyboard and mouse,icon change to keyboard&Mouse.
So i set inputAction like this
and i use playerInput.onControlsChanged event to get current device displayString
public void OnControlsChanged(PlayerInput input)
{
string runStr = playerInput.actions["Run"].GetBindingDisplayString();
Debug.Log($"InputSystemTest -> OnControlsChanged: {runStr}");
}
It works weel on other gamepad key or keyboard&Mouse
But i use gamepad stick to move cursor (Mouse.current.WarpCursorPosition(value))
void Update()
{
if (Gamepad.current == null)
return;
// Get the joystick position
rightStick = Gamepad.current.rightStick.ReadValue();
// Prevent annoying jitter when not using joystick
if (rightStick.magnitude < 0.1f) return;
// Get the current mouse position to add to the joystick movement
var mousePos = Mouse.current.position.ReadValue();
mousePosition = new Vector2(mousePos.x, mousePos.y);
// Precise value for desired cursor position, which unfortunately cannot be used directly
warpPosition = mousePosition + bias + overflow + sensitivity * Time.deltaTime * rightStick;
// Keep the cursor in the game screen (behavior gets weird out of bounds)
warpPosition = new Vector2(Mathf.Clamp(warpPosition.x, 0, Screen.width), Mathf.Clamp(warpPosition.y, 0, Screen.height));
// Store floating point values so they are not lost in WarpCursorPosition (which applies FloorToInt)
overflow = new Vector2(warpPosition.x % 1, warpPosition.y % 1);
// Move the cursor
Mouse.current.WarpCursorPosition(warpPosition);
}
when i push rightStick the playerInput.onControlsChanged will continuously alternately receive mouse event and gamepad event like this
So how do i resolve the conflict between playerInput.onControlsChanged and WarpCursorPosition?
I would greatly appreciate any leads you can provide.