get_viewport().get_mouse_position() inaccurate when viewport is scaled in settings

Godot Version

4.2

Question

I’m using get_viewport().get_mouse_position() to find my cursor’s position on the screen. This position is used to determine pitch and yaw input magnitude for a flight sim. The mouse coordinates are functioning like a joystick position.

When I run the game with Size Modes fullscreen or maximized (and the Stretch modes as anything), the mouse position doesn’t also get rescaled, and the game thinks my cursor is way off the side of the screen (so my plane can only pitch down and yaw left in this case).

This is because get_viewport().get_mouse_position() is calculated before the viewport is scaled to fit the monitor, which introduces the error.

Has any progress been made on this bug, or is there a workaround?