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);
}
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
{
const string lib = "/System/Library/Frameworks/ApplicationServices.framework/Versions/Current/ApplicationServices";
- // CGPoint -> HIPoint
+ // CGPoint -> NSPoint
// CGSize -> HISize
// CGRect -> HIRect
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();
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