From 1d816f8f267ff468478a4b8ff423b2dd0c734654 Mon Sep 17 00:00:00 2001 From: Filoppi Date: Sat, 15 May 2021 12:10:00 +0300 Subject: ControllerInterface: make real Wiimote use PlatformPopulateDevices() --- .../ControllerInterface/ControllerInterface.cpp | 2 +- .../ControllerInterface/Wiimote/WiimoteController.cpp | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'Source/Core/InputCommon/ControllerInterface') diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp index b84e8af571..cb4eae1472 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -185,7 +185,7 @@ void ControllerInterface::RefreshDevices(RefreshReason reason) ciface::DualShockUDPClient::PopulateDevices(); #endif - WiimoteReal::ProcessWiimotePool(); + WiimoteReal::PopulateDevices(); m_devices_mutex.unlock(); diff --git a/Source/Core/InputCommon/ControllerInterface/Wiimote/WiimoteController.cpp b/Source/Core/InputCommon/ControllerInterface/Wiimote/WiimoteController.cpp index eaa56ef449..dfd329f5e0 100644 --- a/Source/Core/InputCommon/ControllerInterface/Wiimote/WiimoteController.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Wiimote/WiimoteController.cpp @@ -128,13 +128,17 @@ void ReleaseDevices(std::optional count) // Remove up to "count" remotes (or all of them if nullopt). // Real wiimotes will be added to the pool. - g_controller_interface.RemoveDevice([&](const Core::Device* device) { - if (device->GetSource() != SOURCE_NAME || count == removed_devices) - return false; - - ++removed_devices; - return true; - }); + // Make sure to force the device removal immediately (as they are shared ptrs and + // they could be kept alive, preventing us from re-creating the device) + g_controller_interface.RemoveDevice( + [&](const Core::Device* device) { + if (device->GetSource() != SOURCE_NAME || count == removed_devices) + return false; + + ++removed_devices; + return true; + }, + true); } Device::Device(std::unique_ptr wiimote) : m_wiimote(std::move(wiimote)) -- cgit v1.2.3