Was trying to figure out how to wrap the mouse cursor in Godot, similar to what Blender does when you move the mouse near the bounds of the window.
To do this, we need to detect if the mouse is close to the window edge by some arbitrary margin. We have to use a margin because if the window is maximized when the mouse hits the edge of the screen, the operating system will not report mouse movement that would move the mouse past the bounds of the window since that would also move the cursor off-screen.
When the mouse is within the bounds, we can warp the mouse. However, the mouse position in Godot is in the viewport’s coordinate system, so we have to transform it back to window pixel coordinates in order for the warp to work correctly: