From d04e44a29d86288026d81256071c6a30af6d94c7 Mon Sep 17 00:00:00 2001 From: pinkimo Date: Mon, 23 Sep 2019 19:15:12 +0200 Subject: [PATCH 01/10] Fix WMMT5 FFB Fix friction effect --- Config/FFBPlugin.ini | 7 +++- DllMain.cpp | 75 +++++++++++++++++++++++++++++++++++++++-- Game Files/WMMT5.cpp | 80 ++++++++++++++++++++++++++------------------ 3 files changed, 127 insertions(+), 35 deletions(-) diff --git a/Config/FFBPlugin.ini b/Config/FFBPlugin.ini index 8603cde..84bf6b5 100644 --- a/Config/FFBPlugin.ini +++ b/Config/FFBPlugin.ini @@ -247,7 +247,7 @@ Gear6=99 [WMMT5] GameId=9 MinForce=0 -MaxForce=35 +MaxForce=100 DefaultCentering=0 FeedbackLength=80 Logging=0 @@ -255,6 +255,11 @@ AlternativeMinForceLeft=0 AlternativeMaxForceLeft=-35 AlternativeMinForceRight=0 AlternativeMaxForceRight=35 +SpringStrength=100 +FrictionStrength=20 +CollisionsStrength=50 +TiresSlipStrength=100 +HighhSpeedVibrationsStrength=50; [Mame 0199 32bit] GameId=4 diff --git a/DllMain.cpp b/DllMain.cpp index 7f54484..ac3ab94 100644 --- a/DllMain.cpp +++ b/DllMain.cpp @@ -1091,6 +1091,7 @@ std::chrono::milliseconds timeOfLastSpringEffect = duration_cast(s std::string lastConstantEffectHash = ""; std::string lastFrictionEffectHash = ""; std::string lastSineEffectHash = ""; +double lastSineEffectStrength = 0; std::string lastSpringEffectHash = ""; void TriggerConstantEffect(int direction, double strength) { @@ -1187,6 +1188,10 @@ void TriggerConstantEffect(int direction, double strength) SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0); SHORT range = maxForce - minForce; SHORT level = (SHORT)(strength * range + minForce); + if (level < 0) + { + level = 32767; + } tempEffect.constant.level = level; hlp.log((char *)(std::to_string(level)).c_str()); SDL_HapticUpdateEffect(haptic, effects.effect_id, &tempEffect); @@ -1224,6 +1229,7 @@ void TriggerFrictionEffectWithDefaultOption(double strength, bool isDefault) { SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect)); tempEffect.type = SDL_HAPTIC_FRICTION; tempEffect.condition.type = SDL_HAPTIC_FRICTION; + tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN; tempEffect.condition.delay = 0; tempEffect.condition.length = isDefault ? 0xFFFFFFFF : configFeedbackLength; tempEffect.condition.left_sat[0] = 0xFFFF; @@ -1233,6 +1239,10 @@ void TriggerFrictionEffectWithDefaultOption(double strength, bool isDefault) { SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0); SHORT range = maxForce - minForce; SHORT coeff = (SHORT)(strength * range + minForce); + if (coeff < 0) + { + coeff = 32767; + } tempEffect.condition.left_coeff[0] = (short)(coeff); tempEffect.condition.right_coeff[0] = (short)(coeff); @@ -1259,6 +1269,10 @@ void TriggerInertiaEffect(double strength) SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0); SHORT range = maxForce - minForce; SHORT coeff = (SHORT)(strength * range + minForce); + if (coeff < 0) + { + coeff = 32767; + } tempEffect.condition.left_coeff[0] = (short)(coeff); tempEffect.condition.right_coeff[0] = (short)(coeff); @@ -1272,16 +1286,28 @@ void TriggerInertiaEffect(double strength) void TriggerTriangleEffect(double strength, double length) { + int direction = 1; + if (strength <= -0.001) { + strength *= -1; + direction = -1; + } + SDL_HapticEffect tempEffect; SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect)); tempEffect.type = SDL_HAPTIC_TRIANGLE; tempEffect.condition.type = SDL_HAPTIC_TRIANGLE; tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN; + tempEffect.condition.direction.dir[0] = direction; + tempEffect.condition.direction.dir[1] = 0; //Y Position tempEffect.periodic.period = 500; SHORT minForce = (SHORT)(strength > 0.001 ? (configMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0. SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0); SHORT range = maxForce - minForce; SHORT power = (SHORT)(strength * range + minForce); + if (power < 0) + { + power = 32767; + } tempEffect.periodic.magnitude = power; tempEffect.periodic.length = length; tempEffect.periodic.attack_length = 1000; @@ -1306,6 +1332,11 @@ void TriggerDamperEffect(double strength) SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0); SHORT range = maxForce - minForce; SHORT coeff = (SHORT)(strength * range + minForce); + if (coeff < 0) + { + coeff = 32767; + } + tempEffect.condition.left_coeff[0] = (short)(coeff); tempEffect.condition.right_coeff[0] = (short)(coeff); tempEffect.condition.left_sat[0] = (short)(coeff) * 10; @@ -1327,11 +1358,19 @@ void TriggerRampEffect(double start,double end,double length) SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0); SHORT range = maxForce - minForce; SHORT start1 = (SHORT)(start * range + minForce); + if (start1 < 0) + { + start1 = 32767; + } SHORT minForce2 = (SHORT)(end > 0.001 ? (configMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0. SHORT maxForce2 = (SHORT)(configMaxForce / 100.0 * 32767.0); SHORT range2 = maxForce - minForce; SHORT start2 = (SHORT)(end * range + minForce); - tempEffect.ramp.delay = 0; + if (start2 < 0) + { + start2 = 32767; + } + tempEffect.ramp.delay = 0; tempEffect.ramp.start = start1; tempEffect.ramp.end = -start2; @@ -1351,6 +1390,10 @@ void TriggerSawtoothUpEffect(double strength, double length) SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0); SHORT range = maxForce - minForce; SHORT power = (SHORT)(strength * range + minForce); + if (power < 0) + { + power = 32767; + } tempEffect.periodic.magnitude = power; tempEffect.periodic.length = length; tempEffect.periodic.attack_length = 1000; @@ -1371,6 +1414,10 @@ void TriggerSawtoothDownEffect(double strength, double length) { SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0); SHORT range = maxForce - minForce; SHORT power = (SHORT)(strength * range + minForce); + if (power < 0) + { + power = 32767; + } tempEffect.periodic.magnitude = power; tempEffect.periodic.length = length; tempEffect.periodic.attack_length = 1000; @@ -1396,12 +1443,23 @@ void TriggerSineEffect(UINT16 period, UINT16 fadePeriod, double strength) return; // same effect, do nothing. } + int direction = 1; + if (strength <= -0.001) { + strength *= -1; + direction = -1; + } + + if (strength < (lastSineEffectStrength / 2.0) && elapsedTime < configFeedbackLength) { + return; // we prevent interruption of previous vibrations by a vibration a lot less strong. + } + // TODO: investigate if we need this if (configResetFeedback || strength <= 0.001) { SDL_HapticStopEffect(haptic, effects.effect_sine_id); if (strength <= 0.01) { timeOfLastSineEffect = now; lastSineEffectHash = effectHash; + lastSineEffectStrength = strength; return; } } @@ -1411,7 +1469,7 @@ void TriggerSineEffect(UINT16 period, UINT16 fadePeriod, double strength) hlp.log("Doing sine..."); tempEffect.type = SDL_HAPTIC_SINE; tempEffect.periodic.direction.type = SDL_HAPTIC_CARTESIAN; - tempEffect.periodic.direction.dir[0] = 1; + tempEffect.periodic.direction.dir[0] = direction; tempEffect.constant.direction.dir[1] = 0; //Y Position tempEffect.periodic.period = period; @@ -1419,6 +1477,10 @@ void TriggerSineEffect(UINT16 period, UINT16 fadePeriod, double strength) SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0); SHORT range = maxForce - minForce; SHORT magnitude = (SHORT)(strength * range + minForce); + if (magnitude < 0) + { + magnitude = 32767; + } tempEffect.periodic.magnitude = (SHORT)(magnitude); tempEffect.periodic.length = configFeedbackLength; @@ -1433,6 +1495,7 @@ void TriggerSineEffect(UINT16 period, UINT16 fadePeriod, double strength) timeOfLastSineEffect = now; lastSineEffectHash = effectHash; + lastSineEffectStrength = strength; } void TriggerSpringEffectWithDefaultOption(double strength, bool isDefault) { @@ -1471,6 +1534,10 @@ void TriggerSpringEffectWithDefaultOption(double strength, bool isDefault) { SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0); SHORT range = maxForce - minForce; SHORT coeff = (SHORT)(strength * range + minForce); + if (coeff < 0) + { + coeff = 32767; + } tempEffect.condition.left_coeff[0] = (short)(coeff); tempEffect.condition.right_coeff[0] = (short)(coeff); @@ -1505,6 +1572,10 @@ void TriggerSpringEffectInfinite(double strength) SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0); SHORT range = maxForce - minForce; SHORT coeff = (SHORT)(strength * range + minForce); + if (coeff < 0) + { + coeff = 32767; + } tempEffect.condition.left_coeff[0] = (short)(coeff); tempEffect.condition.right_coeff[0] = (short)(coeff); diff --git a/Game Files/WMMT5.cpp b/Game Files/WMMT5.cpp index 378e5e6..ef170cc 100644 --- a/Game Files/WMMT5.cpp +++ b/Game Files/WMMT5.cpp @@ -14,57 +14,73 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>. #include #include "WMMT5.h" +wchar_t* settingsWMMT5 = TEXT(".\\FFBPlugin.ini"); +int SpringStrengthWMMT5 = GetPrivateProfileInt(TEXT("Settings"), TEXT("SpringStrength"), 0, settingsWMMT5); +int FrictionStrengthWMMT5 = GetPrivateProfileInt(TEXT("Settings"), TEXT("FrictionStrength"), 0, settingsWMMT5); +int CollisionsStrengthWMMT5 = GetPrivateProfileInt(TEXT("Settings"), TEXT("CollisionsStrength"), 0, settingsWMMT5); +int TiresSlipStrengthWMMT5 = GetPrivateProfileInt(TEXT("Settings"), TEXT("TiresSlipStrength"), 0, settingsWMMT5); +int HighhSpeedVibrationsStrengthWMMT5 = GetPrivateProfileInt(TEXT("Settings"), TEXT("HighhSpeedVibrationsStrength"), 0, settingsWMMT5); + void WMMT5::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) { - float roll = helpers->ReadFloat32(0x196F194, /* isRelativeOffset*/ true); - float friction = helpers->ReadFloat32(0x196F18C, /* isRelativeOffset*/ true); - float sine = helpers->ReadFloat32(0x196F188, /* isRelativeOffset*/ true); + float spring = helpers->ReadFloat32(0x196F18C, /* isRelativeOffset*/ true); + float friction = helpers->ReadFloat32(0x196F190, /* isRelativeOffset*/ true); + float collisions = helpers->ReadFloat32(0x196F194, /* isRelativeOffset*/ true); + float tiresSlip = helpers->ReadFloat32(0x196F188, /* isRelativeOffset*/ true); helpers->log("got value: "); - std::string ffs = std::to_string(roll); - helpers->log((char *)ffs.c_str()); + std::string ffs = "spring: " + std::to_string(spring); + helpers->log((char*)ffs.c_str()); + ffs = "friction: " + std::to_string(friction); + helpers->log((char*)ffs.c_str()); + ffs = "collisions: " + std::to_string(collisions); + helpers->log((char*)ffs.c_str()); + ffs = "tires slip: " + std::to_string(tiresSlip); + helpers->log((char*)ffs.c_str()); + if (0 < spring) { - //Trigger Spring the entire time like real cabinet - double percentForce = 0.7; - triggers->Springi(percentForce); + double percentForce = (1.0 * spring) * SpringStrengthWMMT5 / 100.0; + triggers->Spring(percentForce); } - - if (0 < roll) + if (0 < friction) { - helpers->log("moving wheel right"); - double percentForce = (1.0 - roll); + double percentForce = (1.0 - friction) * FrictionStrengthWMMT5 / 100.0; + triggers->Friction(percentForce); + } + if (0 < collisions) + { + helpers->log("collision on the left"); + double percentForce = (1.0 * collisions) * CollisionsStrengthWMMT5 / 100.0; double percentLength = (250); // direction from right => makes wheel turn left triggers->LeftRight(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - +// triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); + triggers->Sine(100, 120, percentForce); } - else if (0 > roll) + else if (0 > collisions) { - helpers->log("moving wheel left"); - double percentForce = (roll + 1.0); + helpers->log("collision on the right"); + double percentForce = (-1.0 * collisions) * CollisionsStrengthWMMT5 / 100.0; double percentLength = (250); // direction from left => makes wheel turn right triggers->LeftRight(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); +// triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); + double percentForce2 = (1.0 * collisions) * CollisionsStrengthWMMT5 / 100.0; + triggers->Sine(100, 120, percentForce2); } - else if (0 < friction) + if (0 < tiresSlip) { - helpers->log("moving wheel right"); - double percentForce = (0.7 - friction); - triggers->Friction(percentForce); + helpers->log("tires slip left"); + bool highSpeedVibrations = tiresSlip < 0.06; + double percentForce = (-1.0 * tiresSlip) * (highSpeedVibrations ? HighhSpeedVibrationsStrengthWMMT5 : TiresSlipStrengthWMMT5) / 100.0; + triggers->Sine(highSpeedVibrations ? 100 : 120, 120, percentForce); } - else if (0 < sine) + else if (0 > tiresSlip) { - helpers->log("moving wheel right"); - double percentForce = (0.6 - sine); - triggers->Sine(120, 120, percentForce); - } - else if (0 > sine) - { - helpers->log("moving wheel left"); - double percentForce = (sine + 0.6); - triggers->Sine(120, 120, percentForce); + helpers->log("tires slip right"); + bool highSpeedVibrations = tiresSlip > -0.06; + double percentForce = (-1.0 * tiresSlip) * (highSpeedVibrations ? HighhSpeedVibrationsStrengthWMMT5 : TiresSlipStrengthWMMT5) / 100.0; + triggers->Sine(highSpeedVibrations ? 100 : 120, 120, percentForce); } } \ No newline at end of file From a35d6e880cf0b613747a2917fe685e7139cb8d01 Mon Sep 17 00:00:00 2001 From: pinkimo Date: Mon, 23 Sep 2019 19:19:44 +0200 Subject: [PATCH 02/10] Fix --- Game Files/WMMT5.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Game Files/WMMT5.cpp b/Game Files/WMMT5.cpp index ef170cc..764bf08 100644 --- a/Game Files/WMMT5.cpp +++ b/Game Files/WMMT5.cpp @@ -44,7 +44,7 @@ void WMMT5::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers } if (0 < friction) { - double percentForce = (1.0 - friction) * FrictionStrengthWMMT5 / 100.0; + double percentForce = (1.0 * friction) * FrictionStrengthWMMT5 / 100.0; triggers->Friction(percentForce); } if (0 < collisions) From 983735a7fbf3bac666a04f99759b715062bd94c5 Mon Sep 17 00:00:00 2001 From: pinkimo Date: Mon, 23 Sep 2019 19:37:15 +0200 Subject: [PATCH 03/10] Fix --- Game Files/WMMT5.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Game Files/WMMT5.cpp b/Game Files/WMMT5.cpp index 764bf08..af1f034 100644 --- a/Game Files/WMMT5.cpp +++ b/Game Files/WMMT5.cpp @@ -66,8 +66,8 @@ void WMMT5::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers triggers->LeftRight(0, percentForce, percentLength); // triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - double percentForce2 = (1.0 * collisions) * CollisionsStrengthWMMT5 / 100.0; - triggers->Sine(100, 120, percentForce2); + percentForce = (1.0 * collisions) * CollisionsStrengthWMMT5 / 100.0; + triggers->Sine(100, 120, percentForce); } if (0 < tiresSlip) { From ad402e7a9ac0b203dcc2ebf6be35d2ca691332af Mon Sep 17 00:00:00 2001 From: pinkimo Date: Mon, 23 Sep 2019 19:41:56 +0200 Subject: [PATCH 04/10] Fix --- Config/FFBPlugin.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Config/FFBPlugin.ini b/Config/FFBPlugin.ini index 84bf6b5..48174d6 100644 --- a/Config/FFBPlugin.ini +++ b/Config/FFBPlugin.ini @@ -252,9 +252,9 @@ DefaultCentering=0 FeedbackLength=80 Logging=0 AlternativeMinForceLeft=0 -AlternativeMaxForceLeft=-35 +AlternativeMaxForceLeft=-100 AlternativeMinForceRight=0 -AlternativeMaxForceRight=35 +AlternativeMaxForceRight=100 SpringStrength=100 FrictionStrength=20 CollisionsStrength=50 From 19243c1bad26475ca2d1cf4125809f870532ed2e Mon Sep 17 00:00:00 2001 From: pinkimo Date: Tue, 24 Sep 2019 00:45:35 +0200 Subject: [PATCH 05/10] Fine tuning --- Config/FFBPlugin.ini | 5 +++-- Game Files/WMMT5.cpp | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Config/FFBPlugin.ini b/Config/FFBPlugin.ini index 48174d6..f7c2cd1 100644 --- a/Config/FFBPlugin.ini +++ b/Config/FFBPlugin.ini @@ -257,9 +257,10 @@ AlternativeMinForceRight=0 AlternativeMaxForceRight=100 SpringStrength=100 FrictionStrength=20 -CollisionsStrength=50 +CollisionsStrength=30 TiresSlipStrength=100 -HighhSpeedVibrationsStrength=50; +HighhSpeedVibrationsStrength=50 +LimitBetweenHighSpeedVibrationsAndTiresSlip=75 [Mame 0199 32bit] GameId=4 diff --git a/Game Files/WMMT5.cpp b/Game Files/WMMT5.cpp index af1f034..0f6e927 100644 --- a/Game Files/WMMT5.cpp +++ b/Game Files/WMMT5.cpp @@ -20,6 +20,7 @@ int FrictionStrengthWMMT5 = GetPrivateProfileInt(TEXT("Settings"), TEXT("Frictio int CollisionsStrengthWMMT5 = GetPrivateProfileInt(TEXT("Settings"), TEXT("CollisionsStrength"), 0, settingsWMMT5); int TiresSlipStrengthWMMT5 = GetPrivateProfileInt(TEXT("Settings"), TEXT("TiresSlipStrength"), 0, settingsWMMT5); int HighhSpeedVibrationsStrengthWMMT5 = GetPrivateProfileInt(TEXT("Settings"), TEXT("HighhSpeedVibrationsStrength"), 0, settingsWMMT5); +int LimitBetweenHighSpeedVibrationsAndTiresSlipWMMT5 = GetPrivateProfileInt(TEXT("Settings"), TEXT("LimitBetweenHighSpeedVibrationsAndTiresSlip"), 0, settingsWMMT5); void WMMT5::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) { @@ -72,14 +73,14 @@ void WMMT5::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers if (0 < tiresSlip) { helpers->log("tires slip left"); - bool highSpeedVibrations = tiresSlip < 0.06; + bool highSpeedVibrations = (1.0 * tiresSlip) < (LimitBetweenHighSpeedVibrationsAndTiresSlipWMMT5 / 1000.0); double percentForce = (-1.0 * tiresSlip) * (highSpeedVibrations ? HighhSpeedVibrationsStrengthWMMT5 : TiresSlipStrengthWMMT5) / 100.0; triggers->Sine(highSpeedVibrations ? 100 : 120, 120, percentForce); } else if (0 > tiresSlip) { helpers->log("tires slip right"); - bool highSpeedVibrations = tiresSlip > -0.06; + bool highSpeedVibrations = (-1.0 * tiresSlip) < (LimitBetweenHighSpeedVibrationsAndTiresSlipWMMT5 / 1000.0); double percentForce = (-1.0 * tiresSlip) * (highSpeedVibrations ? HighhSpeedVibrationsStrengthWMMT5 : TiresSlipStrengthWMMT5) / 100.0; triggers->Sine(highSpeedVibrations ? 100 : 120, 120, percentForce); } From 51e6cd269044be6897d8a732eb5133f4a00663ec Mon Sep 17 00:00:00 2001 From: pinkimo Date: Thu, 26 Sep 2019 02:16:37 +0200 Subject: [PATCH 06/10] Fine tune FFB and rumble --- Config/FFBPlugin.ini | 8 ++++---- Game Files/WMMT5.cpp | 31 ++++++++++++++++++++----------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/Config/FFBPlugin.ini b/Config/FFBPlugin.ini index f7c2cd1..d381983 100644 --- a/Config/FFBPlugin.ini +++ b/Config/FFBPlugin.ini @@ -22,8 +22,8 @@ MaxForce=100 DeviceGUID= ;Set to 1 if you want to enable rumble, else 0. EnableRumble=1 -; Set to 1 to generate log.txt, else 0. Logs will be appended and not cleared. ReverseRumble=0 +; Set to 1 to generate log.txt, else 0. Logs will be appended and not cleared. Logging=0 ; When a command is set that contradicts a prior command, clear the prior command. Probably should stay as 1. ResetFeedback=1 @@ -256,10 +256,10 @@ AlternativeMaxForceLeft=-100 AlternativeMinForceRight=0 AlternativeMaxForceRight=100 SpringStrength=100 -FrictionStrength=20 -CollisionsStrength=30 +FrictionStrength=0 +CollisionsStrength=100 TiresSlipStrength=100 -HighhSpeedVibrationsStrength=50 +HighhSpeedVibrationsStrength=100 LimitBetweenHighSpeedVibrationsAndTiresSlip=75 [Mame 0199 32bit] diff --git a/Game Files/WMMT5.cpp b/Game Files/WMMT5.cpp index 0f6e927..2cc24f4 100644 --- a/Game Files/WMMT5.cpp +++ b/Game Files/WMMT5.cpp @@ -52,23 +52,19 @@ void WMMT5::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers { helpers->log("collision on the left"); double percentForce = (1.0 * collisions) * CollisionsStrengthWMMT5 / 100.0; - double percentLength = (250); - // direction from right => makes wheel turn left - triggers->LeftRight(percentForce, 0, percentLength); -// triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); triggers->Sine(100, 120, percentForce); + + double percentLength = (150); + triggers->LeftRight(0, percentForce, percentLength); } else if (0 > collisions) { helpers->log("collision on the right"); - double percentForce = (-1.0 * collisions) * CollisionsStrengthWMMT5 / 100.0; - double percentLength = (250); - // direction from left => makes wheel turn right - triggers->LeftRight(0, percentForce, percentLength); -// triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - - percentForce = (1.0 * collisions) * CollisionsStrengthWMMT5 / 100.0; + double percentForce = (1.0 * collisions) * CollisionsStrengthWMMT5 / 100.0; triggers->Sine(100, 120, percentForce); + + double percentLength = (150); + triggers->LeftRight(0, -1.0 * percentForce, percentLength); } if (0 < tiresSlip) { @@ -76,6 +72,13 @@ void WMMT5::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers bool highSpeedVibrations = (1.0 * tiresSlip) < (LimitBetweenHighSpeedVibrationsAndTiresSlipWMMT5 / 1000.0); double percentForce = (-1.0 * tiresSlip) * (highSpeedVibrations ? HighhSpeedVibrationsStrengthWMMT5 : TiresSlipStrengthWMMT5) / 100.0; triggers->Sine(highSpeedVibrations ? 100 : 120, 120, percentForce); + + if (0 == CollisionsStrengthWMMT5 || (0.001 > collisions && -0.001 < collisions)) + { + percentForce *= -1.0; + double percentLength = (150); + triggers->LeftRight(highSpeedVibrations ? percentForce : 0, highSpeedVibrations ? 0 : percentForce, percentLength); + } } else if (0 > tiresSlip) { @@ -83,5 +86,11 @@ void WMMT5::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers bool highSpeedVibrations = (-1.0 * tiresSlip) < (LimitBetweenHighSpeedVibrationsAndTiresSlipWMMT5 / 1000.0); double percentForce = (-1.0 * tiresSlip) * (highSpeedVibrations ? HighhSpeedVibrationsStrengthWMMT5 : TiresSlipStrengthWMMT5) / 100.0; triggers->Sine(highSpeedVibrations ? 100 : 120, 120, percentForce); + + if (0 == CollisionsStrengthWMMT5 || (0.001 > collisions && -0.001 < collisions)) + { + double percentLength = (150); + triggers->LeftRight(highSpeedVibrations ? percentForce : 0, highSpeedVibrations ? 0 : percentForce, percentLength); + } } } \ No newline at end of file From 5659e6281ea72ec7f1e463a0e9dac8ee78cf534c Mon Sep 17 00:00:00 2001 From: pinkimo Date: Sat, 28 Sep 2019 02:37:29 +0200 Subject: [PATCH 07/10] Add support for alternative FFB to sine and triangle effects Fix constant effect alternative FFB --- DllMain.cpp | 61 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 7 deletions(-) diff --git a/DllMain.cpp b/DllMain.cpp index ac3ab94..4b8cd32 100644 --- a/DllMain.cpp +++ b/DllMain.cpp @@ -1129,7 +1129,11 @@ void TriggerConstantEffect(int direction, double strength) SHORT minForce = (SHORT)(strength > 0.001 ? (configAlternativeMinForceLeft / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0. SHORT maxForce = (SHORT)(configAlternativeMaxForceLeft / 100.0 * 32767.0); SHORT range = maxForce - minForce; - SHORT level = (SHORT)(strength * range - minForce); + SHORT level = (SHORT)(strength * range + minForce); + if (level > 0) + { + level = -32767; + } tempEffect.constant.level = level; hlp.log((char *)(std::to_string(level)).c_str()); SDL_HapticUpdateEffect(haptic, effects.effect_left_id, &tempEffect); @@ -1144,6 +1148,10 @@ void TriggerConstantEffect(int direction, double strength) SHORT maxForce = (SHORT)(configAlternativeMaxForceRight / 100.0 * 32767.0); SHORT range = maxForce - minForce; SHORT level = (SHORT)(strength * range + minForce); + if (level < 0) + { + level = 32767; + } tempEffect.constant.level = level; hlp.log((char *)(std::to_string(level)).c_str()); SDL_HapticUpdateEffect(haptic, effects.effect_right_id, &tempEffect); @@ -1300,14 +1308,34 @@ void TriggerTriangleEffect(double strength, double length) tempEffect.condition.direction.dir[0] = direction; tempEffect.condition.direction.dir[1] = 0; //Y Position tempEffect.periodic.period = 500; - SHORT minForce = (SHORT)(strength > 0.001 ? (configMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0. - SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0); + + int confMinForce = configMinForce; + int confMaxForce = configMaxForce; + if (AlternativeFFB == 1) + { + if (direction == -1) + { + confMinForce = configAlternativeMinForceLeft; + confMaxForce = configAlternativeMaxForceLeft; + } + else + { + confMinForce = configAlternativeMinForceRight; + confMaxForce = configAlternativeMaxForceRight; + } + } + SHORT minForce = (SHORT)(strength > 0.001 ? (confMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0. + SHORT maxForce = (SHORT)(confMaxForce / 100.0 * 32767.0); SHORT range = maxForce - minForce; SHORT power = (SHORT)(strength * range + minForce); - if (power < 0) + if (range > 0 && power < 0) { power = 32767; } + else if (range < 0 && power > 0) + { + power = -32767; + } tempEffect.periodic.magnitude = power; tempEffect.periodic.length = length; tempEffect.periodic.attack_length = 1000; @@ -1473,14 +1501,33 @@ void TriggerSineEffect(UINT16 period, UINT16 fadePeriod, double strength) tempEffect.constant.direction.dir[1] = 0; //Y Position tempEffect.periodic.period = period; - SHORT minForce = (SHORT)(strength > 0.001 ? (configMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0. - SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0); + int confMinForce = configMinForce; + int confMaxForce = configMaxForce; + if (AlternativeFFB == 1) + { + if (direction == -1) + { + confMinForce = configAlternativeMinForceLeft; + confMaxForce = configAlternativeMaxForceLeft; + } + else + { + confMinForce = configAlternativeMinForceRight; + confMaxForce = configAlternativeMaxForceRight; + } + } + SHORT minForce = (SHORT)(strength > 0.001 ? (confMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0. + SHORT maxForce = (SHORT)(confMaxForce / 100.0 * 32767.0); SHORT range = maxForce - minForce; SHORT magnitude = (SHORT)(strength * range + minForce); - if (magnitude < 0) + if (range > 0 && magnitude < 0) { magnitude = 32767; } + else if (range < 0 && magnitude > 0) + { + magnitude = -32767; + } tempEffect.periodic.magnitude = (SHORT)(magnitude); tempEffect.periodic.length = configFeedbackLength; From 71dba728b847a0e541c4cf10a7c4e41cabc75d24 Mon Sep 17 00:00:00 2001 From: pinkimo Date: Sun, 29 Sep 2019 18:01:35 +0200 Subject: [PATCH 08/10] Improve WMMT5 FFB + fix sine effect globally --- Config/FFBPlugin.ini | 1 + DllMain.cpp | 32 ++++++++---------- Game Files/WMMT5.cpp | 78 ++++++++++++++++++++++++++++++-------------- 3 files changed, 68 insertions(+), 43 deletions(-) diff --git a/Config/FFBPlugin.ini b/Config/FFBPlugin.ini index d381983..f3c506a 100644 --- a/Config/FFBPlugin.ini +++ b/Config/FFBPlugin.ini @@ -257,6 +257,7 @@ AlternativeMinForceRight=0 AlternativeMaxForceRight=100 SpringStrength=100 FrictionStrength=0 +JointsAndStripesStrength=100 CollisionsStrength=100 TiresSlipStrength=100 HighhSpeedVibrationsStrength=100 diff --git a/DllMain.cpp b/DllMain.cpp index 4b8cd32..0fc4680 100644 --- a/DllMain.cpp +++ b/DllMain.cpp @@ -1090,8 +1090,8 @@ std::chrono::milliseconds timeOfLastSineEffect = duration_cast(sys std::chrono::milliseconds timeOfLastSpringEffect = duration_cast(system_clock::now().time_since_epoch()); std::string lastConstantEffectHash = ""; std::string lastFrictionEffectHash = ""; -std::string lastSineEffectHash = ""; double lastSineEffectStrength = 0; +double lastSineEffectPeriod = 0; std::string lastSpringEffectHash = ""; void TriggerConstantEffect(int direction, double strength) { @@ -1464,12 +1464,6 @@ void TriggerSineEffect(UINT16 period, UINT16 fadePeriod, double strength) { std::chrono::milliseconds now = duration_cast(system_clock::now().time_since_epoch()); long long elapsedTime = (std::chrono::duration_cast(now - timeOfLastSineEffect)).count(); - std::string effectHash = std::to_string(effects.effect_sine_id) + "_" + std::to_string(period) + "_" + std::to_string(fadePeriod) + "_" + std::to_string(strength); - - // if the effect is the same as the last effect that was sent AND enough time hasn't elapsed, do nothing - if (effectHash.compare(lastSineEffectHash) == 0 && elapsedTime < configFeedbackLength) { - return; // same effect, do nothing. - } int direction = 1; if (strength <= -0.001) { @@ -1477,19 +1471,19 @@ void TriggerSineEffect(UINT16 period, UINT16 fadePeriod, double strength) direction = -1; } - if (strength < (lastSineEffectStrength / 2.0) && elapsedTime < configFeedbackLength) { - return; // we prevent interruption of previous vibrations by a vibration a lot less strong. + // we ignore new effect until the last one is completed, unless the new one is significantly stronger + if (elapsedTime < lastSineEffectPeriod && strength < (lastSineEffectStrength * 2.0)) { + return; } - // TODO: investigate if we need this - if (configResetFeedback || strength <= 0.001) { + // if no strength, we do nothing + if (strength <= 0.001) { + return; + } + + // stop previous sine if not completed + if (configResetFeedback) { SDL_HapticStopEffect(haptic, effects.effect_sine_id); - if (strength <= 0.01) { - timeOfLastSineEffect = now; - lastSineEffectHash = effectHash; - lastSineEffectStrength = strength; - return; - } } SDL_HapticEffect tempEffect; @@ -1530,7 +1524,7 @@ void TriggerSineEffect(UINT16 period, UINT16 fadePeriod, double strength) } tempEffect.periodic.magnitude = (SHORT)(magnitude); - tempEffect.periodic.length = configFeedbackLength; + tempEffect.periodic.length = period; tempEffect.periodic.attack_length = fadePeriod; tempEffect.periodic.fade_length = fadePeriod; @@ -1541,8 +1535,8 @@ void TriggerSineEffect(UINT16 period, UINT16 fadePeriod, double strength) hlp.log((char *)std::to_string(supported).c_str());*/ timeOfLastSineEffect = now; - lastSineEffectHash = effectHash; lastSineEffectStrength = strength; + lastSineEffectPeriod = period; } void TriggerSpringEffectWithDefaultOption(double strength, bool isDefault) { diff --git a/Game Files/WMMT5.cpp b/Game Files/WMMT5.cpp index 2cc24f4..d966459 100644 --- a/Game Files/WMMT5.cpp +++ b/Game Files/WMMT5.cpp @@ -15,8 +15,10 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>. #include "WMMT5.h" wchar_t* settingsWMMT5 = TEXT(".\\FFBPlugin.ini"); +bool gameFfbStarted = false; int SpringStrengthWMMT5 = GetPrivateProfileInt(TEXT("Settings"), TEXT("SpringStrength"), 0, settingsWMMT5); int FrictionStrengthWMMT5 = GetPrivateProfileInt(TEXT("Settings"), TEXT("FrictionStrength"), 0, settingsWMMT5); +int JointsAndStripesStrengthWMMT5 = GetPrivateProfileInt(TEXT("Settings"), TEXT("JointsAndStripesStrength"), 0, settingsWMMT5); int CollisionsStrengthWMMT5 = GetPrivateProfileInt(TEXT("Settings"), TEXT("CollisionsStrength"), 0, settingsWMMT5); int TiresSlipStrengthWMMT5 = GetPrivateProfileInt(TEXT("Settings"), TEXT("TiresSlipStrength"), 0, settingsWMMT5); int HighhSpeedVibrationsStrengthWMMT5 = GetPrivateProfileInt(TEXT("Settings"), TEXT("HighhSpeedVibrationsStrength"), 0, settingsWMMT5); @@ -38,59 +40,87 @@ void WMMT5::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers ffs = "tires slip: " + std::to_string(tiresSlip); helpers->log((char*)ffs.c_str()); + double percentForce; if (0 < spring) { - double percentForce = (1.0 * spring) * SpringStrengthWMMT5 / 100.0; + if (!gameFfbStarted) + { + helpers->log("game's FFB started"); + gameFfbStarted = true; + } + percentForce = (1.0 * spring) * SpringStrengthWMMT5 / 100.0; triggers->Spring(percentForce); } + else if (!gameFfbStarted) + { + helpers->log("fake spring/friction until game's FFB starts"); + percentForce = 0.4 * SpringStrengthWMMT5 / 100.0; + triggers->Spring(percentForce); + percentForce = 0.5 * FrictionStrengthWMMT5 / 100.0; + triggers->Friction(percentForce); + } if (0 < friction) { - double percentForce = (1.0 * friction) * FrictionStrengthWMMT5 / 100.0; + percentForce = (1.0 * friction) * FrictionStrengthWMMT5 / 100.0; triggers->Friction(percentForce); } if (0 < collisions) { - helpers->log("collision on the left"); - double percentForce = (1.0 * collisions) * CollisionsStrengthWMMT5 / 100.0; - triggers->Sine(100, 120, percentForce); - - double percentLength = (150); - triggers->LeftRight(0, percentForce, percentLength); + if (0.209 <= collisions && 0.311 >= collisions) + { + helpers->log("joint/stripe on the right"); + percentForce = (1.0 * collisions) * JointsAndStripesStrengthWMMT5 / 100.0; + triggers->Sine(80, 80, percentForce); + triggers->LeftRight(0, percentForce, 150); + } + else + { + helpers->log("collision on the right"); + percentForce = (1.0 * collisions) * CollisionsStrengthWMMT5 / 100.0; + triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); + triggers->LeftRight(0, percentForce, 150); + } } else if (0 > collisions) { - helpers->log("collision on the right"); - double percentForce = (1.0 * collisions) * CollisionsStrengthWMMT5 / 100.0; - triggers->Sine(100, 120, percentForce); + if (-0.209 >= collisions && -0.311 <= collisions) + { + helpers->log("joint/stripe on the left"); + percentForce = (1.0 * collisions) * JointsAndStripesStrengthWMMT5 / 100.0; + triggers->Sine(80, 80, percentForce); + triggers->LeftRight(0, -1.0 * percentForce, 150); + } + else + { + helpers->log("collision on the left"); + percentForce = (-1.0 * collisions) * CollisionsStrengthWMMT5 / 100.0; + triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); + triggers->LeftRight(0, percentForce, 150); + } - double percentLength = (150); - triggers->LeftRight(0, -1.0 * percentForce, percentLength); } if (0 < tiresSlip) { helpers->log("tires slip left"); bool highSpeedVibrations = (1.0 * tiresSlip) < (LimitBetweenHighSpeedVibrationsAndTiresSlipWMMT5 / 1000.0); - double percentForce = (-1.0 * tiresSlip) * (highSpeedVibrations ? HighhSpeedVibrationsStrengthWMMT5 : TiresSlipStrengthWMMT5) / 100.0; - triggers->Sine(highSpeedVibrations ? 100 : 120, 120, percentForce); + percentForce = (-1.0 * tiresSlip) * (highSpeedVibrations ? HighhSpeedVibrationsStrengthWMMT5 : TiresSlipStrengthWMMT5) / 100.0; + triggers->Sine(100, 100, percentForce); - if (0 == CollisionsStrengthWMMT5 || (0.001 > collisions && -0.001 < collisions)) + if ((0 == JointsAndStripesStrengthWMMT5 && 0 == CollisionsStrengthWMMT5) || (0.001 > collisions && -0.001 < collisions)) { - percentForce *= -1.0; - double percentLength = (150); - triggers->LeftRight(highSpeedVibrations ? percentForce : 0, highSpeedVibrations ? 0 : percentForce, percentLength); + triggers->LeftRight(highSpeedVibrations ? (-1.0 * percentForce) : 0, highSpeedVibrations ? 0 : (-1.0 * percentForce), 150); } } else if (0 > tiresSlip) { helpers->log("tires slip right"); bool highSpeedVibrations = (-1.0 * tiresSlip) < (LimitBetweenHighSpeedVibrationsAndTiresSlipWMMT5 / 1000.0); - double percentForce = (-1.0 * tiresSlip) * (highSpeedVibrations ? HighhSpeedVibrationsStrengthWMMT5 : TiresSlipStrengthWMMT5) / 100.0; - triggers->Sine(highSpeedVibrations ? 100 : 120, 120, percentForce); + percentForce = (-1.0 * tiresSlip) * (highSpeedVibrations ? HighhSpeedVibrationsStrengthWMMT5 : TiresSlipStrengthWMMT5) / 100.0; + triggers->Sine(100, 100, percentForce); - if (0 == CollisionsStrengthWMMT5 || (0.001 > collisions && -0.001 < collisions)) + if ((0 == JointsAndStripesStrengthWMMT5 && 0 == CollisionsStrengthWMMT5) || (0.001 > collisions && -0.001 < collisions)) { - double percentLength = (150); - triggers->LeftRight(highSpeedVibrations ? percentForce : 0, highSpeedVibrations ? 0 : percentForce, percentLength); + triggers->LeftRight(highSpeedVibrations ? percentForce : 0, highSpeedVibrations ? 0 : percentForce, 150); } } } \ No newline at end of file From 6d3576d09923200ae88084d20ca1533622f42125 Mon Sep 17 00:00:00 2001 From: pinkimo Date: Sun, 29 Sep 2019 22:42:57 +0200 Subject: [PATCH 09/10] Fixes --- DllMain.cpp | 4 ++-- Game Files/WMMT5.cpp | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/DllMain.cpp b/DllMain.cpp index 0fc4680..0ae6e31 100644 --- a/DllMain.cpp +++ b/DllMain.cpp @@ -1471,7 +1471,7 @@ void TriggerSineEffect(UINT16 period, UINT16 fadePeriod, double strength) direction = -1; } - // we ignore new effect until the last one is completed, unless the new one is significantly stronger + // we ignore the new effect until the last one is completed, unless the new one is significantly stronger if (elapsedTime < lastSineEffectPeriod && strength < (lastSineEffectStrength * 2.0)) { return; } @@ -1481,7 +1481,7 @@ void TriggerSineEffect(UINT16 period, UINT16 fadePeriod, double strength) return; } - // stop previous sine if not completed + // stop previous effect if not completed if (configResetFeedback) { SDL_HapticStopEffect(haptic, effects.effect_sine_id); } diff --git a/Game Files/WMMT5.cpp b/Game Files/WMMT5.cpp index d966459..88aa254 100644 --- a/Game Files/WMMT5.cpp +++ b/Game Files/WMMT5.cpp @@ -14,8 +14,8 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>. #include #include "WMMT5.h" -wchar_t* settingsWMMT5 = TEXT(".\\FFBPlugin.ini"); bool gameFfbStarted = false; +wchar_t* settingsWMMT5 = TEXT(".\\FFBPlugin.ini"); int SpringStrengthWMMT5 = GetPrivateProfileInt(TEXT("Settings"), TEXT("SpringStrength"), 0, settingsWMMT5); int FrictionStrengthWMMT5 = GetPrivateProfileInt(TEXT("Settings"), TEXT("FrictionStrength"), 0, settingsWMMT5); int JointsAndStripesStrengthWMMT5 = GetPrivateProfileInt(TEXT("Settings"), TEXT("JointsAndStripesStrength"), 0, settingsWMMT5); @@ -71,14 +71,14 @@ void WMMT5::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers helpers->log("joint/stripe on the right"); percentForce = (1.0 * collisions) * JointsAndStripesStrengthWMMT5 / 100.0; triggers->Sine(80, 80, percentForce); - triggers->LeftRight(0, percentForce, 150); + triggers->LeftRight(0, percentForce, 100); } else { helpers->log("collision on the right"); percentForce = (1.0 * collisions) * CollisionsStrengthWMMT5 / 100.0; triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - triggers->LeftRight(0, percentForce, 150); + triggers->LeftRight(0, percentForce, 100); } } else if (0 > collisions) @@ -88,14 +88,14 @@ void WMMT5::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers helpers->log("joint/stripe on the left"); percentForce = (1.0 * collisions) * JointsAndStripesStrengthWMMT5 / 100.0; triggers->Sine(80, 80, percentForce); - triggers->LeftRight(0, -1.0 * percentForce, 150); + triggers->LeftRight(0, -1.0 * percentForce, 100); } else { helpers->log("collision on the left"); percentForce = (-1.0 * collisions) * CollisionsStrengthWMMT5 / 100.0; triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - triggers->LeftRight(0, percentForce, 150); + triggers->LeftRight(0, percentForce, 100); } } @@ -108,7 +108,7 @@ void WMMT5::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers if ((0 == JointsAndStripesStrengthWMMT5 && 0 == CollisionsStrengthWMMT5) || (0.001 > collisions && -0.001 < collisions)) { - triggers->LeftRight(highSpeedVibrations ? (-1.0 * percentForce) : 0, highSpeedVibrations ? 0 : (-1.0 * percentForce), 150); + triggers->LeftRight(highSpeedVibrations ? (-1.0 * percentForce) : 0, highSpeedVibrations ? 0 : (-1.0 * percentForce), 100); } } else if (0 > tiresSlip) @@ -120,7 +120,7 @@ void WMMT5::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers if ((0 == JointsAndStripesStrengthWMMT5 && 0 == CollisionsStrengthWMMT5) || (0.001 > collisions && -0.001 < collisions)) { - triggers->LeftRight(highSpeedVibrations ? percentForce : 0, highSpeedVibrations ? 0 : percentForce, 150); + triggers->LeftRight(highSpeedVibrations ? percentForce : 0, highSpeedVibrations ? 0 : percentForce, 100); } } } \ No newline at end of file From 05d112802e559e280449cc256cf615eb733740bf Mon Sep 17 00:00:00 2001 From: pinkimo Date: Mon, 30 Sep 2019 01:43:53 +0200 Subject: [PATCH 10/10] Fix rumble --- Game Files/WMMT5.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Game Files/WMMT5.cpp b/Game Files/WMMT5.cpp index 88aa254..127b972 100644 --- a/Game Files/WMMT5.cpp +++ b/Game Files/WMMT5.cpp @@ -71,14 +71,14 @@ void WMMT5::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers helpers->log("joint/stripe on the right"); percentForce = (1.0 * collisions) * JointsAndStripesStrengthWMMT5 / 100.0; triggers->Sine(80, 80, percentForce); - triggers->LeftRight(0, percentForce, 100); + triggers->LeftRight(0, percentForce, 150); } else { helpers->log("collision on the right"); percentForce = (1.0 * collisions) * CollisionsStrengthWMMT5 / 100.0; triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - triggers->LeftRight(0, percentForce, 100); + triggers->LeftRight(0, percentForce, 150); } } else if (0 > collisions) @@ -88,14 +88,14 @@ void WMMT5::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers helpers->log("joint/stripe on the left"); percentForce = (1.0 * collisions) * JointsAndStripesStrengthWMMT5 / 100.0; triggers->Sine(80, 80, percentForce); - triggers->LeftRight(0, -1.0 * percentForce, 100); + triggers->LeftRight(0, -1.0 * percentForce, 150); } else { helpers->log("collision on the left"); percentForce = (-1.0 * collisions) * CollisionsStrengthWMMT5 / 100.0; triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - triggers->LeftRight(0, percentForce, 100); + triggers->LeftRight(0, percentForce, 150); } } @@ -106,9 +106,9 @@ void WMMT5::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers percentForce = (-1.0 * tiresSlip) * (highSpeedVibrations ? HighhSpeedVibrationsStrengthWMMT5 : TiresSlipStrengthWMMT5) / 100.0; triggers->Sine(100, 100, percentForce); - if ((0 == JointsAndStripesStrengthWMMT5 && 0 == CollisionsStrengthWMMT5) || (0.001 > collisions && -0.001 < collisions)) + if (!highSpeedVibrations && ((0 == JointsAndStripesStrengthWMMT5 && 0 == CollisionsStrengthWMMT5) || (0.001 > collisions && -0.001 < collisions))) { - triggers->LeftRight(highSpeedVibrations ? (-1.0 * percentForce) : 0, highSpeedVibrations ? 0 : (-1.0 * percentForce), 100); + triggers->LeftRight(0, -1.0 * percentForce, 150); } } else if (0 > tiresSlip) @@ -118,9 +118,9 @@ void WMMT5::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers percentForce = (-1.0 * tiresSlip) * (highSpeedVibrations ? HighhSpeedVibrationsStrengthWMMT5 : TiresSlipStrengthWMMT5) / 100.0; triggers->Sine(100, 100, percentForce); - if ((0 == JointsAndStripesStrengthWMMT5 && 0 == CollisionsStrengthWMMT5) || (0.001 > collisions && -0.001 < collisions)) + if (!highSpeedVibrations && ((0 == JointsAndStripesStrengthWMMT5 && 0 == CollisionsStrengthWMMT5) || (0.001 > collisions && -0.001 < collisions))) { - triggers->LeftRight(highSpeedVibrations ? percentForce : 0, highSpeedVibrations ? 0 : percentForce, 100); + triggers->LeftRight(0, percentForce, 150); } } } \ No newline at end of file