diff options
Diffstat (limited to 'src/input_common/input_engine.cpp')
| -rw-r--r-- | src/input_common/input_engine.cpp | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/src/input_common/input_engine.cpp b/src/input_common/input_engine.cpp index a4a07d4ac..9c17ca4f7 100644 --- a/src/input_common/input_engine.cpp +++ b/src/input_common/input_engine.cpp | |||
| @@ -10,41 +10,31 @@ namespace InputCommon { | |||
| 10 | 10 | ||
| 11 | void InputEngine::PreSetController(const PadIdentifier& identifier) { | 11 | void InputEngine::PreSetController(const PadIdentifier& identifier) { |
| 12 | std::lock_guard lock{mutex}; | 12 | std::lock_guard lock{mutex}; |
| 13 | if (!controller_list.contains(identifier)) { | 13 | controller_list.try_emplace(identifier); |
| 14 | controller_list.insert_or_assign(identifier, ControllerData{}); | ||
| 15 | } | ||
| 16 | } | 14 | } |
| 17 | 15 | ||
| 18 | void InputEngine::PreSetButton(const PadIdentifier& identifier, int button) { | 16 | void InputEngine::PreSetButton(const PadIdentifier& identifier, int button) { |
| 19 | std::lock_guard lock{mutex}; | 17 | std::lock_guard lock{mutex}; |
| 20 | ControllerData& controller = controller_list.at(identifier); | 18 | ControllerData& controller = controller_list.at(identifier); |
| 21 | if (!controller.buttons.contains(button)) { | 19 | controller.buttons.try_emplace(button, false); |
| 22 | controller.buttons.insert_or_assign(button, false); | ||
| 23 | } | ||
| 24 | } | 20 | } |
| 25 | 21 | ||
| 26 | void InputEngine::PreSetHatButton(const PadIdentifier& identifier, int button) { | 22 | void InputEngine::PreSetHatButton(const PadIdentifier& identifier, int button) { |
| 27 | std::lock_guard lock{mutex}; | 23 | std::lock_guard lock{mutex}; |
| 28 | ControllerData& controller = controller_list.at(identifier); | 24 | ControllerData& controller = controller_list.at(identifier); |
| 29 | if (!controller.hat_buttons.contains(button)) { | 25 | controller.hat_buttons.try_emplace(button, u8{0}); |
| 30 | controller.hat_buttons.insert_or_assign(button, u8{0}); | ||
| 31 | } | ||
| 32 | } | 26 | } |
| 33 | 27 | ||
| 34 | void InputEngine::PreSetAxis(const PadIdentifier& identifier, int axis) { | 28 | void InputEngine::PreSetAxis(const PadIdentifier& identifier, int axis) { |
| 35 | std::lock_guard lock{mutex}; | 29 | std::lock_guard lock{mutex}; |
| 36 | ControllerData& controller = controller_list.at(identifier); | 30 | ControllerData& controller = controller_list.at(identifier); |
| 37 | if (!controller.axes.contains(axis)) { | 31 | controller.axes.try_emplace(axis, 0.0f); |
| 38 | controller.axes.insert_or_assign(axis, 0.0f); | ||
| 39 | } | ||
| 40 | } | 32 | } |
| 41 | 33 | ||
| 42 | void InputEngine::PreSetMotion(const PadIdentifier& identifier, int motion) { | 34 | void InputEngine::PreSetMotion(const PadIdentifier& identifier, int motion) { |
| 43 | std::lock_guard lock{mutex}; | 35 | std::lock_guard lock{mutex}; |
| 44 | ControllerData& controller = controller_list.at(identifier); | 36 | ControllerData& controller = controller_list.at(identifier); |
| 45 | if (!controller.motions.contains(motion)) { | 37 | controller.motions.try_emplace(motion); |
| 46 | controller.motions.insert_or_assign(motion, BasicMotion{}); | ||
| 47 | } | ||
| 48 | } | 38 | } |
| 49 | 39 | ||
| 50 | void InputEngine::SetButton(const PadIdentifier& identifier, int button, bool value) { | 40 | void InputEngine::SetButton(const PadIdentifier& identifier, int button, bool value) { |