mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 18:55:50 +00:00
[SDL] Avoid CursorVisible = true cursor jump
This commit is contained in:
parent
a270b9328e
commit
e3fd9e1374
|
@ -397,6 +397,16 @@ namespace OpenTK.Platform.SDL2
|
|||
SDL.ShowCursor(!grab);
|
||||
SDL.SetWindowGrab(window.Handle, grab);
|
||||
SDL.SetRelativeMouseMode(grab);
|
||||
if (!grab)
|
||||
{
|
||||
// Move the cursor to the current position
|
||||
// in order to avoid a sudden jump when it
|
||||
// becomes visible again
|
||||
float scale = Width / (float)Size.Width;
|
||||
SDL.WarpMouseInWindow(window.Handle,
|
||||
(int)Math.Round(MouseState.X / scale),
|
||||
(int)Math.Round(MouseState.Y / scale));
|
||||
}
|
||||
}
|
||||
|
||||
// Hack to force WindowState events to be pumped
|
||||
|
|
Loading…
Reference in a new issue