Skip to content

Mouse.current.position returns stale value #1073

@Decavoid

Description

@Decavoid

Mouse.current.position should return the latest mouse position but it returns the previous mouse position instead.

Repro code:
mousetest.zip

using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.UI;

public class Test : MonoBehaviour
{
    [SerializeField] Text textOldInputXY;
    [SerializeField] Text textInputSystemXY;
    [SerializeField] Text textOK;

    private void Update()
    {
        Vector3 oldSystemMousePos = Input.mousePosition;
        Vector2 inputSystemMousePos = Mouse.current.position.ReadValue();

        if (oldSystemMousePos.x == inputSystemMousePos.x && oldSystemMousePos.y == inputSystemMousePos.y)
        {
            textOK.color = Color.green;
            textOK.text = "ok";
        }
        else
        {
            textOK.color = Color.red;
            textOK.text = "fail";
        }

        textOldInputXY.text = $"{oldSystemMousePos.x} {oldSystemMousePos.y}";
        textInputSystemXY.text = $"{inputSystemMousePos.x} {inputSystemMousePos.y}";
    }
}

Scenario 1: Change mouse DPI to the lowest possible value. Slowly move the mouse (5px/s). Observed result: the text quickly changes: "ok/fail/..." for every pixel, new Input System's position lags behind by 1 px.
screenshot0

Scenario 2: While moving the mouse relatively quickly, lift the mouse up. Keep the mouse in the air. Observed result: Text shows "fail". Old input system mouse position is correct. New Input System's mouse position is different by >10 pixels, showing the previous value.
screenshot

Unity: 2019.3.2f1
InputSystem: 1.0.0-preview.5
Windows 10
fogbugz Case 1221634.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions