Warping cursor affects mouse position/delta differently between platforms

Hi all,

Using the InputSystem version 1.3.0 (Unity version 2022.1.6f1), I encounter a problem using Mouse.current.WarpCursorPosition(targetPosition);.
The way the cursor’s position is updated varies between MacOS and Windows.
On Windows, the cursor does move properly and everything is running as intended, however on MacOS, the cursor is only warping after moving the mouse.

I have set up this little example script to test the problem:

private void Update()
{
    if (Mouse.current.leftButton.wasReleasedThisFrame)
    {
        Vector2 position = Mouse.current.position.ReadValue();
        Vector2 mirrorPosition = new Vector2(Screen.width - position.x, Screen.height - position.y);

        Mouse.current.WarpCursorPosition(mirrorPosition);
     
        Debug.Log($"warping mouse from {position} to {mirrorPosition}.");
    }
}

When running the script on Windows, the cursor warps to a mirrored screen position from where the user has clicked. Clicking a second time without moving the mouse warps the cursor again, back to the original screen position.
On MacOS however, the cursor does warp to the new position, but if the user clicks again without moving the mouse, the Debug.Log message shows that the cursor’s position has not been updated. Visually, the mouse doesn’t appear to move at all.

After googling for answers, I came across the use of InputState.Change(Mouse.current.position, targetPosition);, which I think helps with my implementation but doesn’t help to circumvent the issue highlighted by the above example script.

I am looking to have a feature parity between Windows and MacOS, and hope to find a way to force update the cursor’s position so that I can use the WarpCursorPosition() function the same way across platforms.

Any help or tips getting this to work are very welcome!

For info, it appears as though the OS actually reports the correct position. Using Cmd + Shift + 4 to check the cursor’s coordinates, it updates properly immediately after the warp.
I think this indicates that the new position isn’t being registered properly by Unity.

Another interesting detail: in the example script I posted above, the cursor does eventually warp again when clicking multiple times without moving the mouse, it just takes several seconds for the cursor position to be updated internally.

I’ll upload a couple of screen recordings to highlight the issue later on.

Here is a screen capture of the example code from the first post, running on Windows:
8449373--1120751--warp cursor position windows.gif

And here is the same setup running on MacOS:
8449373--1120748--warp cursor position mac.gif

As you can see, on Windows the cursor is being warped properly the second time as well. On MacOS, as the position is determined by an offset from the current cursor coordinates, the second click doesn’t warp the cursor, indicating that the cursor’s position is not set internally.

Based on the following thread: Mouse.WarpCursorPosition() produces mouse delta on Linux but not on Windows?
I suspect that this issue is also present in Linux, and only works correctly on Windows (if reporting the new position as the cursor’s position is the intended behaviour).

The following thread appears to report the same issue back in version 1.0.0 for Windows: InputSystem reporting wrong mouse position after WarpCursorPosition
The solution the author of the thread proposes doesn’t seem to work in my situation.

Any help, workaround or suggestion is greatly appreciated!