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.
This commit is contained in:
parent
93f5df4195
commit
3926db624d
|
@ -175,9 +175,13 @@ void ControllerInterface::RemoveDevice(std::function<bool(const ciface::Core::De
|
||||||
//
|
//
|
||||||
void ControllerInterface::UpdateInput()
|
void ControllerInterface::UpdateInput()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lk(m_devices_mutex);
|
// Don't block the UI or CPU thread (to avoid a short but noticeable frame drop)
|
||||||
for (const auto& d : m_devices)
|
if (m_devices_mutex.try_lock())
|
||||||
d->UpdateInput();
|
{
|
||||||
|
std::lock_guard<std::mutex> lk(m_devices_mutex, std::adopt_lock);
|
||||||
|
for (const auto& d : m_devices)
|
||||||
|
d->UpdateInput();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue