summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
diff options
context:
space:
mode:
authorLéo Lam <leo@innovatetechnologi.es>2016-07-15 11:34:18 +0200
committerLéo Lam <leo@innovatetechnologi.es>2016-07-29 17:18:40 +0200
commit3926db624d5ab2f959e67eb2369f1fe5f0f9543a (patch)
treea9abfe0e141b8c6eb64c96cb344cbca887cc117b /Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
parent93f5df419521171c11e16d6a8ff84b9d0d8fd6c0 (diff)
ControllerInterface: Don't block on UpdateInput()
Changes UpdateInput() to skip if we can't lock the mutex, instead of potentially blocking the CPU thread and causing a short but noticeable frame drop.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
index cf726698f1..9c7a08428e 100644
--- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
@@ -175,9 +175,13 @@ void ControllerInterface::RemoveDevice(std::function<bool(const ciface::Core::De
//
void ControllerInterface::UpdateInput()
{
- std::lock_guard<std::mutex> lk(m_devices_mutex);
- for (const auto& d : m_devices)
- d->UpdateInput();
+ // Don't block the UI or CPU thread (to avoid a short but noticeable frame drop)
+ if (m_devices_mutex.try_lock())
+ {
+ std::lock_guard<std::mutex> lk(m_devices_mutex, std::adopt_lock);
+ for (const auto& d : m_devices)
+ d->UpdateInput();
+ }
}
//