From 179ae009df693736ba46fa04ff1bc01f3ab8c891 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Wed, 12 Oct 2022 20:14:13 -0400 Subject: [PATCH] Improve logic and fix for old compilers --- Source/controls/controller.cpp | 6 ++---- Source/options.cpp | 14 ++++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Source/controls/controller.cpp b/Source/controls/controller.cpp index d24e9631d..6703c7036 100644 --- a/Source/controls/controller.cpp +++ b/Source/controls/controller.cpp @@ -75,10 +75,8 @@ bool IsControllerButtonPressed(ControllerButton button) bool IsControllerButtonComboPressed(ControllerButtonCombo combo) { - bool comboPressed = IsControllerButtonPressed(combo.button); - if (combo.modifier != ControllerButton_NONE) - comboPressed = comboPressed && IsControllerButtonPressed(combo.modifier); - return comboPressed; + return IsControllerButtonPressed(combo.button) + && (combo.modifier == ControllerButton_NONE || IsControllerButtonPressed(combo.modifier)); } bool HandleControllerAddedOrRemovedEvent(const SDL_Event &event) diff --git a/Source/options.cpp b/Source/options.cpp index cda18c9bd..568e21384 100644 --- a/Source/options.cpp +++ b/Source/options.cpp @@ -1494,15 +1494,17 @@ void PadmapperOptions::Action::LoadFromIni(string_view category) std::string modName; std::string buttonName; - for (string_view name : SplitByChar(result.data(), '+')) { - modName = buttonName; - buttonName = name; - } - - if (buttonName.empty()) { + auto parts = SplitByChar(result.data(), '+'); + auto it = parts.begin(); + if (it == parts.end()) { SetValue(ControllerButtonCombo {}); return; } + buttonName = std::string(*it); + if (++it != parts.end()) { + modName = std::move(buttonName); + buttonName = std::string(*it); + } ControllerButtonCombo input {}; if (!modName.empty()) {