Fix macos x64 wrong mouse input

This commit is contained in:
Vperus 2017-06-07 00:05:06 +03:00 committed by Vlad K
parent f1fed27afd
commit 85541f6449
2 changed files with 51 additions and 2 deletions

View file

@ -160,7 +160,32 @@ namespace OpenTK.Platform.MacOS
// Not the _stret version, perhaps because a NSPoint fits in one register?
// thefiddler: gcc is indeed using objc_msgSend for NSPoint on i386
[DllImport (LibObjC, EntryPoint="objc_msgSend")]
public extern static NSPoint SendPoint(IntPtr receiver, IntPtr selector);
public extern static NSPointF SendPointF(IntPtr receiver, IntPtr selector);
[DllImport (LibObjC, EntryPoint="objc_msgSend")]
public extern static NSPointD SendPointD(IntPtr receiver, IntPtr selector);
public static NSPoint SendPoint(IntPtr receiver, IntPtr selector)
{
NSPoint r = new NSPoint();
unsafe
{
if (IntPtr.Size == 4)
{
NSPointF pf = SendPointF(receiver, selector);
r.X.Value = *(IntPtr *)&pf.x;
r.Y.Value = *(IntPtr *)&pf.y;
}
else
{
NSPointD pd = SendPointD(receiver, selector);
r.X.Value = *(IntPtr *)&pd.x;
r.Y.Value = *(IntPtr *)&pd.y;
}
}
return r;
}
[DllImport (LibObjC, EntryPoint="objc_msgSend_stret")]
extern static void SendRect(out NSRect retval, IntPtr receiver, IntPtr selector);

View file

@ -45,6 +45,18 @@ namespace OpenTK.Platform.MacOS
{
IntPtr value;
public IntPtr Value
{
get
{
return value;
}
set
{
this.value = value;
}
}
public static implicit operator NSFloat(float v)
{
NSFloat f;
@ -179,5 +191,17 @@ namespace OpenTK.Platform.MacOS
return new RectangleF(s.Location, s.Size);
}
}
}
// Using IntPtr in NSFloat cause that if imported function
// return struct that consist of them you will get wrong data
// This types are used for such function.
public struct NSPointF
{
public float x, y;
}
public struct NSPointD
{
public double x, y;
}
}