Further improvements on WMMT5 FFB
This commit is contained in:
parent
6fbe720efb
commit
2e3f8f2149
@ -292,7 +292,6 @@ GearChangeStrength=20
|
|||||||
GearChangeDelay=250
|
GearChangeDelay=250
|
||||||
GearChangeLength=200
|
GearChangeLength=200
|
||||||
LimitBetweenHighSpeedVibrationsAndTiresSlip=75
|
LimitBetweenHighSpeedVibrationsAndTiresSlip=75
|
||||||
ShowButtonNumbersForSetup=0
|
|
||||||
ForceFullTune=0
|
ForceFullTune=0
|
||||||
DisableRaceTimer=0
|
DisableRaceTimer=0
|
||||||
EnableForceFinish=0
|
EnableForceFinish=0
|
||||||
|
12
DllMain.cpp
12
DllMain.cpp
@ -1197,7 +1197,7 @@ void TriggerTriangleEffect(double strength, double length)
|
|||||||
if (FFBorRumble == 0)
|
if (FFBorRumble == 0)
|
||||||
{
|
{
|
||||||
int direction = 1;
|
int direction = 1;
|
||||||
if (strength <= -0.001) {
|
if (strength < -0.001) {
|
||||||
strength *= -1;
|
strength *= -1;
|
||||||
direction = -1;
|
direction = -1;
|
||||||
}
|
}
|
||||||
@ -1387,18 +1387,18 @@ void TriggerSineEffect(UINT16 period, UINT16 fadePeriod, double strength)
|
|||||||
long long elapsedTime = (std::chrono::duration_cast<std::chrono::milliseconds>(now - timeOfLastSineEffect)).count();
|
long long elapsedTime = (std::chrono::duration_cast<std::chrono::milliseconds>(now - timeOfLastSineEffect)).count();
|
||||||
|
|
||||||
int direction = 1;
|
int direction = 1;
|
||||||
if (strength <= -0.001) {
|
if (strength < -0.001) {
|
||||||
strength *= -1;
|
strength *= -1;
|
||||||
direction = -1;
|
direction = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// we ignore the new effect until the last one is completed, unless the new one is significantly stronger
|
// if no strength, we do nothing
|
||||||
if (elapsedTime < lastSineEffectPeriod && strength < (lastSineEffectStrength * 2.0)) {
|
if (strength <= 0.001) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if no strength, we do nothing
|
// we ignore the new effect until the last one is completed, unless the new one is significantly stronger
|
||||||
if (strength <= 0.001) {
|
if (elapsedTime < lastSineEffectPeriod && strength < (lastSineEffectStrength * 1.5)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,19 +44,17 @@ static int ForceTimeUpButton = GetPrivateProfileInt(TEXT("Settings"), TEXT("Forc
|
|||||||
|
|
||||||
static int InputThread(void *ptr)
|
static int InputThread(void *ptr)
|
||||||
{
|
{
|
||||||
|
if (1 != EnableForceFinish && 1 != EnableForceTimeUp)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
myHelpers->log("starting input thread");
|
myHelpers->log("starting input thread");
|
||||||
while (SDL_WaitEvent(&e) != 0)
|
while (SDL_WaitEvent(&e) != 0)
|
||||||
{
|
{
|
||||||
if (e.type == SDL_JOYBUTTONDOWN)
|
if (e.type == SDL_JOYBUTTONDOWN)
|
||||||
{
|
{
|
||||||
myHelpers->log("button pressed");
|
myHelpers->log("button pressed");
|
||||||
if (1 == ShowButtonNumbersForSetup && e.jbutton.button >= 0)
|
|
||||||
{
|
|
||||||
char buff[100];
|
|
||||||
sprintf_s(buff, "Button %d Pressed", e.jbutton.button);
|
|
||||||
MessageBoxA(NULL, buff, "", NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (1 == EnableForceFinish && e.jbutton.button == ForceFinishButton)
|
if (1 == EnableForceFinish && e.jbutton.button == ForceFinishButton)
|
||||||
{
|
{
|
||||||
INT_PTR ptr1 = myHelpers->ReadIntPtr(0x199A468, true);
|
INT_PTR ptr1 = myHelpers->ReadIntPtr(0x199A468, true);
|
||||||
@ -133,21 +131,21 @@ static int GearChangeThread(void* ptr)
|
|||||||
}
|
}
|
||||||
myHelpers->log("gear change");
|
myHelpers->log("gear change");
|
||||||
double percentForce = GearChangeStrength / 100.0;
|
double percentForce = GearChangeStrength / 100.0;
|
||||||
myTriggers->Sine(GearChangeLength, 0, percentForce);
|
myTriggers->Sine(GearChangeLength, GearChangeLength, percentForce);
|
||||||
myTriggers->LeftRight(0, percentForce, 150);
|
myTriggers->LeftRight(0, percentForce, 150);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WMMT5::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) {
|
void WMMT5::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers)
|
||||||
|
{
|
||||||
if (!init)
|
if (!init)
|
||||||
{
|
{
|
||||||
init = true;
|
init = true;
|
||||||
myTriggers = triggers;
|
myTriggers = triggers;
|
||||||
myConstants = constants;
|
myConstants = constants;
|
||||||
myHelpers = helpers;
|
myHelpers = helpers;
|
||||||
SDL_Thread* inputThread = SDL_CreateThread(InputThread, "InputThread", (void*)NULL);
|
SDL_CreateThread(InputThread, "InputThread", (void*)NULL);
|
||||||
SDL_Thread* spamThread = SDL_CreateThread(SpamThread, "SpamThread", (void*)NULL);
|
SDL_CreateThread(SpamThread, "SpamThread", (void*)NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
float spring = helpers->ReadFloat32(0x196F18C, true);
|
float spring = helpers->ReadFloat32(0x196F18C, true);
|
||||||
@ -161,7 +159,15 @@ void WMMT5::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers
|
|||||||
helpers->log((char*)msg.c_str());
|
helpers->log((char*)msg.c_str());
|
||||||
|
|
||||||
double percentForce;
|
double percentForce;
|
||||||
if (0 < spring)
|
if (0.001 > spring && !gameFfbStarted)
|
||||||
|
{
|
||||||
|
helpers->log("fake spring+friction until game's FFB starts");
|
||||||
|
percentForce = 0.3 * SpringStrength / 100.0;
|
||||||
|
triggers->Spring(percentForce);
|
||||||
|
percentForce = 0.5 * FrictionStrength / 100.0;
|
||||||
|
triggers->Friction(percentForce);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (!gameFfbStarted)
|
if (!gameFfbStarted)
|
||||||
{
|
{
|
||||||
@ -170,20 +176,10 @@ void WMMT5::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers
|
|||||||
}
|
}
|
||||||
percentForce = (1.0 * spring) * SpringStrength / 100.0;
|
percentForce = (1.0 * spring) * SpringStrength / 100.0;
|
||||||
triggers->Spring(percentForce);
|
triggers->Spring(percentForce);
|
||||||
}
|
|
||||||
else if (!gameFfbStarted)
|
|
||||||
{
|
|
||||||
helpers->log("fake spring/friction until game's FFB starts");
|
|
||||||
percentForce = 0.3 * SpringStrength / 100.0;
|
|
||||||
triggers->Spring(percentForce);
|
|
||||||
percentForce = 0.5 * FrictionStrength / 100.0;
|
|
||||||
triggers->Friction(percentForce);
|
|
||||||
}
|
|
||||||
if (0 < friction)
|
|
||||||
{
|
|
||||||
percentForce = (1.0 * friction) * FrictionStrength / 100.0;
|
percentForce = (1.0 * friction) * FrictionStrength / 100.0;
|
||||||
triggers->Friction(percentForce);
|
triggers->Friction(percentForce);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 < collisions)
|
if (0 < collisions)
|
||||||
{
|
{
|
||||||
if (0.209 <= collisions && 0.311 >= collisions)
|
if (0.209 <= collisions && 0.311 >= collisions)
|
||||||
@ -217,8 +213,13 @@ void WMMT5::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers
|
|||||||
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
|
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
|
||||||
triggers->LeftRight(0, percentForce, 150);
|
triggers->LeftRight(0, percentForce, 150);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
helpers->log("resetting collision");
|
||||||
|
triggers->Constant(constants->DIRECTION_FROM_LEFT, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (0 < tiresSlip)
|
if (0 < tiresSlip)
|
||||||
{
|
{
|
||||||
helpers->log("tires slip left");
|
helpers->log("tires slip left");
|
||||||
@ -247,7 +248,6 @@ void WMMT5::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers
|
|||||||
INT_PTR ptr1 = helpers->ReadIntPtr(0x199A450, true);
|
INT_PTR ptr1 = helpers->ReadIntPtr(0x199A450, true);
|
||||||
UINT8 gear = helpers->ReadByte(ptr1 + 0x398, false);
|
UINT8 gear = helpers->ReadByte(ptr1 + 0x398, false);
|
||||||
|
|
||||||
|
|
||||||
if (0 < WheelSpinStrength)
|
if (0 < WheelSpinStrength)
|
||||||
{
|
{
|
||||||
INT_PTR ptr1 = myHelpers->ReadIntPtr(0x1948F10, true);
|
INT_PTR ptr1 = myHelpers->ReadIntPtr(0x1948F10, true);
|
||||||
@ -306,7 +306,7 @@ void WMMT5::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers
|
|||||||
|
|
||||||
if (oldgear != gear && 0 < gear && 0.5 < time && 0.1 <= speed)
|
if (oldgear != gear && 0 < gear && 0.5 < time && 0.1 <= speed)
|
||||||
{
|
{
|
||||||
SDL_Thread* gearChangeThread = SDL_CreateThread(GearChangeThread, "GearChangeThread", (void*)NULL);
|
SDL_CreateThread(GearChangeThread, "GearChangeThread", (void*)NULL);
|
||||||
}
|
}
|
||||||
oldgear = gear;
|
oldgear = gear;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user