From 7714a7ccd9080819828fbeb1dfa27be70b80e07d Mon Sep 17 00:00:00 2001 From: Aaron M Date: Wed, 30 Oct 2019 18:20:41 +1300 Subject: [PATCH] Add new rumble code inplace of old simple rumble never used so no need to keep it --- Common Files/Game.h | 2 +- DllMain.cpp | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Common Files/Game.h b/Common Files/Game.h index 206f03f..85a8d27 100644 --- a/Common Files/Game.h +++ b/Common Files/Game.h @@ -6,7 +6,7 @@ struct EffectTriggers { void(*Spring)(double strength); void(*Friction)(double strength); void(*Sine)(UINT16 period, UINT16 fadePeriod, double strength); - void(*Rumble)(double strength, double length); + void(*Rumble)(double lowfrequency, double highfrequency, double length); void(*LeftRight)(double smallstrength, double largestrength, double length); void(*LeftRightDevice2)(double smallstrength, double largestrength, double length); void(*Springi)(double strength); diff --git a/DllMain.cpp b/DllMain.cpp index 404a36c..632c630 100644 --- a/DllMain.cpp +++ b/DllMain.cpp @@ -1566,11 +1566,19 @@ void TriggerLeftRightDevice2Effect(double smallstrength, double largestrength, d } } -void TriggerRumbleEffect(double strength, double length) +void TriggerRumbleEffect(double lowfrequency, double highfrequency, double length) { if (EnableRumble == 1) { - SDL_HapticRumblePlay(haptic, strength, length); + DWORD minForceLow = (DWORD)(lowfrequency > 0.001 ? (configMinForce / 100.0 * 65535.0) : 0); + DWORD minForceHigh = (DWORD)(highfrequency > 0.001 ? (configMinForce / 100.0 * 65535.0) : 0); + DWORD maxForce = (DWORD)(configMaxForce / 100.0 * 65535.0); + DWORD rangeLow = maxForce - minForceLow; + DWORD rangeHigh = maxForce - minForceHigh; + DWORD LowMotor = (DWORD)(lowfrequency * rangeLow + minForceLow); + DWORD HighMotor = (DWORD)(highfrequency * rangeHigh + minForceHigh); + + SDL_JoystickRumble(GameController, LowMotor, HighMotor, length); } }