From c3d242b519c7b68c08bf2224561bca3d77ac1c65 Mon Sep 17 00:00:00 2001 From: Nicolas Lessard Date: Sun, 28 Mar 2021 21:51:10 -0400 Subject: [PATCH] Bugfix turbo presses not releasing --- JoyShockMapper/src/main.cpp | 39 +++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/JoyShockMapper/src/main.cpp b/JoyShockMapper/src/main.cpp index d04e638..74442b9 100644 --- a/JoyShockMapper/src/main.cpp +++ b/JoyShockMapper/src/main.cpp @@ -764,6 +764,24 @@ bool Mapping::AddMapping(KeyCode key, EventModifier evtMod, ActionModifier actMo } BtnEvent applyEvt, releaseEvt; + switch (actMod) + { + case ActionModifier::Toggle: + apply = bind(&DigitalButton::ApplyButtonToggle, placeholders::_1, key, apply, release); + release = OnEventAction(); + break; + case ActionModifier::Instant: + { + OnEventAction action2 = bind(&DigitalButton::RegisterInstant, placeholders::_1, applyEvt); + apply = bind(&Mapping::RunBothActions, placeholders::_1, apply, action2); + releaseEvt = BtnEvent::OnInstantRelease; + } + break; + case ActionModifier::INVALID: + return false; + // None applies no modification... Hey! + } + switch (evtMod) { case EventModifier::StartPress: @@ -786,30 +804,13 @@ bool Mapping::AddMapping(KeyCode key, EventModifier evtMod, ActionModifier actMo case EventModifier::TurboPress: applyEvt = BtnEvent::OnTurbo; releaseEvt = BtnEvent::OnTurbo; + InsertEventMapping(BtnEvent::OnRelease, release); // On turbo you also need to clear the turbo on release break; default: // EventModifier::INVALID or None return false; } - switch (actMod) - { - case ActionModifier::Toggle: - apply = bind(&DigitalButton::ApplyButtonToggle, placeholders::_1, key, apply, release); - release = OnEventAction(); - break; - case ActionModifier::Instant: - { - OnEventAction action2 = bind(&DigitalButton::RegisterInstant, placeholders::_1, applyEvt); - apply = bind(&Mapping::RunBothActions, placeholders::_1, apply, action2); - releaseEvt = BtnEvent::OnInstantRelease; - } - break; - case ActionModifier::INVALID: - return false; - // None applies no modification... Hey! - } - - // Insert release first because in turbo's case apply and release are the same but we want release to apply first + // Insert release first because in turbo's case apply and release are the same but we want release to happen first InsertEventMapping(releaseEvt, release); InsertEventMapping(applyEvt, apply); return true;