mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-07-17 19:57:25 +00:00
[Mac] Explicitly close removed devices
Devices are now explicitly closed when they a DeviceRemoved event is received. Additionally, exceptions are no longer allowed to escape into unmanaged code, where they might crash the runtime.
This commit is contained in:
parent
d12643cf44
commit
57c2f89038
|
@ -179,6 +179,8 @@ namespace OpenTK.Platform.MacOS
|
|||
CGEventType type,
|
||||
IntPtr @event,
|
||||
IntPtr refcon)
|
||||
{
|
||||
try
|
||||
{
|
||||
CursorState.SetIsConnected(true);
|
||||
|
||||
|
@ -228,6 +230,12 @@ namespace OpenTK.Platform.MacOS
|
|||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Do not let any exceptions escape into unmanaged code!
|
||||
Debug.Print(e.ToString());
|
||||
}
|
||||
|
||||
return @event;
|
||||
}
|
||||
|
@ -336,6 +344,7 @@ namespace OpenTK.Platform.MacOS
|
|||
{
|
||||
NativeMethods.IOHIDDeviceRegisterInputValueCallback(device, IntPtr.Zero, IntPtr.Zero);
|
||||
NativeMethods.IOHIDDeviceUnscheduleFromRunLoop(device, RunLoop, InputLoopMode);
|
||||
NativeMethods.IOHIDDeviceClose(device, IOOptionBits.Zero);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -1093,7 +1102,7 @@ namespace OpenTK.Platform.MacOS
|
|||
[DllImport(hid)]
|
||||
public static extern void IOHIDManagerSetDeviceMatching(
|
||||
IOHIDManagerRef manager,
|
||||
CFDictionaryRef matching) ;
|
||||
CFDictionaryRef matching);
|
||||
|
||||
[DllImport(hid)]
|
||||
public static extern IOReturn IOHIDManagerOpen(
|
||||
|
@ -1105,6 +1114,11 @@ namespace OpenTK.Platform.MacOS
|
|||
IOHIDDeviceRef manager,
|
||||
IOOptionBits opts);
|
||||
|
||||
[DllImport(hid)]
|
||||
public static extern IOReturn IOHIDDeviceClose(
|
||||
IOHIDDeviceRef device,
|
||||
IOOptionBits options);
|
||||
|
||||
[DllImport(hid)]
|
||||
public static extern CFTypeRef IOHIDDeviceGetProperty(
|
||||
IOHIDDeviceRef device,
|
||||
|
|
Loading…
Reference in a new issue