mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 05:40:01 -06: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:
@ -6,8 +6,19 @@
|
||||
#include <memory>
|
||||
#include "Common/Common.h"
|
||||
|
||||
// This should be called before calling GetState() or State() on a control reference
|
||||
// to prevent a race condition.
|
||||
// This is a recursive mutex because UpdateReferences is recursive.
|
||||
static std::recursive_mutex s_get_state_mutex;
|
||||
std::unique_lock<std::recursive_mutex> ControllerEmu::GetStateLock()
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> lock(s_get_state_mutex);
|
||||
return lock;
|
||||
}
|
||||
|
||||
void ControllerEmu::UpdateReferences(ControllerInterface& devi)
|
||||
{
|
||||
auto lock = ControllerEmu::GetStateLock();
|
||||
for (auto& ctrlGroup : groups)
|
||||
{
|
||||
for (auto& control : ctrlGroup->controls)
|
||||
|
Reference in New Issue
Block a user