mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-11 16:49:28 +02:00
ControllerInterface: Add RemoveDevice()
This adds RemoveDevice() to ControllerInterface, fixes ExpressionParser and some other code to support device removals without crashing, and adds an IsValid() method to Device, to prepare for hotplugging.
This commit is contained in:
@ -160,6 +160,14 @@ void ControllerInterface::AddDevice(std::shared_ptr<ciface::Core::Device> device
|
||||
m_devices.emplace_back(std::move(device));
|
||||
}
|
||||
|
||||
void ControllerInterface::RemoveDevice(std::function<bool(const ciface::Core::Device*)> callback)
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(m_devices_mutex);
|
||||
m_devices.erase(std::remove_if(m_devices.begin(), m_devices.end(),
|
||||
[&callback](const auto& dev) { return callback(dev.get()); }),
|
||||
m_devices.end());
|
||||
}
|
||||
|
||||
//
|
||||
// UpdateInput
|
||||
//
|
||||
|
Reference in New Issue
Block a user