summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp33
1 files changed, 18 insertions, 15 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
index 442e5502fa..d1ee02370a 100644
--- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
@@ -64,7 +64,7 @@ void ControllerInterface::Initialize(const WindowSystemInfo& wsi)
// nothing needed for OSX and Quartz
#endif
#ifdef CIFACE_USE_SDL
- ciface::SDL::Init();
+ m_input_backends.emplace_back(ciface::SDL::CreateInputBackend(this));
#endif
#ifdef CIFACE_USE_ANDROID
// nothing needed
@@ -181,9 +181,6 @@ void ControllerInterface::RefreshDevices(RefreshReason reason)
ciface::Quartz::PopulateDevices(m_wsi.render_window);
}
#endif
-#ifdef CIFACE_USE_SDL
- ciface::SDL::PopulateDevices();
-#endif
#ifdef CIFACE_USE_ANDROID
ciface::Android::PopulateDevices();
#endif
@@ -197,6 +194,9 @@ void ControllerInterface::RefreshDevices(RefreshReason reason)
ciface::DualShockUDPClient::PopulateDevices();
#endif
+ for (auto& backend : m_input_backends)
+ backend->PopulateDevices();
+
WiimoteReal::PopulateDevices();
if (m_populating_devices_counter.fetch_sub(1) == 1)
@@ -242,9 +242,6 @@ void ControllerInterface::Shutdown()
ciface::OSX::DeInit();
ciface::Quartz::DeInit();
#endif
-#ifdef CIFACE_USE_SDL
- ciface::SDL::DeInit();
-#endif
#ifdef CIFACE_USE_ANDROID
// nothing needed
#endif
@@ -255,6 +252,8 @@ void ControllerInterface::Shutdown()
ciface::DualShockUDPClient::DeInit();
#endif
+ m_input_backends.clear();
+
// Make sure no devices had been added within Shutdown() in the time
// between checking they checked atomic m_is_init bool and we changed it.
// We couldn't have locked m_devices_population_mutex for the whole Shutdown()
@@ -384,15 +383,19 @@ void ControllerInterface::UpdateInput()
// TODO: if we are an emulation input channel, we should probably always lock
// Prefer outdated values over blocking UI or CPU thread (avoids short but noticeable frame drop)
- if (m_devices_mutex.try_lock())
+ if (!m_devices_mutex.try_lock())
+ return;
+
+ std::lock_guard lk(m_devices_mutex, std::adopt_lock);
+
+ for (auto& backend : m_input_backends)
+ backend->UpdateInput();
+
+ for (const auto& d : m_devices)
{
- std::lock_guard lk(m_devices_mutex, std::adopt_lock);
- for (const auto& d : m_devices)
- {
- // Theoretically we could avoid updating input on devices that don't have any references to
- // them, but in practice a few devices types could break in different ways, so we don't
- d->UpdateInput();
- }
+ // Theoretically we could avoid updating input on devices that don't have any references to
+ // them, but in practice a few devices types could break in different ways, so we don't
+ d->UpdateInput();
}
}