1
0
mirror of synced 2024-11-27 16:10:52 +01:00

Merge pull request #1 from Boomslangnz/master

update
This commit is contained in:
adamgp 2020-06-21 23:00:44 +01:00 committed by GitHub
commit 452d5765a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 109 additions and 92 deletions

View File

@ -860,6 +860,7 @@ AlternativeMaxForceRightECA=100
[MAME 32bit Outputs]
GameId=22
AutoScrollGUI=0
EnableForceSpringEffect=0
ForceSpringStrength=100
Device2GUID=
@ -1303,7 +1304,7 @@ FFBDivideAceDriver=643
[MAME 64bit Outputs]
GameId=22
ScanDelayTime=5
AutoScrollGUI=0
EnableForceSpringEffect=0
ForceSpringStrength=100
Device2GUID=

View File

@ -915,6 +915,7 @@ 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 AutoCloseWindowError = GetPrivateProfileInt(TEXT("Settings"), TEXT("AutoCloseWindowError"), 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);
@ -1916,6 +1917,16 @@ void TriggerSpringEffect(double strength)
TriggerSpringEffectWithDefaultOption(strength, false);
}
void changeVolume()
{
INPUT ip = { 0 };
ip.type = INPUT_KEYBOARD;
ip.ki.wVk = VK_VOLUME_MUTE;
SendInput(1, &ip, sizeof(INPUT));
ip.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &ip, sizeof(INPUT));
}
int WorkaroundToFixRumble(void* ptr)
{
SDL_Event e;
@ -1925,6 +1936,91 @@ int WorkaroundToFixRumble(void* ptr)
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);
}
}
DWORD WINAPI FFBLoop2(LPVOID lpParam)
{
// assign FFB effects here
@ -2154,106 +2250,19 @@ DWORD WINAPI FFBLoop(LPVOID lpParam)
Sleep(2500);
}
Initialize(0);
if (EnableFFBStrengthDynamicAdjustment == 1)
{
CreateThread(NULL, 0, AdjustFFBStrengthLoop, NULL, 0, NULL);
}
hlp.log("Initialize() complete");
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");
}
@ -2342,6 +2351,13 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ulReasonForCall, LPVOID lpReserved)
{
gl_cgGLDll = LoadLibraryA("cgGL.dll");
}
if (configGameId == 26)
{
if (AutoCloseWindowError == 1)
{
changeVolume();
}
}
}
else
{