Cocoa Port: Fix a bug where HID devices would fail to be detected on startup when running on macOS High Sierra.

This commit is contained in:
rogerman 2018-08-13 23:33:24 -07:00
parent 8448b3ee10
commit 208f99f4a6
2 changed files with 28 additions and 22 deletions

View File

@ -2238,6 +2238,7 @@
[inputManager setMappingsWithMappings:userMappings]; [inputManager setMappingsWithMappings:userMappings];
[[inputManager hidManager] setDeviceListController:inputDeviceListController]; [[inputManager hidManager] setDeviceListController:inputDeviceListController];
[[inputManager hidManager] setRunLoop:[NSRunLoop currentRunLoop]];
// Set the microphone settings per user preferences. // Set the microphone settings per user preferences.
[[cdsCore cdsController] setHardwareMicMute:[[NSUserDefaults standardUserDefaults] boolForKey:@"Microphone_HardwareMicMute"]]; [[cdsCore cdsController] setHardwareMicMute:[[NSUserDefaults standardUserDefaults] boolForKey:@"Microphone_HardwareMicMute"]];

View File

@ -116,13 +116,18 @@ static NSDictionary *hidUsageTable = nil;
CFRelease(elementArray); CFRelease(elementArray);
// Set up force feedback. // Set up force feedback.
#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5 #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
if (IsOSXVersionSupported(10, 6, 0))
{
ioService = IOHIDDeviceGetService(hidDeviceRef); ioService = IOHIDDeviceGetService(hidDeviceRef);
if (ioService != MACH_PORT_NULL) if (ioService != MACH_PORT_NULL)
{ {
IOObjectRetain(ioService); IOObjectRetain(ioService);
} }
}
else
#else #else
{
ioService = MACH_PORT_NULL; ioService = MACH_PORT_NULL;
CFMutableDictionaryRef matchingDict = IOServiceMatching(kIOHIDDeviceKey); CFMutableDictionaryRef matchingDict = IOServiceMatching(kIOHIDDeviceKey);
@ -143,6 +148,7 @@ static NSDictionary *hidUsageTable = nil;
CFRelease(matchingDict); CFRelease(matchingDict);
} }
} }
}
#endif #endif
ffDevice = NULL; ffDevice = NULL;
@ -865,7 +871,6 @@ void HandleQueueValueAvailableCallback(void *inContext, IOReturn inResult, void
CFRelease(cfGenericControllerMatcher); CFRelease(cfGenericControllerMatcher);
spinlockRunLoop = OS_SPINLOCK_INIT; spinlockRunLoop = OS_SPINLOCK_INIT;
[self setRunLoop:[NSRunLoop currentRunLoop]];
IOReturn result = IOHIDManagerOpen(hidManagerRef, kIOHIDOptionsTypeNone); IOReturn result = IOHIDManagerOpen(hidManagerRef, kIOHIDOptionsTypeNone);
if (result != kIOReturnSuccess) if (result != kIOReturnSuccess)