mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-02-02 06:21:00 +00:00
[Mac] Retain CFRunLoop while it is in use
This commit is contained in:
parent
42e4e0b27e
commit
7956126c8d
|
@ -94,7 +94,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
readonly Dictionary<int, IntPtr> JoystickIndexToDevice =
|
readonly Dictionary<int, IntPtr> JoystickIndexToDevice =
|
||||||
new Dictionary<int, IntPtr>();
|
new Dictionary<int, IntPtr>();
|
||||||
|
|
||||||
readonly CFRunLoop RunLoop = CF.CFRunLoopGetMain();
|
readonly CFRunLoop RunLoop;
|
||||||
readonly CFString InputLoopMode = CF.RunLoopModeDefault;
|
readonly CFString InputLoopMode = CF.RunLoopModeDefault;
|
||||||
readonly CFDictionary DeviceTypes = new CFDictionary();
|
readonly CFDictionary DeviceTypes = new CFDictionary();
|
||||||
|
|
||||||
|
@ -118,6 +118,16 @@ namespace OpenTK.Platform.MacOS
|
||||||
{
|
{
|
||||||
Debug.Print("Using HIDInput.");
|
Debug.Print("Using HIDInput.");
|
||||||
|
|
||||||
|
RunLoop = CF.CFRunLoopGetMain();
|
||||||
|
if (RunLoop == IntPtr.Zero)
|
||||||
|
RunLoop = CF.CFRunLoopGetCurrent();
|
||||||
|
if (RunLoop == IntPtr.Zero)
|
||||||
|
{
|
||||||
|
Debug.Print("[Error] No CFRunLoop found for {0}", GetType().FullName);
|
||||||
|
throw new InvalidOperationException();
|
||||||
|
}
|
||||||
|
CF.CFRetain(RunLoop);
|
||||||
|
|
||||||
HandleDeviceAdded = DeviceAdded;
|
HandleDeviceAdded = DeviceAdded;
|
||||||
HandleDeviceRemoved = DeviceRemoved;
|
HandleDeviceRemoved = DeviceRemoved;
|
||||||
HandleDeviceValueReceived = DeviceValueReceived;
|
HandleDeviceValueReceived = DeviceValueReceived;
|
||||||
|
@ -1776,6 +1786,11 @@ namespace OpenTK.Platform.MacOS
|
||||||
NativeMethods.IOHIDManagerClose(hidmanager, IOOptionBits.Zero);
|
NativeMethods.IOHIDManagerClose(hidmanager, IOOptionBits.Zero);
|
||||||
hidmanager = IntPtr.Zero;
|
hidmanager = IntPtr.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (RunLoop != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
CF.CFRelease(RunLoop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue