From 313913cb3825d757130d4f879bd86ec1caf65032 Mon Sep 17 00:00:00 2001 From: Aaron M Date: Sat, 5 Oct 2019 10:48:41 +1300 Subject: [PATCH] revert code --- DllMain.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/DllMain.cpp b/DllMain.cpp index 89a3485..8e725d9 100644 --- a/DllMain.cpp +++ b/DllMain.cpp @@ -1120,6 +1120,21 @@ void TriggerConstantEffect(int direction, double strength) int effectId = direction == effectConst.DIRECTION_FROM_LEFT ? effects.effect_right_id : effects.effect_left_id; std::string effectHash = std::to_string(effectId) + "_" + std::to_string(strength) + "_" + std::to_string(direction); + // if the effect is the same as the last effect that was sent AND enough time hasn't elapsed, do nothing + if (effectHash.compare(lastConstantEffectHash) == 0 && elapsedTime < configFeedbackLength) { + return; // same effect, do nothing. + } + + //TODO: investigate if we need this + if (configResetFeedback || strength <= 0.001) { + SDL_HapticStopEffect(haptic, effects.effect_id); + if (strength <= 0.01) { + timeOfLastConstantEffect = now; + lastConstantEffectHash = effectHash; + return; + } + } + // if no strength, we do nothing if (strength <= 0.001) { return; @@ -1173,6 +1188,9 @@ void TriggerConstantEffect(int direction, double strength) hlp.log((char *)(std::to_string(level)).c_str()); SDL_HapticUpdateEffect(haptic, effects.effect_id, &tempEffect); SDL_HapticRunEffect(haptic, effects.effect_id, 1); + + timeOfLastConstantEffect = now; + lastConstantEffectHash = effectHash; } void TriggerFrictionEffectWithDefaultOption(double strength, bool isDefault) {