diff options
| author | Matthew Parlane <parlane@gmail.com> | 2016-06-26 00:17:08 +1200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-06-26 00:17:08 +1200 |
| commit | a7448271a9203aea26f05f62b75e43c5e5860e98 (patch) | |
| tree | 5e43d6ee5fcfbe74a6bacf1eba81ee0a7a44fa14 /Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp | |
| parent | 2f9a911c540473bb6cea5a9891a6a281aa2f3750 (diff) | |
| parent | 9b075556ea826699800d9478d1eed3a80368c348 (diff) | |
Merge pull request #3892 from leoetlino/ciface-synchronisation
ControllerInterface: Add synchronisation
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp index 55643ece5f..b36387162d 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -55,31 +55,31 @@ void ControllerInterface::Initialize(void* const hwnd) m_hwnd = hwnd; #ifdef CIFACE_USE_DINPUT - ciface::DInput::Init(m_devices, (HWND)hwnd); + ciface::DInput::Init((HWND)hwnd); #endif #ifdef CIFACE_USE_XINPUT - ciface::XInput::Init(m_devices); + ciface::XInput::Init(); #endif #ifdef CIFACE_USE_XLIB - ciface::Xlib::Init(m_devices, hwnd); + ciface::Xlib::Init(hwnd); #ifdef CIFACE_USE_X11_XINPUT2 - ciface::XInput2::Init(m_devices, hwnd); + ciface::XInput2::Init(hwnd); #endif #endif #ifdef CIFACE_USE_OSX - ciface::OSX::Init(m_devices, hwnd); + ciface::OSX::Init(hwnd); #endif #ifdef CIFACE_USE_SDL - ciface::SDL::Init(m_devices); + ciface::SDL::Init(); #endif #ifdef CIFACE_USE_ANDROID - ciface::Android::Init(m_devices); + ciface::Android::Init(); #endif #ifdef CIFACE_USE_EVDEV - ciface::evdev::Init(m_devices); + ciface::evdev::Init(); #endif #ifdef CIFACE_USE_PIPES - ciface::Pipes::Init(m_devices); + ciface::Pipes::Init(); #endif m_is_init = true; @@ -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 @@ -139,6 +141,12 @@ void ControllerInterface::Shutdown() m_is_init = false; } +void ControllerInterface::AddDevice(ciface::Core::Device* device) +{ + std::lock_guard<std::mutex> lk(m_devices_mutex); + m_devices.push_back(device); +} + // // UpdateInput // @@ -146,6 +154,7 @@ void ControllerInterface::Shutdown() // void ControllerInterface::UpdateInput() { + std::lock_guard<std::mutex> lk(m_devices_mutex); for (ciface::Core::Device* d : m_devices) d->UpdateInput(); } |
