From f476808851aae8b250fffc048cc331c5ff39358c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?DOTTEL=20Ga=C3=ABl?= Date: Sun, 6 Apr 2025 23:44:51 +0200 Subject: [PATCH] Fix button_to_string when str is empty --- .../Controllers/NintendoSwitch_ControllerState.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SerialPrograms/Source/NintendoSwitch/Controllers/NintendoSwitch_ControllerState.cpp b/SerialPrograms/Source/NintendoSwitch/Controllers/NintendoSwitch_ControllerState.cpp index cbe2be147c..85b0133214 100644 --- a/SerialPrograms/Source/NintendoSwitch/Controllers/NintendoSwitch_ControllerState.cpp +++ b/SerialPrograms/Source/NintendoSwitch/Controllers/NintendoSwitch_ControllerState.cpp @@ -34,12 +34,12 @@ std::string button_to_string(Button button){ if (button & BUTTON_LEFT_SR) str += "Left-SR"; if (button & BUTTON_RIGHT_SL) str += "Right-SL"; if (button & BUTTON_RIGHT_SR) str += "Right-SR"; - if (str.back() == ' '){ - str.pop_back(); - } if (str.empty()){ str = "none"; } + if (str.back() == ' '){ + str.pop_back(); + } return str; } std::string dpad_to_string(DpadPosition dpad){