mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-16 11:06:49 +01:00
Fixed crash on Mac OS X 10.10 and earlier
This commit is contained in:
parent
012217f069
commit
6d67c98e70
@ -195,6 +195,11 @@ static IOHIDManagerRef s_hidManager = NULL;
|
|||||||
static void
|
static void
|
||||||
HIDCallback(void *context, IOReturn result, void *sender, IOHIDValueRef value)
|
HIDCallback(void *context, IOReturn result, void *sender, IOHIDValueRef value)
|
||||||
{
|
{
|
||||||
|
if (context != s_hidManager) {
|
||||||
|
/* An old callback, ignore it (related to bug 2157 below) */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
IOHIDElementRef elem = IOHIDValueGetElement(value);
|
IOHIDElementRef elem = IOHIDValueGetElement(value);
|
||||||
if (IOHIDElementGetUsagePage(elem) != kHIDPage_KeyboardOrKeypad
|
if (IOHIDElementGetUsagePage(elem) != kHIDPage_KeyboardOrKeypad
|
||||||
|| IOHIDElementGetUsage(elem) != kHIDUsage_KeyboardCapsLock) {
|
|| IOHIDElementGetUsage(elem) != kHIDUsage_KeyboardCapsLock) {
|
||||||
@ -232,13 +237,14 @@ QuitHIDCallback()
|
|||||||
if (!s_hidManager) {
|
if (!s_hidManager) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IOHIDManagerUnscheduleFromRunLoop(s_hidManager, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
|
|
||||||
IOHIDManagerRegisterInputValueCallback(s_hidManager, NULL, NULL);
|
|
||||||
IOHIDManagerClose(s_hidManager, 0);
|
|
||||||
|
|
||||||
#if 0 /* Releasing here causes a crash on Mac OS X 10.10 and earlier,
|
#if 0 /* Releasing here causes a crash on Mac OS X 10.10 and earlier,
|
||||||
* so just leak it for now. See bug 2157 for details.
|
* so just leak it for now. See bug 2157 for details.
|
||||||
*/
|
*/
|
||||||
|
IOHIDManagerUnscheduleFromRunLoop(s_hidManager, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
|
||||||
|
IOHIDManagerRegisterInputValueCallback(s_hidManager, NULL, NULL);
|
||||||
|
IOHIDManagerClose(s_hidManager, 0);
|
||||||
|
|
||||||
CFRelease(s_hidManager);
|
CFRelease(s_hidManager);
|
||||||
#endif
|
#endif
|
||||||
s_hidManager = NULL;
|
s_hidManager = NULL;
|
||||||
@ -267,7 +273,7 @@ InitHIDCallback()
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
IOHIDManagerSetDeviceMatchingMultiple(s_hidManager, matches);
|
IOHIDManagerSetDeviceMatchingMultiple(s_hidManager, matches);
|
||||||
IOHIDManagerRegisterInputValueCallback(s_hidManager, HIDCallback, NULL);
|
IOHIDManagerRegisterInputValueCallback(s_hidManager, HIDCallback, s_hidManager);
|
||||||
IOHIDManagerScheduleWithRunLoop(s_hidManager, CFRunLoopGetMain(), kCFRunLoopDefaultMode);
|
IOHIDManagerScheduleWithRunLoop(s_hidManager, CFRunLoopGetMain(), kCFRunLoopDefaultMode);
|
||||||
if (IOHIDManagerOpen(s_hidManager, kIOHIDOptionsTypeNone) == kIOReturnSuccess) {
|
if (IOHIDManagerOpen(s_hidManager, kIOHIDOptionsTypeNone) == kIOReturnSuccess) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
Loading…
Reference in New Issue
Block a user