diff --git a/Source/Core/InputCommon/ControllerInterface/Win32/Win32.cpp b/Source/Core/InputCommon/ControllerInterface/Win32/Win32.cpp index 2e69fc80e6..79584913cf 100644 --- a/Source/Core/InputCommon/ControllerInterface/Win32/Win32.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Win32/Win32.cpp @@ -10,8 +10,6 @@ #include -#include - #include "Common/Flag.h" #include "Common/Logging/Log.h" #include "InputCommon/ControllerInterface/DInput/DInput.h" @@ -20,7 +18,6 @@ #pragma comment(lib, "OneCoreUAP.Lib") -static std::mutex s_populate_mutex; // TODO is this really needed? static Common::Flag s_first_populate_devices_asked; static HCMNOTIFICATION s_notify_handle; @@ -52,7 +49,6 @@ _Pre_satisfies_(EventDataSize >= sizeof(CM_NOTIFY_EVENT_DATA)) static DWORD CALL // listen for it. if (s_first_populate_devices_asked.IsSet()) { - std::lock_guard lk_population(s_populate_mutex); // TODO: we could easily use the message passed alongside this event, which tells // whether a device was added or removed, to avoid removing old, still connected, devices g_controller_interface.PlatformPopulateDevices([&] { @@ -96,17 +92,18 @@ InputBackend::InputBackend(ControllerInterface* controller_interface) void InputBackend::PopulateDevices() { - std::lock_guard lk_population(s_populate_mutex); - s_first_populate_devices_asked.Set(); - ciface::DInput::PopulateDevices(GetHWND()); - ciface::XInput::PopulateDevices(); - ciface::WGInput::PopulateDevices(); + g_controller_interface.PlatformPopulateDevices([this] { + s_first_populate_devices_asked.Set(); + ciface::DInput::PopulateDevices(GetHWND()); + ciface::XInput::PopulateDevices(); + ciface::WGInput::PopulateDevices(); + }); } void InputBackend::HandleWindowChange() { - std::lock_guard lk_population(s_populate_mutex); - ciface::DInput::ChangeWindow(GetHWND()); + g_controller_interface.PlatformPopulateDevices( + [this] { ciface::DInput::ChangeWindow(GetHWND()); }); } InputBackend::~InputBackend()