Change HIPoint to NSPoint, hipoint wasn't arch independent
authorVPeruS <vperus@gmail.com>
Thu, 8 Jun 2017 19:25:59 +0000 (22:25 +0300)
committerVlad K <vperus@gmail.com>
Tue, 13 Jun 2017 02:31:31 +0000 (05:31 +0300)
src/OpenTK/Platform/MacOS/HIDInput.cs
src/OpenTK/Platform/MacOS/Quartz/DisplayServices.cs
src/OpenTK/Platform/MacOS/Quartz/EventServices.cs

index ca6eecd..87d06ae 100644 (file)
@@ -273,7 +273,7 @@ namespace OpenTK.Platform.MacOS
                     case CGEventType.RightMouseDragged:
                     case CGEventType.OtherMouseDragged:
                         {
-                            Carbon.HIPoint p = CG.EventGetLocation(@event);
+                            NSPoint p = CG.EventGetLocation(@event);
                             CursorState.X = (int)Math.Round(p.X);
                             CursorState.Y = (int)Math.Round(p.Y);
                         }
@@ -1045,7 +1045,15 @@ namespace OpenTK.Platform.MacOS
         void IMouseDriver2.SetPosition(double x, double y)
         {
             CG.SetLocalEventsSuppressionInterval(0.0);
-            CG.WarpMouseCursorPosition(new Carbon.HIPoint(x, y));
+
+            NSPoint p = new NSPoint();
+            unsafe
+            {
+                p.X.Value = *(IntPtr *)&x;
+                p.Y.Value = *(IntPtr *)&y;
+            }
+
+            CG.WarpMouseCursorPosition(p);
         }
 
         #endregion
index 9a1b3d1..853d32d 100644 (file)
@@ -60,7 +60,7 @@ namespace OpenTK.Platform.MacOS
     {
         const string lib = "/System/Library/Frameworks/ApplicationServices.framework/Versions/Current/ApplicationServices";
 
-        // CGPoint -> HIPoint
+        // CGPoint -> NSPoint
         // CGSize -> HISize
         // CGRect -> HIRect
 
@@ -116,7 +116,7 @@ namespace OpenTK.Platform.MacOS
         internal static extern IntPtr DisplaySwitchToMode(IntPtr display, IntPtr displayMode);
 
         [DllImport(lib, EntryPoint = "CGWarpMouseCursorPosition")]
-        internal static extern CGError WarpMouseCursorPosition(HIPoint newCursorPosition);
+        internal static extern CGError WarpMouseCursorPosition(NSPoint newCursorPosition);
 
         [DllImport(lib, EntryPoint = "CGCursorIsVisible")]
         internal static extern bool CursorIsVisible();
index 7e61bdd..73067be 100644 (file)
@@ -66,7 +66,32 @@ namespace OpenTK.Platform.MacOS
             CGEventField field);
 
         [DllImport(lib, EntryPoint = "CGEventGetLocation")]
-        internal static extern Carbon.HIPoint EventGetLocation(CGEventRef @event);
+        internal static extern NSPointF EventGetLocationF(CGEventRef @event);
+        [DllImport(lib, EntryPoint = "CGEventGetLocation")]
+        internal static extern NSPointD EventGetLocationD(CGEventRef @event);
+
+        internal static NSPoint EventGetLocation(CGEventRef @event)
+        {
+            NSPoint r = new NSPoint();
+
+            unsafe {
+                if (IntPtr.Size == 4)
+                {
+                    NSPointF pf = EventGetLocationF(@event);
+                    r.X.Value = *(IntPtr *)&pf.x;
+                    r.Y.Value = *(IntPtr *)&pf.y;
+                }
+                else
+                {
+                    NSPointD pd = EventGetLocationD(@event);
+                    r.X.Value = *(IntPtr *)&pd.x;
+                    r.Y.Value = *(IntPtr *)&pd.y;
+                }
+            }
+
+            return r;
+        }
+
     }
 
     enum CGEventTapLocation