Skip to content
Permalink
Browse files
Merge pull request #9326 from Subject38/wiimote_deadlock
InputCommon: Fix callback dispatch deadlock
  • Loading branch information
leoetlino committed Dec 15, 2020
2 parents 2c2ec16 + 00ec25d commit ed15645
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
@@ -140,6 +140,19 @@ void ControllerInterface::RefreshDevices()
InvokeDevicesChangedCallbacks();
}

void ControllerInterface::PlatformPopulateDevices(std::function<void()> callback)
{
if (!m_is_init)
return;

m_is_populating_devices = true;

callback();

m_is_populating_devices = false;
InvokeDevicesChangedCallbacks();
}

// Remove all devices and call library cleanup functions
void ControllerInterface::Shutdown()
{
@@ -50,6 +50,7 @@ class ControllerInterface : public ciface::Core::DeviceContainer
void Shutdown();
void AddDevice(std::shared_ptr<ciface::Core::Device> device);
void RemoveDevice(std::function<bool(const ciface::Core::Device*)> callback);
void PlatformPopulateDevices(std::function<void()> callback);
bool IsInit() const { return m_is_init; }
void UpdateInput();

@@ -28,8 +28,10 @@ static LRESULT CALLBACK WindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARA
{
if (message == WM_INPUT_DEVICE_CHANGE)
{
ciface::DInput::PopulateDevices(s_hwnd);
ciface::XInput::PopulateDevices();
g_controller_interface.PlatformPopulateDevices([] {
ciface::DInput::PopulateDevices(s_hwnd);
ciface::XInput::PopulateDevices();
});
s_done_populating.Set();
}

0 comments on commit ed15645

Please sign in to comment.