diff --git a/Source/OpenTK/Platform/SDL2/Sdl2Mouse.cs b/Source/OpenTK/Platform/SDL2/Sdl2Mouse.cs index af8039b1..0f7f2825 100644 --- a/Source/OpenTK/Platform/SDL2/Sdl2Mouse.cs +++ b/Source/OpenTK/Platform/SDL2/Sdl2Mouse.cs @@ -83,6 +83,8 @@ namespace OpenTK.Platform.SDL2 } } + internal static float Scale = 1.0f; + #endregion #region Public Members @@ -110,13 +112,19 @@ namespace OpenTK.Platform.SDL2 public MouseState GetState() { - return state; + MouseState scaledState = state; + if (Configuration.RunningOnMacOS) + { + scaledState.X = (int)Math.Round(scaledState.X * Scale); + scaledState.Y = (int)Math.Round(scaledState.Y * Scale); + } + return scaledState; } public MouseState GetState(int index) { if (index == 0) - return state; + return GetState(); else return new MouseState(); } @@ -126,6 +134,12 @@ namespace OpenTK.Platform.SDL2 int x, y; var buttons = SDL.GetGlobalMouseState(out x, out y); + if (Configuration.RunningOnMacOS) + { + x = (int)Math.Round(x * Scale); + y = (int)Math.Round(y * Scale); + } + var c = new MouseState(); c.SetIsConnected(true); c.X = x; diff --git a/Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs b/Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs index 6fdcbf91..47b6d13c 100644 --- a/Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs +++ b/Source/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs @@ -285,6 +285,7 @@ namespace OpenTK.Platform.SDL2 window.OnMouseMove( (int)Math.Round(ev.X * scale), (int)Math.Round(ev.Y * scale)); + Sdl2Mouse.Scale = scale; } static void ProcessMouseWheelEvent(Sdl2NativeWindow window, MouseWheelEvent ev)