Skip to content

Commit

Permalink
Merge pull request #19 from Electronicks/master
Browse files Browse the repository at this point in the history
Fix to chords adding themselves multiple times to the stack
  • Loading branch information
JibbSmart authored Apr 25, 2020
2 parents fb62dd2 + fd56317 commit c39595d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions JoyShockMapper/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -1067,6 +1069,10 @@ class JoyShock {
handleButtonChange(softIndex, true);
}
}
else
{
handleButtonChange(softIndex, false);
}
break;
case DstState::PressStart:
if (pressed <= trigger_threshold) {
Expand Down

0 comments on commit c39595d

Please sign in to comment.