1
0
mirror of synced 2024-11-28 00:20:52 +01:00

Merge pull request #8 from adamgp/master

Adding persistence to FFB Strength adjustments between loads.
This commit is contained in:
Boomslangnz 2020-06-24 10:58:51 +12:00 committed by GitHub
commit 5830fa50db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 57 additions and 1 deletions

View File

@ -52,6 +52,12 @@ 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
; Set to 1 if you want FFB strength adjustments to persist between loads, else 0.
EnablePersistentMaxForce=0
; 0-100: the previous max force strength set if persistence is enabled. -1 means this has not yet been saved.
PersistentMaxForce=-1
PersistentAlternativeMaxForceLeft=1
PersistentAlternativeMaxForceRight=-1
; ***********************************************************************************************************************************
; ************************************************ Game overrides are specified below ***********************************************

View File

@ -921,6 +921,10 @@ int IncreaseFFBStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("IncreaseF
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 EnablePersistentMaxForce = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnablePersistentMaxForce"), 0, settingsFilename);
int PersistentMaxForce = GetPrivateProfileInt(TEXT("Settings"), TEXT("PersistentMaxForce"), -1, settingsFilename);
int PersistentAlternativeMaxForceLeft = GetPrivateProfileInt(TEXT("Settings"), TEXT("PersistentAlternativeMaxForceLeft"), 1, settingsFilename);
int PersistentAlternativeMaxForceRight = GetPrivateProfileInt(TEXT("Settings"), TEXT("PersistentAlternativeMaxForceRight"), -1, settingsFilename);
int defaultCenterMaxForce = configMaxForce;
int defaultCenterMinForce = configMinForce;
@ -1936,6 +1940,22 @@ int WorkaroundToFixRumble(void* ptr)
return 0;
}
void WritePersistentMaxForce()
{
if (EnablePersistentMaxForce == 1)
{
if (AlternativeFFB == 1)
{
WritePrivateProfileStringA("Settings", "PersistentAlternativeMaxForceLeft", (char*)(std::to_string(configAlternativeMaxForceLeft)).c_str(), ".\\FFBPlugin.ini");
WritePrivateProfileStringA("Settings", "PersistentAlternativeMaxForceRight", (char*)(std::to_string(configAlternativeMaxForceRight)).c_str(), ".\\FFBPlugin.ini");
}
else
{
WritePrivateProfileStringA("Settings", "PersistentMaxForce", (char*)(std::to_string(configMaxForce)).c_str(), ".\\FFBPlugin.ini");
}
}
}
DWORD WINAPI AdjustFFBStrengthLoop(LPVOID lpParam)
{
SDL_Event e;
@ -1968,9 +1988,11 @@ DWORD WINAPI AdjustFFBStrengthLoop(LPVOID lpParam)
if ((configMaxForce >= 0) && (configMaxForce < 100))
{
configMaxForce += StepFFBStrength;
configMaxForce = max(0, min(100, configMaxForce));
configMaxForce = max(0, min(100, configMaxForce));
}
}
WritePersistentMaxForce();
}
if (e.jbutton.button == DecreaseFFBStrength)
@ -1996,6 +2018,8 @@ DWORD WINAPI AdjustFFBStrengthLoop(LPVOID lpParam)
configMaxForce = max(0, min(100, configMaxForce));
}
}
WritePersistentMaxForce();
}
if (e.jbutton.button == ResetFFBStrength)
@ -2012,6 +2036,8 @@ DWORD WINAPI AdjustFFBStrengthLoop(LPVOID lpParam)
configMaxForce = defaultCenterMaxForce;
configMinForce = defaultCenterMinForce;
}
WritePersistentMaxForce();
}
}
}
@ -2254,6 +2280,30 @@ DWORD WINAPI FFBLoop(LPVOID lpParam)
{
CreateThread(NULL, 0, AdjustFFBStrengthLoop, NULL, 0, NULL);
}
// Load persistent max force if previously set.
if (EnablePersistentMaxForce == 1)
{
if (AlternativeFFB == 1)
{
if (PersistentAlternativeMaxForceLeft <= 0)
{
configAlternativeMaxForceLeft = PersistentAlternativeMaxForceLeft;
}
if (PersistentAlternativeMaxForceRight >= 0)
{
configAlternativeMaxForceRight = PersistentAlternativeMaxForceRight;
}
}
else
{
if (PersistentMaxForce >= 0)
{
configMaxForce = PersistentMaxForce;
}
}
}
hlp.log("Initialize() complete");
return 0;