From 1d33d1000e0b14ad6ab2c26d44742df776565d38 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Tue, 23 Nov 2010 22:10:49 +0000 Subject: [PATCH] [Win32] Implemented Mouse.SetPosition via SetCursorPos. This was refreshingly simple, the function works exactly as expected! (unlike XWarpPointer on X11) --- Source/OpenTK/Platform/Windows/API.cs | 3 +++ Source/OpenTK/Platform/Windows/WMInput.cs | 2 +- Source/OpenTK/Platform/Windows/WinRawMouse.cs | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/OpenTK/Platform/Windows/API.cs b/Source/OpenTK/Platform/Windows/API.cs index 96c3de9f..97b4115b 100644 --- a/Source/OpenTK/Platform/Windows/API.cs +++ b/Source/OpenTK/Platform/Windows/API.cs @@ -971,6 +971,9 @@ namespace OpenTK.Platform.Windows [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] public static extern bool ClipCursor(IntPtr rcClip); + [DllImport("user32.dll")] + public static extern bool SetCursorPos(int X, int Y); + #region Async input #region GetCursorPos diff --git a/Source/OpenTK/Platform/Windows/WMInput.cs b/Source/OpenTK/Platform/Windows/WMInput.cs index 692ef491..e512204f 100644 --- a/Source/OpenTK/Platform/Windows/WMInput.cs +++ b/Source/OpenTK/Platform/Windows/WMInput.cs @@ -139,7 +139,7 @@ namespace OpenTK.Platform.Windows public void SetPosition(double x, double y) { - throw new NotImplementedException(); + Functions.SetCursorPos((int)x, (int)y); } #endregion diff --git a/Source/OpenTK/Platform/Windows/WinRawMouse.cs b/Source/OpenTK/Platform/Windows/WinRawMouse.cs index 4d6ade4f..38e8a371 100644 --- a/Source/OpenTK/Platform/Windows/WinRawMouse.cs +++ b/Source/OpenTK/Platform/Windows/WinRawMouse.cs @@ -280,7 +280,7 @@ namespace OpenTK.Platform.Windows public void SetPosition(double x, double y) { - throw new NotImplementedException(); + Functions.SetCursorPos((int)x, (int)y); } #endregion