From fd56317089acefa4a6c77adfb38b6a45defafdde Mon Sep 17 00:00:00 2001 From: Nicolas Lessard Date: Fri, 24 Apr 2020 11:58:01 -0400 Subject: [PATCH] Fix to chords adding themselves multiple times to the stack --- JoyShockMapper/src/main.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/JoyShockMapper/src/main.cpp b/JoyShockMapper/src/main.cpp index 284e36d..6561d29 100644 --- a/JoyShockMapper/src/main.cpp +++ b/JoyShockMapper/src/main.cpp @@ -722,16 +722,18 @@ class JoyShock { } void handleButtonChange(int index, bool pressed) { - if(pressed) - btnCommon.chordStack.push_front(index); // Always push at the fromt to make it a stack - else { - auto foundChord = std::find(btnCommon.chordStack.begin(), btnCommon.chordStack.end(), index); + auto foundChord = std::find(btnCommon.chordStack.begin(), btnCommon.chordStack.end(), index); + if (!pressed) + { if (foundChord != btnCommon.chordStack.end()) { // The chord is released btnCommon.chordStack.erase(foundChord); } } + else if (foundChord == btnCommon.chordStack.end()) { + btnCommon.chordStack.push_front(index); // Always push at the fromt to make it a stack + } switch (buttons[index]._btnState) { @@ -1067,6 +1069,10 @@ class JoyShock { handleButtonChange(softIndex, true); } } + else + { + handleButtonChange(softIndex, false); + } break; case DstState::PressStart: if (pressed <= trigger_threshold) {