Make controller button code thread-safe (#405)

* Refactor spinlock to meet Lockable requirements
* Input: Refactor button code and make it thread-safe
This commit is contained in:
Exzap 2022-10-23 15:47:42 +02:00 committed by GitHub
parent c40466f3a8
commit 028b3f7992
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 311 additions and 220 deletions

View file

@ -279,13 +279,9 @@ bool EmulatedController::is_mapping_down(uint64 mapping) const
const auto it = m_mappings.find(mapping);
if (it != m_mappings.cend())
{
if (const auto controller = it->second.controller.lock()) {
auto& buttons=controller->get_state().buttons;
auto buttonState=buttons.find(it->second.button);
return buttonState!=buttons.end() && buttonState->second;
}
if (const auto controller = it->second.controller.lock())
return controller->get_state().buttons.GetButtonState(it->second.button);
}
return false;
}