mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-12-13 04:36:59 +00:00
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:
parent
c40466f3a8
commit
028b3f7992
28 changed files with 311 additions and 220 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#include "input/api/Keyboard/KeyboardController.h"
|
||||
#include <boost/container/small_vector.hpp>
|
||||
|
||||
#include "input/api/Keyboard/KeyboardController.h"
|
||||
#include "gui/guiWrapper.h"
|
||||
|
||||
KeyboardController::KeyboardController()
|
||||
|
|
@ -51,7 +52,9 @@ ControllerState KeyboardController::raw_state()
|
|||
ControllerState result{};
|
||||
if (g_window_info.app_active)
|
||||
{
|
||||
g_window_info.get_keystates(result.buttons);
|
||||
boost::container::small_vector<uint32, 16> pressedKeys;
|
||||
g_window_info.iter_keystates([&pressedKeys](const std::pair<const uint32, bool>& keyState) { if (keyState.second) pressedKeys.emplace_back(keyState.first); });
|
||||
result.buttons.SetPressedButtons(pressedKeys);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue