Merge IOKit hotplug support patch [Sintendo]

Merge libretro Super Game Boy support improvement patch [fr500]
This commit is contained in:
byuu
2019-10-31 09:19:27 +09:00
parent 1c1cfd086b
commit 2b9a22e1d8
4 changed files with 118 additions and 77 deletions

View File

@@ -101,8 +101,6 @@ struct InputJoypadIOKit {
}
auto poll(vector<shared_pointer<HID::Device>>& devices) -> void {
detectDevices(); //hotplug support
for(auto& jp : joypads) {
IOHIDDeviceRef device = jp.device;
@@ -181,13 +179,13 @@ struct InputJoypadIOKit {
IOHIDManagerSetDeviceMatchingMultiple(manager, matcher);
IOHIDManagerRegisterDeviceMatchingCallback(manager, deviceMatchingCallback, this);
IOHIDManagerRegisterDeviceRemovalCallback(manager, deviceRemovalCallback, this);
IOHIDManagerScheduleWithRunLoop(manager, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
if(IOHIDManagerOpen(manager, kIOHIDOptionsTypeNone) != kIOReturnSuccess) {
releaseManager();
return false;
}
detectDevices();
return true;
}
@@ -261,14 +259,6 @@ private:
CFRelease(pageNumber), CFRelease(usageNumber);
return dict;
}
auto detectDevices() -> void {
CFRunLoopRef runLoop = CFRunLoopGetCurrent();
CFStringRef runLoopMode = CFSTR("rubyJoypadIOKit");
IOHIDManagerScheduleWithRunLoop(manager, runLoop, runLoopMode);
while(CFRunLoopRunInMode(runLoopMode, 0, true) == kCFRunLoopRunHandledSource);
IOHIDManagerUnscheduleFromRunLoop(manager, runLoop, runLoopMode);
}
};
auto deviceMatchingCallback(void* context, IOReturn result, void* sender, IOHIDDeviceRef device) -> void {