mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-11 22:25:36 +00:00
Implemented SetPosition in terms of CGWarpMouseCursorPosition.
Added constructors to HIPoint.
This commit is contained in:
parent
5caf6204de
commit
1a3df17dff
|
@ -99,6 +99,14 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||
{
|
||||
public float X;
|
||||
public float Y;
|
||||
public HIPoint(float x, float y)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
public HIPoint(double x, double y)
|
||||
: this((float)x, (float)y)
|
||||
{ }
|
||||
}
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct HISize
|
||||
|
|
|
@ -12,6 +12,21 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||
|
||||
}
|
||||
|
||||
enum CGError
|
||||
{
|
||||
Success = 0,
|
||||
Failure = 1000,
|
||||
IllegalArgument = 1001,
|
||||
InvalidConnection = 1002,
|
||||
InvalidContext = 1003,
|
||||
CannotComplete = 1004,
|
||||
NotImplemented = 1006,
|
||||
RangeCheck = 1007,
|
||||
TypeCheck = 1008,
|
||||
InvalidOperation = 1010,
|
||||
NoneAvailable = 1011,
|
||||
}
|
||||
|
||||
internal static class CG
|
||||
{
|
||||
const string appServices = "/System/Library/Frameworks/ApplicationServices.framework/Versions/Current/ApplicationServices";
|
||||
|
@ -50,5 +65,7 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||
[DllImport(appServices, EntryPoint = "CGDisplaySwitchToMode")]
|
||||
internal static extern IntPtr DisplaySwitchToMode(IntPtr display, IntPtr displayMode);
|
||||
|
||||
[DllImport(appServices, EntryPoint = "CGWarpMouseCursorPosition")]
|
||||
internal static extern CGError WarpMouseCursorPosition(HIPoint newCursorPosition);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,8 @@ namespace OpenTK.Platform.MacOS
|
|||
using IOOptionBits = System.IntPtr;
|
||||
using IOReturn = System.IntPtr;
|
||||
|
||||
// Requires Mac OS X 10.5 or higher.
|
||||
// Todo: create a driver for older installations. Maybe use CGGetLastMouseDelta for that?
|
||||
class HIDInput : IMouseDriver2
|
||||
{
|
||||
#region Fields
|
||||
|
@ -195,7 +197,7 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
#region IMouseDriver2 Members
|
||||
|
||||
public MouseState GetState()
|
||||
MouseState IMouseDriver2.GetState()
|
||||
{
|
||||
MouseState master = new MouseState();
|
||||
foreach (KeyValuePair<IntPtr, MouseState> item in MouseDevices)
|
||||
|
@ -206,7 +208,7 @@ namespace OpenTK.Platform.MacOS
|
|||
return master;
|
||||
}
|
||||
|
||||
public MouseState GetState(int index)
|
||||
MouseState IMouseDriver2.GetState(int index)
|
||||
{
|
||||
IntPtr device;
|
||||
if (MouseIndexToDevice.TryGetValue(index, out device))
|
||||
|
@ -217,8 +219,9 @@ namespace OpenTK.Platform.MacOS
|
|||
return new MouseState();
|
||||
}
|
||||
|
||||
public void SetPosition(double x, double y)
|
||||
void IMouseDriver2.SetPosition(double x, double y)
|
||||
{
|
||||
CG.WarpMouseCursorPosition(new Carbon.HIPoint(x, y));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
Loading…
Reference in a new issue