From 2ce752eb977f892dee2c4d149a21fef45b55d810 Mon Sep 17 00:00:00 2001 From: Adam Pooley Date: Fri, 19 Jun 2020 13:11:59 +0100 Subject: [PATCH] Adding optional dynamic strength adjustment controls. --- Config/FFBPlugin.ini | 9 +++ DllMain.cpp | 103 +++++++++++++++++++++++++++++++++++ Includes/FFBPluginReadme.txt | 5 +- 3 files changed, 114 insertions(+), 3 deletions(-) diff --git a/Config/FFBPlugin.ini b/Config/FFBPlugin.ini index cb900ed..9b932bc 100644 --- a/Config/FFBPlugin.ini +++ b/Config/FFBPlugin.ini @@ -43,6 +43,15 @@ AlternativeMaxForceLeft=-100 AlternativeMinForceRight=0 AlternativeMaxForceRight=100 ForceShowDeviceGUIDMessageBox=0 +; Set to 1 if you want to enable dynamic strength adjustments, else 0. +EnableFFBStrengthDynamicAdjustment=0 +; Button index for dynamically changing maximum FFB strength. +IncreaseFFBStrength= +DecreaseFFBStrength= +ResetFFBStrength= +; Step is the amount to adjust when increasing or decreasing per button where FFB strength is represented on +; a scale of 0-100. +StepFFBStrength=5 ; *********************************************************************************************************************************** ; ************************************************ Game overrides are specified below *********************************************** diff --git a/DllMain.cpp b/DllMain.cpp index 62cd97b..4cfc76a 100644 --- a/DllMain.cpp +++ b/DllMain.cpp @@ -915,6 +915,18 @@ int RumbleStrengthLeftMotor = GetPrivateProfileInt(TEXT("Settings"), TEXT("Rumbl int RumbleStrengthRightMotor = GetPrivateProfileInt(TEXT("Settings"), TEXT("RumbleStrengthRightMotor"), 0, settingsFilename); int EnableForceSpringEffect = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableForceSpringEffect"), 0, settingsFilename); int ForceSpringStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("ForceSpringStrength"), 0, settingsFilename); +int EnableFFBStrengthDynamicAdjustment = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableFFBStrengthDynamicAdjustment"), 0, settingsFilename); +int IncreaseFFBStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("IncreaseFFBStrength"), NULL, settingsFilename); +int DecreaseFFBStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("DecreaseFFBStrength"), NULL, settingsFilename); +int ResetFFBStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("ResetFFBStrength"), NULL, settingsFilename); +int StepFFBStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("StepFFBStrength"), 5, settingsFilename); + +int defaultCenterMaxForce = configMaxForce; +int defaultCenterMinForce = configMinForce; +int defaultAlternativeCenterMaxForceRight = configAlternativeMaxForceRight; +int defaultAlternativeCenterMinForceRight = configAlternativeMinForceRight; +int defaultAlternativeCenterMaxForceLeft = configAlternativeMaxForceLeft; +int defaultAlternativeCenterMinForceLeft = configAlternativeMinForceRight; char chainedDLL[256]; @@ -2147,10 +2159,101 @@ DWORD WINAPI FFBLoop(LPVOID lpParam) return 0; } +DWORD WINAPI AdjustFFBStrengthLoop(LPVOID lpParam) +{ + SDL_Event e; + + while (true) + { + while (SDL_WaitEvent(&e) != 0) + { + if (e.type == SDL_JOYBUTTONDOWN) + { + if (e.jbutton.which == joystick_index1) + { + if (e.jbutton.button == IncreaseFFBStrength) + { + if (AlternativeFFB == 1) + { + if ((configAlternativeMaxForceRight >= 0) && (configAlternativeMaxForceRight < 100)) + { + configAlternativeMaxForceRight += StepFFBStrength; + configAlternativeMaxForceRight = max(0, min(100, configAlternativeMaxForceRight)); + } + if ((configAlternativeMaxForceLeft <= 0) && (configAlternativeMaxForceLeft > -100)) + { + configAlternativeMaxForceLeft -= StepFFBStrength; + configAlternativeMaxForceLeft = max(-100, min(0, configAlternativeMaxForceLeft)); + } + } + else + { + if ((configMaxForce >= 0) && (configMaxForce < 100)) + { + configMaxForce += StepFFBStrength; + configMaxForce = max(0, min(100, configMaxForce)); + } + } + } + + if (e.jbutton.button == DecreaseFFBStrength) + { + if (AlternativeFFB == 1) + { + if ((configAlternativeMaxForceRight > 0) && (configAlternativeMaxForceRight <= 100)) + { + configAlternativeMaxForceRight -= StepFFBStrength; + configAlternativeMaxForceRight = max(0, min(100, configAlternativeMaxForceRight)); + } + if ((configAlternativeMaxForceLeft < 0) && (configAlternativeMaxForceLeft >= -100)) + { + configAlternativeMaxForceLeft += StepFFBStrength; + configAlternativeMaxForceLeft = max(-100, min(0, configAlternativeMaxForceLeft)); + } + } + else + { + if ((configMaxForce > 0) && (configMaxForce <= 100)) + { + configMaxForce -= StepFFBStrength; + configMaxForce = max(0, min(100, configMaxForce)); + } + } + } + + if (e.jbutton.button == ResetFFBStrength) + { + if (AlternativeFFB == 1) + { + configAlternativeMaxForceRight = defaultAlternativeCenterMaxForceRight; + configAlternativeMinForceRight = defaultAlternativeCenterMinForceRight; + configAlternativeMaxForceLeft = defaultAlternativeCenterMaxForceLeft; + configAlternativeMinForceRight = defaultAlternativeCenterMinForceLeft; + } + else + { + configMaxForce = defaultCenterMaxForce; + configMinForce = defaultCenterMinForce; + } + } + } + } + } + + Sleep(16); + } +} + void CreateFFBLoopThread() { hlp.log("Before CreateThread"); CreateThread(NULL, 0, FFBLoop, (LPVOID)&keepRunning, 0, NULL); + + if (EnableFFBStrengthDynamicAdjustment == 1) + { + CreateThread(NULL, 0, AdjustFFBStrengthLoop, NULL, 0, NULL); + } + hlp.log("After CreateThread"); } diff --git a/Includes/FFBPluginReadme.txt b/Includes/FFBPluginReadme.txt index a1770c4..e130d7f 100644 --- a/Includes/FFBPluginReadme.txt +++ b/Includes/FFBPluginReadme.txt @@ -1,6 +1,6 @@ ***FFB Arcade Plugin*** -Version 2.1 +Version 2.2 Brought to you by Boomslangnz, Ducon2016, Spazzy & pinkimo. @@ -180,5 +180,4 @@ extremely generous. -Vapor TRX -Virtua Racing (CHANGE TO UPRIGHT CABINET) -Wacky Races --Wangan Midnight Maximum Tune 5 --Le Mans 24 \ No newline at end of file +-Wangan Midnight Maximum Tune 5 \ No newline at end of file