diff options
| author | Pierre Bourdon <delroth@gmail.com> | 2016-07-29 17:43:49 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-07-29 17:43:49 +0200 |
| commit | e0cbb9d1ae6f35b4b44a8e1ed99e8a710c36a7d3 (patch) | |
| tree | 7e0fff192b12dbddbf9c39d133ee433662727fa4 /Source/Core/InputCommon/ControllerEmu.cpp | |
| parent | fc85d8036f1bab0963b3a64278f8e4ea157b6dcf (diff) | |
| parent | 135641404af9c52e433ef28dba4f86fa208f4365 (diff) | |
Merge pull request #3890 from leoetlino/evdev-hotplug
evdev: Add hotplug support
Diffstat (limited to 'Source/Core/InputCommon/ControllerEmu.cpp')
| -rw-r--r-- | Source/Core/InputCommon/ControllerEmu.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Source/Core/InputCommon/ControllerEmu.cpp b/Source/Core/InputCommon/ControllerEmu.cpp index 117184c8db..b3b13b796a 100644 --- a/Source/Core/InputCommon/ControllerEmu.cpp +++ b/Source/Core/InputCommon/ControllerEmu.cpp @@ -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) |
