From 4176cc77e1c3627ceee7b849195f026efc1bf9ca Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Tue, 21 Jan 2020 18:52:58 -0600 Subject: InputCommon/ControllerInterface: Make devices mutex recursive so RemoveDevice can be used within UpdateInput. --- .../InputCommon/ControllerInterface/ControllerInterface.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp') diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp index 130f0f357a..faa6de185e 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -93,7 +93,7 @@ void ControllerInterface::RefreshDevices() return; { - std::lock_guard lk(m_devices_mutex); + std::lock_guard lk(m_devices_mutex); m_devices.clear(); } @@ -131,6 +131,7 @@ void ControllerInterface::RefreshDevices() #ifdef CIFACE_USE_DUALSHOCKUDPCLIENT ciface::DualShockUDPClient::PopulateDevices(); #endif + ciface::Wiimote::PopulateDevices(); m_is_populating_devices = false; InvokeDevicesChangedCallbacks(); @@ -146,7 +147,7 @@ void ControllerInterface::Shutdown() m_is_init = false; { - std::lock_guard lk(m_devices_mutex); + std::lock_guard lk(m_devices_mutex); for (const auto& d : m_devices) { @@ -193,7 +194,7 @@ void ControllerInterface::AddDevice(std::shared_ptr device return; { - std::lock_guard lk(m_devices_mutex); + std::lock_guard lk(m_devices_mutex); const auto is_id_in_use = [&device, this](int id) { return std::any_of(m_devices.begin(), m_devices.end(), [&device, &id](const auto& d) { @@ -229,7 +230,7 @@ void ControllerInterface::AddDevice(std::shared_ptr device void ControllerInterface::RemoveDevice(std::function callback) { { - std::lock_guard lk(m_devices_mutex); + std::lock_guard lk(m_devices_mutex); auto it = std::remove_if(m_devices.begin(), m_devices.end(), [&callback](const auto& dev) { if (callback(dev.get())) { @@ -251,7 +252,7 @@ void ControllerInterface::UpdateInput() // Don't block the UI or CPU thread (to avoid a short but noticeable frame drop) if (m_devices_mutex.try_lock()) { - std::lock_guard lk(m_devices_mutex, std::adopt_lock); + std::lock_guard lk(m_devices_mutex, std::adopt_lock); for (const auto& d : m_devices) d->UpdateInput(); } -- cgit v1.2.3