diff options
| author | Léo Lam <leo@innovatetechnologi.es> | 2016-06-12 17:31:41 +0200 |
|---|---|---|
| committer | Léo Lam <leo@innovatetechnologi.es> | 2016-06-25 13:46:53 +0200 |
| commit | d3e2ae35ff853d115aca077eaa10b88114ef7c7c (patch) | |
| tree | ef48e2c922c685a99fbfe602b408623475092763 /Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp | |
| parent | fd29e5c4cc26cd853a03ac7b0e08b367b7070c84 (diff) | |
ControllerInterface: Add synchronisation
Since we may have to add/access devices from different threads, this
adds synchronisation to anything that touches m_devices.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp index c139d3b787..b36387162d 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -104,6 +104,8 @@ void ControllerInterface::Shutdown() if (!m_is_init) return; + std::lock_guard<std::mutex> lk(m_devices_mutex); + for (ciface::Core::Device* d : m_devices) { // Set outputs to ZERO before destroying device @@ -141,6 +143,7 @@ void ControllerInterface::Shutdown() void ControllerInterface::AddDevice(ciface::Core::Device* device) { + std::lock_guard<std::mutex> lk(m_devices_mutex); m_devices.push_back(device); } @@ -151,6 +154,7 @@ void ControllerInterface::AddDevice(ciface::Core::Device* device) // void ControllerInterface::UpdateInput() { + std::lock_guard<std::mutex> lk(m_devices_mutex); for (ciface::Core::Device* d : m_devices) d->UpdateInput(); } |
