mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
ControllerInterface: Remove OSX window handle
also make it more thread safe (avoid rare deadlock) and fix it trying to add devices before the CI has init
This commit is contained in:
@@ -6,8 +6,7 @@
|
||||
|
||||
namespace ciface::OSX
|
||||
{
|
||||
void Init(void* window);
|
||||
void PopulateDevices(void* window);
|
||||
void Init();
|
||||
void DeInit();
|
||||
|
||||
void DeviceElementDebugPrint(const void*, void*);
|
||||
|
||||
@@ -135,8 +135,6 @@ static void DeviceDebugPrint(IOHIDDeviceRef device)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void* g_window;
|
||||
|
||||
static std::string GetDeviceRefName(IOHIDDeviceRef inIOHIDDeviceRef)
|
||||
{
|
||||
const NSString* name = reinterpret_cast<const NSString*>(
|
||||
@@ -172,10 +170,8 @@ static void DeviceMatchingCallback(void* inContext, IOReturn inResult, void* inS
|
||||
}
|
||||
}
|
||||
|
||||
void Init(void* window)
|
||||
void Init()
|
||||
{
|
||||
g_window = window;
|
||||
|
||||
HIDManager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
|
||||
if (!HIDManager)
|
||||
ERROR_LOG_FMT(CONTROLLERINTERFACE, "Failed to create HID Manager reference");
|
||||
@@ -210,19 +206,17 @@ void Init(void* window)
|
||||
});
|
||||
}
|
||||
|
||||
void PopulateDevices(void* window)
|
||||
{
|
||||
DeInit();
|
||||
Init(window);
|
||||
}
|
||||
|
||||
void DeInit()
|
||||
{
|
||||
s_stopper.Signal();
|
||||
s_hotplug_thread.join();
|
||||
if (HIDManager)
|
||||
{
|
||||
s_stopper.Signal();
|
||||
s_hotplug_thread.join();
|
||||
|
||||
// This closes all devices as well
|
||||
IOHIDManagerClose(HIDManager, kIOHIDOptionsTypeNone);
|
||||
CFRelease(HIDManager);
|
||||
// This closes all devices as well
|
||||
IOHIDManagerClose(HIDManager, kIOHIDOptionsTypeNone);
|
||||
CFRelease(HIDManager);
|
||||
HIDManager = nullptr;
|
||||
}
|
||||
}
|
||||
} // namespace ciface::OSX
|
||||
|
||||
Reference in New Issue
Block a user