diff options
author | Lioncash <mathew1800@gmail.com> | 2021-12-13 15:50:48 +0100 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2021-12-13 15:57:51 +0100 |
commit | 4d4a23447688030402dc1499db8a827065154136 (patch) | |
tree | 992c2f49a830b961016bcf54b0c925b19e220703 /src | |
parent | input_engine: Remove left-over namespace qualifiers (diff) | |
download | yuzu-4d4a23447688030402dc1499db8a827065154136.tar yuzu-4d4a23447688030402dc1499db8a827065154136.tar.gz yuzu-4d4a23447688030402dc1499db8a827065154136.tar.bz2 yuzu-4d4a23447688030402dc1499db8a827065154136.tar.lz yuzu-4d4a23447688030402dc1499db8a827065154136.tar.xz yuzu-4d4a23447688030402dc1499db8a827065154136.tar.zst yuzu-4d4a23447688030402dc1499db8a827065154136.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/input_common/input_engine.cpp | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/src/input_common/input_engine.cpp b/src/input_common/input_engine.cpp index fce914348..a4a07d4ac 100644 --- a/src/input_common/input_engine.cpp +++ b/src/input_common/input_engine.cpp @@ -104,68 +104,76 @@ void InputEngine::SetMotion(const PadIdentifier& identifier, int motion, const B bool InputEngine::GetButton(const PadIdentifier& identifier, int button) const { std::lock_guard lock{mutex}; - if (!controller_list.contains(identifier)) { + const auto controller_iter = controller_list.find(identifier); + if (controller_iter == controller_list.cend()) { LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(), identifier.pad, identifier.port); return false; } - ControllerData controller = controller_list.at(identifier); - if (!controller.buttons.contains(button)) { + const ControllerData& controller = controller_iter->second; + const auto button_iter = controller.buttons.find(button); + if (button_iter == controller.buttons.cend()) { LOG_ERROR(Input, "Invalid button {}", button); return false; } - return controller.buttons.at(button); + return button_iter->second; } bool InputEngine::GetHatButton(const PadIdentifier& identifier, int button, u8 direction) const { std::lock_guard lock{mutex}; - if (!controller_list.contains(identifier)) { + const auto controller_iter = controller_list.find(identifier); + if (controller_iter == controller_list.cend()) { LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(), identifier.pad, identifier.port); return false; } - ControllerData controller = controller_list.at(identifier); - if (!controller.hat_buttons.contains(button)) { + const ControllerData& controller = controller_iter->second; + const auto hat_iter = controller.hat_buttons.find(button); + if (hat_iter == controller.hat_buttons.cend()) { LOG_ERROR(Input, "Invalid hat button {}", button); return false; } - return (controller.hat_buttons.at(button) & direction) != 0; + return (hat_iter->second & direction) != 0; } f32 InputEngine::GetAxis(const PadIdentifier& identifier, int axis) const { std::lock_guard lock{mutex}; - if (!controller_list.contains(identifier)) { + const auto controller_iter = controller_list.find(identifier); + if (controller_iter == controller_list.cend()) { LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(), identifier.pad, identifier.port); return 0.0f; } - ControllerData controller = controller_list.at(identifier); - if (!controller.axes.contains(axis)) { + const ControllerData& controller = controller_iter->second; + const auto axis_iter = controller.axes.find(axis); + if (axis_iter == controller.axes.cend()) { LOG_ERROR(Input, "Invalid axis {}", axis); return 0.0f; } - return controller.axes.at(axis); + return axis_iter->second; } BatteryLevel InputEngine::GetBattery(const PadIdentifier& identifier) const { std::lock_guard lock{mutex}; - if (!controller_list.contains(identifier)) { + const auto controller_iter = controller_list.find(identifier); + if (controller_iter == controller_list.cend()) { LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(), identifier.pad, identifier.port); return BatteryLevel::Charging; } - ControllerData controller = controller_list.at(identifier); + const ControllerData& controller = controller_iter->second; return controller.battery; } BasicMotion InputEngine::GetMotion(const PadIdentifier& identifier, int motion) const { std::lock_guard lock{mutex}; - if (!controller_list.contains(identifier)) { + const auto controller_iter = controller_list.find(identifier); + if (controller_iter == controller_list.cend()) { LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.Format(), identifier.pad, identifier.port); return {}; } - ControllerData controller = controller_list.at(identifier); + const ControllerData& controller = controller_iter->second; return controller.motions.at(motion); } |