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:
parent
8448b3ee10
commit
208f99f4a6
|
@ -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"]];
|
||||||
|
|
|
@ -116,31 +116,37 @@ 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
|
||||||
ioService = IOHIDDeviceGetService(hidDeviceRef);
|
if (IsOSXVersionSupported(10, 6, 0))
|
||||||
if (ioService != MACH_PORT_NULL)
|
|
||||||
{
|
{
|
||||||
IOObjectRetain(ioService);
|
ioService = IOHIDDeviceGetService(hidDeviceRef);
|
||||||
}
|
if (ioService != MACH_PORT_NULL)
|
||||||
#else
|
|
||||||
ioService = MACH_PORT_NULL;
|
|
||||||
|
|
||||||
CFMutableDictionaryRef matchingDict = IOServiceMatching(kIOHIDDeviceKey);
|
|
||||||
if (matchingDict)
|
|
||||||
{
|
|
||||||
CFStringRef locationKey = CFSTR(kIOHIDLocationIDKey);
|
|
||||||
CFTypeRef deviceLocation = IOHIDDeviceGetProperty(hidDeviceRef, locationKey);
|
|
||||||
if (deviceLocation != NULL)
|
|
||||||
{
|
{
|
||||||
CFDictionaryAddValue(matchingDict, locationKey, deviceLocation);
|
IOObjectRetain(ioService);
|
||||||
|
|
||||||
//This eats a reference to matchingDict, so we don't need a separate release.
|
|
||||||
//The result, meanwhile, has a reference count of 1 and must be released by the caller.
|
|
||||||
ioService = IOServiceGetMatchingService(kIOMasterPortDefault, matchingDict);
|
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
else
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
ioService = MACH_PORT_NULL;
|
||||||
|
|
||||||
|
CFMutableDictionaryRef matchingDict = IOServiceMatching(kIOHIDDeviceKey);
|
||||||
|
if (matchingDict)
|
||||||
{
|
{
|
||||||
CFRelease(matchingDict);
|
CFStringRef locationKey = CFSTR(kIOHIDLocationIDKey);
|
||||||
|
CFTypeRef deviceLocation = IOHIDDeviceGetProperty(hidDeviceRef, locationKey);
|
||||||
|
if (deviceLocation != NULL)
|
||||||
|
{
|
||||||
|
CFDictionaryAddValue(matchingDict, locationKey, deviceLocation);
|
||||||
|
|
||||||
|
//This eats a reference to matchingDict, so we don't need a separate release.
|
||||||
|
//The result, meanwhile, has a reference count of 1 and must be released by the caller.
|
||||||
|
ioService = IOServiceGetMatchingService(kIOMasterPortDefault, matchingDict);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CFRelease(matchingDict);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue