1
0
mirror of synced 2025-01-31 11:53:54 +01:00

Make every game plugin have Running Thread etc

Makes rumble work correctly and stop for each and every game plus other enhancements, also removed Teknoparrot class file etc and just added code to TP games cpp files directly. Removed LastForStop
This commit is contained in:
Aaron M 2019-11-01 18:30:36 +13:00
parent ede0f04835
commit ea7f30935c
55 changed files with 11645 additions and 10931 deletions

View File

@ -1,17 +0,0 @@
#include "TeknoParrotGame.h"
TeknoParrotGame::TeknoParrotGame()
{
hSection = CreateFileMapping(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, 64, L"TeknoParrot_JvsState");
secData = MapViewOfFile(hSection, FILE_MAP_ALL_ACCESS, 0, 0, 64);
ffbOffset = *((int *)secData + 2);
}
int TeknoParrotGame::GetTeknoParrotFFB()
{
ffbOffset = *((int *)secData + 2);
return ffbOffset;
}
void TeknoParrotGame::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
helpers->log("TeknoParrot game not implemented");
}

View File

@ -1,18 +0,0 @@
#pragma once
#include "Game.h"
class TeknoParrotGame : public Game {
// TP-related
HANDLE hSection;
LPVOID secData;
int ffbOffset = 0;
protected:
int lastWasStop = 0;
int GetTeknoParrotFFB();
TeknoParrotGame();
public:
void FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers);
};

View File

@ -50,7 +50,6 @@
<ClCompile Include="Game Files\KODrive.cpp" />
<ClCompile Include="Game Files\OutRun2Real.cpp" />
<ClCompile Include="Game Files\ButtonRumble.cpp" />
<ClCompile Include="Common Files\TeknoParrotGame.cpp" />
<ClCompile Include="Game Files\Demul.cpp" />
<ClCompile Include="Game Files\AfterburnerClimax.cpp" />
<ClCompile Include="Game Files\BG4JP.cpp" />
@ -86,7 +85,6 @@
<ClCompile Include="Game Files\LGI3D.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Common Files\TeknoParrotGame.h" />
<ClInclude Include="Game Files\AfterburnerClimax.h" />
<ClInclude Include="Game Files\BG4JP.h" />
<ClInclude Include="Game Files\Daytona3.h" />

View File

@ -47,7 +47,6 @@
<ClCompile Include="Game Files\ChaseHQ2.cpp">
<Filter>Game Files</Filter>
</ClCompile>
<ClCompile Include="Common Files\TeknoParrotGame.cpp" />
<ClCompile Include="Game Files\MarioKartGPDX.cpp">
<Filter>Game Files</Filter>
</ClCompile>
@ -152,9 +151,6 @@
<ClInclude Include="Game Files\ChaseHQ2.h">
<Filter>Game Files</Filter>
</ClInclude>
<ClInclude Include="Common Files\TeknoParrotGame.h">
<Filter>Common Header Files</Filter>
</ClInclude>
<ClInclude Include="Game Files\MarioKartGPDX.h">
<Filter>Game Files</Filter>
</ClInclude>

View File

@ -14,29 +14,57 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include <string>
#include "AfterburnerClimax.h"
#include "SDL.h"
void AfterburnerClimax::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
UINT8 ff = helpers->ReadByte(0x08347A5E, /* isRelativeOffset */ false);
helpers->log("got value: ");
std::string ffs = std::to_string(ff);
helpers->log((char *)ffs.c_str());
static SDL_Event e;
static EffectTriggers* myTriggers;
static EffectConstants* myConstants;
static Helpers* myHelpers;
wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini");
int Rumble1Strength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Rumble1Strength"), 0, settingsFilename);
int Rumble2Strength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Rumble2Strength"), 0, settingsFilename);
int Rumble1Length = GetPrivateProfileInt(TEXT("Settings"), TEXT("Rumble1Length"), 0, settingsFilename);
int Rumble2Length = GetPrivateProfileInt(TEXT("Settings"), TEXT("Rumble2Length"), 0, settingsFilename);
if (ff == 64)
static wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini");
static int Rumble1Strength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Rumble1Strength"), 0, settingsFilename);
static int Rumble2Strength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Rumble2Strength"), 0, settingsFilename);
static int Rumble1Length = GetPrivateProfileInt(TEXT("Settings"), TEXT("Rumble1Length"), 0, settingsFilename);
static int Rumble2Length = GetPrivateProfileInt(TEXT("Settings"), TEXT("Rumble2Length"), 0, settingsFilename);
static int RunningThread(void* ptr)
{
int cnt;
for (cnt = 0; cnt >= 0; ++cnt)
{
UINT8 ff = myHelpers->ReadByte(0x08347A5E, /* isRelativeOffset */ false);
myHelpers->log("got value: ");
std::string ffs = std::to_string(ff);
myHelpers->log((char*)ffs.c_str());
if (ff == 64)
{
double percentForce = ((Rumble1Strength) / 100.0);
double percentLength = (Rumble1Length);
triggers->Rumble(percentForce, percentForce, percentLength);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if (ff == 80)
else if (ff == 80)
{
double percentForce = ((Rumble2Strength) / 100.0);
double percentLength = (Rumble2Length);
triggers->Rumble(percentForce, percentForce, percentLength);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
}
return 0;
}
void AfterburnerClimax::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
SDL_Thread* thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void*)NULL);
while (SDL_WaitEvent(&e) != 0)
{
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
}
}

View File

@ -13,83 +13,110 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include <string>
#include "BG4JP.h"
#include "SDL.h"
static SDL_Event e;
static EffectTriggers* myTriggers;
static EffectConstants* myConstants;
static Helpers* myHelpers;
static int SpeedStrength;
static int RunningThread(void* ptr)
{
int cnt;
for (cnt = 0; cnt >= 0; ++cnt)
{
int ff = myHelpers->ReadInt32(0x42EBB0, /* isRelativeOffset */ true);
float ffspeed = myHelpers->ReadFloat32(0x3F3000, /* isRelativeOffset */ true);
float ff2 = myHelpers->ReadFloat32(0x42EAB4, /* isRelativeOffset */ true);
if ((ffspeed >= 0.1) & (ffspeed <= 15))
{
SpeedStrength = 10;
}
else if ((ffspeed >= 15.01) & (ffspeed <= 35))
{
SpeedStrength = 20;
}
else if ((ffspeed >= 35.01) & (ffspeed <= 55))
{
SpeedStrength = 30;
}
else if ((ffspeed >= 55.01) & (ffspeed <= 75))
{
SpeedStrength = 40;
}
else if ((ffspeed >= 75.01) & (ffspeed <= 90))
{
SpeedStrength = 51;
}
else if ((ffspeed >= 90.01) & (ffspeed <= 110))
{
SpeedStrength = 62;
}
else if ((ffspeed >= 110.01) & (ffspeed <= 130))
{
SpeedStrength = 75;
}
else if ((ffspeed >= 130.01) & (ffspeed <= 150))
{
SpeedStrength = 90;
}
else if (ffspeed > 150.01)
{
SpeedStrength = 100;
}
else
{
SpeedStrength = 0;
}
myHelpers->log("got value: ");
std::string ffs = std::to_string(ff);
myHelpers->log((char*)ffs.c_str());
if ((2000000 < ff) && (ff < 4000000))
{
double percentForce = SpeedStrength / 100.0;
double percentLength = 150;
myTriggers->Rumble(0, percentForce, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce);
}
else if ((1000000 < ff) && (ff < 1600000))
{
double percentForce = SpeedStrength / 100.0;
double percentLength = 150;
myTriggers->Rumble(percentForce, 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce);
}
else if ((0.00000000000000000001 < ff2) && (ffspeed > 0.01))
{
double percentForce = (0.1);
double percentLength = (50);
myTriggers->Rumble(0, percentForce, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce);
}
else if ((0.00000000000000000001 > ff2) && (ffspeed > 0.01))
{
double percentForce = (0.1);
double percentLength = (50);
myTriggers->Rumble(percentForce, 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce);
}
}
}
void BG4JP::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
int ff = helpers->ReadInt32(0x42EBB0, /* isRelativeOffset */ true);
float ffspeed = helpers->ReadFloat32(0x3F3000, /* isRelativeOffset */ true);
float ff2 = helpers->ReadFloat32(0x42EAB4, /* isRelativeOffset */ true);
if ((ffspeed >= 0.1) & (ffspeed <= 15))
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
SDL_Thread* thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void*)NULL);
while (SDL_WaitEvent(&e) != 0)
{
SpeedStrength = 10;
}
else if ((ffspeed >= 15.01) & (ffspeed <= 35))
{
SpeedStrength = 20;
}
else if ((ffspeed >= 35.01) & (ffspeed <= 55))
{
SpeedStrength = 30;
}
else if ((ffspeed >= 55.01) & (ffspeed <= 75))
{
SpeedStrength = 40;
}
else if ((ffspeed >= 75.01) & (ffspeed <= 90))
{
SpeedStrength = 51;
}
else if ((ffspeed >= 90.01) & (ffspeed <= 110))
{
SpeedStrength = 62;
}
else if ((ffspeed >= 110.01) & (ffspeed <= 130))
{
SpeedStrength = 75;
}
else if ((ffspeed >= 130.01) & (ffspeed <= 150))
{
SpeedStrength = 90;
}
else if (ffspeed > 150.01)
{
SpeedStrength = 100;
}
else
{
SpeedStrength = 0;
}
helpers->log("got value: ");
std::string ffs = std::to_string(ff);
helpers->log((char *)ffs.c_str());
if ((2000000 < ff) && (ff < 4000000))
{
double percentForce = SpeedStrength / 100.0;
double percentLength = 150;
triggers->Rumble(0, percentForce, percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
}
else if ((1000000 < ff) && (ff < 1600000))
{
double percentForce = SpeedStrength / 100.0;
double percentLength = 150;
triggers->Rumble(percentForce, 0, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
}
else if ((0.00000000000000000001 < ff2) && (ffspeed > 0.01))
{
double percentForce = (0.1);
double percentLength = (50);
triggers->Rumble(0, percentForce, percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
}
else if ((0.00000000000000000001 > ff2) && (ffspeed > 0.01))
{
double percentForce = (0.1);
double percentLength = (50);
triggers->Rumble(percentForce, 0, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
}
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
}
}

View File

@ -14,7 +14,6 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#pragma once
#include "../Common Files/Game.h"
class BG4JP : public Game {
int lastWasStop = 0;
public:
void FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers);

View File

@ -13,10 +13,15 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include <string>
#include "ChaseHQ2.h"
#include "SDL.h"
static SDL_Event e;
static EffectTriggers* myTriggers;
static EffectConstants* myConstants;
static Helpers* myHelpers;
int ttx2chasehq2(int ffRaw) {
switch (ffRaw) {
// moving right, from weakest to strongest (30 => 16).
case 28672:
return 30;
case 24640:
@ -48,7 +53,6 @@ int ttx2chasehq2(int ffRaw) {
case 30816:
return 16;
// moving left, from weakest to strongest (15 => 1)
case 20480:
return 15;
case 16448:
@ -85,53 +89,61 @@ int ttx2chasehq2(int ffRaw) {
}
}
void ChaseHQ2::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
int ff = 0;
static int RunningThread(void* ptr)
{
int cnt;
for (cnt = 0; cnt >= 0; ++cnt)
{
long ffAddress = helpers->ReadInt32(0x130B558, /* isRelativeOffset*/ true);
int ffRaw = helpers->ReadInt32(ffAddress + 0x45, /* isRelativeOffset */ false);
int lampArray[8] = { (16384) + 1, 16 ,1024 ,512, 128, 8, 256 };//The 1 isn't needed but I wasn't sure how to get the 16384 to see the first digit any other way lol
for (int i = 0; i < 7; i++) {
if ((ffRaw & lampArray[i]) == lampArray[i]) {
ffRaw -= lampArray[i];
}
};
int ff = 0;
{
long ffAddress = myHelpers->ReadInt32(0x130B558, true);
int ffRaw = myHelpers->ReadInt32(ffAddress + 0x45, false);
int lampArray[8] = { (16384) + 1, 16 ,1024 ,512, 128, 8, 256 };
for (int i = 0; i < 7; i++) {
if ((ffRaw & lampArray[i]) == lampArray[i]) {
ffRaw -= lampArray[i];
}
};
ff = ttx2chasehq2(ffRaw);
}
ff = ttx2chasehq2(ffRaw);
}
helpers->log("got value: ");
std::string ffs = std::to_string(ff);
helpers->log((char *)ffs.c_str());
myHelpers->log("got value: ");
std::string ffs = std::to_string(ff);
myHelpers->log((char*)ffs.c_str());
if (ff > 15)
{
helpers->log("moving wheel right");
// assume that 30 is the weakest and 16 is the strongest
double percentForce = (31 - ff) / 15.0;
double percentLength = 100;
// direction from left => makes wheel turn right
triggers->Rumble(percentForce, 0, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); // old logic: 31 - ff
lastWasStop = 0;
}
else if (ff > 0)
{
helpers->log("moving wheel left");
// assume that 1 is the strongest and 15 is the weakest
double percentForce = (16 - ff) / 15.0;
double percentLength = 100;
// direction from right => makes wheel turn left
triggers->Rumble(0, percentForce, percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); // old logic: 15 - ff
lastWasStop = 0;
}
else
{
if (lastWasStop == 0) {
triggers->Constant(constants->DIRECTION_FROM_LEFT, 0); // just pass the hash of 0 strength so we update lastEffectHash & lastEffectTime
lastWasStop = 1;
if (ff > 15)
{
myHelpers->log("moving wheel right");
double percentForce = (31 - ff) / 15.0;
double percentLength = 100;
myTriggers->Rumble(percentForce, 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce);
}
else if (ff > 0)
{
myHelpers->log("moving wheel left");
double percentForce = (16 - ff) / 15.0;
double percentLength = 100;
myTriggers->Rumble(0, percentForce, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce);
}
}
}
void ChaseHQ2::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
SDL_Thread* thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void*)NULL);
while (SDL_WaitEvent(&e) != 0)
{
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
}
}

View File

@ -14,7 +14,6 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#pragma once
#include "../Common Files/Game.h"
class ChaseHQ2 : public Game {
int lastWasStop = 0;
public:
void FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers);

View File

@ -140,8 +140,14 @@ static int RunningThread(void *ptr)
}
void Daytona3::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
SDL_Thread *thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void *)NULL);
UINT8 gear = helpers->ReadByte(0x019B468C, /* isRelativeOffset */ false);
int ff = helpers->ReadInt32(0x15AFC46, /* isRelativeOffset */ false);
helpers->log("got value: ");

View File

@ -14,7 +14,6 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#pragma once
#include "../Common Files/Game.h"
class Daytona3 : public Game {
int lastWasStop = 0;
public:
void FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers);

View File

@ -18,6 +18,12 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include "SDL.h"
static SDL_Event e;
static EffectTriggers* myTriggers;
static EffectConstants* myConstants;
static Helpers* myHelpers;
int nascar(int ffnas) {
switch (ffnas) {
@ -110,65 +116,84 @@ BOOL CALLBACK FindWindowBySubstr(HWND hwnd, LPARAM substring)
return true; // Need to continue enumerating windows
}
void Demul::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectTriggers * triggers) {
const TCHAR substring[] = TEXT("NASCAR");
EnumWindows(FindWindowBySubstr, (LPARAM)substring);
wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini");
int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename);
static int RunningThread(void* ptr)
{
int cnt;
for (cnt = 0; cnt >= 0; ++cnt)
{
int ffnascar = 0;
{
if (!EnumWindows(FindWindowBySubstr, (LPARAM)substring))
{
UINT8 ffnas = helpers->ReadByte(0x30060C, /* isRelativeOffset */ true); //Nascar Arcade
std::string ffs = std::to_string(ffnas);
helpers->log((char *)ffs.c_str());
helpers->log("got value: ");
ffnascar = nascar(ffnas);
const TCHAR substring[] = TEXT("NASCAR");
EnumWindows(FindWindowBySubstr, (LPARAM)substring);
wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini");
int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename);
if (FFBMode == 0)
{
int ffnascar = 0;
{
if (!EnumWindows(FindWindowBySubstr, (LPARAM)substring))
{
if ((ffnascar > 16) & (ffnascar < 33))
UINT8 ffnas = myHelpers->ReadByte(0x30060C, /* isRelativeOffset */ true); //Nascar Arcade
std::string ffs = std::to_string(ffnas);
myHelpers->log((char*)ffs.c_str());
myHelpers->log("got value: ");
ffnascar = nascar(ffnas);
if (FFBMode == 0)
{
helpers->log("moving wheel left");
double percentForce = (ffnascar - 16) / 16.0;
double percentLength = 100;
triggers->Rumble(percentForce, 0, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
if ((ffnascar > 16)& (ffnascar < 33))
{
myHelpers->log("moving wheel left");
double percentForce = (ffnascar - 16) / 16.0;
double percentLength = 100;
myTriggers->Rumble(percentForce, 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce);
}
else if ((ffnascar > 0)& (ffnascar < 17))
{
myHelpers->log("moving wheel right");
double percentForce = (17 - ffnascar) / 16.0;
double percentLength = 100;
myTriggers->Rumble(0, percentForce, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce);
}
}
else if ((ffnascar > 0) & (ffnascar < 17))
else
{
helpers->log("moving wheel right");
double percentForce = (17 - ffnascar) / 16.0;
double percentLength = 100;
triggers->Rumble(0, percentForce, percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
}
}
else
{
if ((ffnascar > 16) & (ffnascar < 33))
{
helpers->log("moving wheel left");
double percentForce = (ffnascar - 16) / 16.0;
double percentLength = 100;
triggers->Rumble(pow(percentForce, 0.5), 0, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, 0.5)));
}
else if ((ffnascar > 0) & (ffnascar < 17))
{
helpers->log("moving wheel right");
double percentForce = (17 - ffnascar) / 16.0;
double percentLength = 100;
triggers->Rumble(0, pow(percentForce, 0.5), percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, 0.5)));
if ((ffnascar > 16)& (ffnascar < 33))
{
myHelpers->log("moving wheel left");
double percentForce = (ffnascar - 16) / 16.0;
double percentLength = 100;
myTriggers->Rumble(pow(percentForce, 0.5), 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, (pow(percentForce, 0.5)));
}
else if ((ffnascar > 0)& (ffnascar < 17))
{
myHelpers->log("moving wheel right");
double percentForce = (17 - ffnascar) / 16.0;
double percentLength = 100;
myTriggers->Rumble(0, pow(percentForce, 0.5), percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, (pow(percentForce, 0.5)));
}
}
}
}
}
}
}
void Demul::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectTriggers * triggers) {
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
SDL_Thread* thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void*)NULL);
while (SDL_WaitEvent(&e) != 0)
{
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
}
}

View File

@ -13,43 +13,73 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include <string>
#include "FordRacing.h"
#include "SDL.h"
static EffectTriggers* myTriggers;
static EffectConstants* myConstants;
static Helpers* myHelpers;
static SDL_Event e;
static HANDLE hSection;
static LPVOID secData;
static int ffbOffset = 0;
void FordRacing::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
helpers->log("in FR Ffbloop");
const int ff = GetTeknoParrotFFB();
std::string ffs = std::to_string(ff);
helpers->log((char *)ffs.c_str());
static int TeknoParrotGame()
{
hSection = CreateFileMapping(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, 64, L"TeknoParrot_JvsState");
secData = MapViewOfFile(hSection, FILE_MAP_ALL_ACCESS, 0, 0, 64);
ffbOffset = *((int*)secData + 2);
return 0;
}
if (ff < -65505 && ff > -65515)
{
helpers->log("moving wheel left");
// -65507 => 9
// -65508 => 8
// -65515 => 1
// weirdly, FR has 9 levels, not 15, utilizing only -65506 (weakest) to -65514 (strongest)
double percentForce = (-65505 - ff) / 9.0;
double percentLength = 50;
// direction from left => makes wheel turn right
triggers->Rumble(0, percentForce, percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
lastWasStop = 0;
}
else if (ff > 0 && ff < 16)
{
helpers->log("moving wheel right");
// weirdly, FR has 9 levels, not 15, utilizing 15 (weakest) through 7 (strongest)
double percentForce = (16 - ff) / 9.0;
double percentLength = 50;
// direction from right => makes wheel turn left
triggers->Rumble(percentForce, 0, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
lastWasStop = 0;
}
else
{
if (lastWasStop == 0) {
triggers->Constant(constants->DIRECTION_FROM_LEFT, 0); // just pass the hash of 0 strength so we update lastEffectHash & lastEffectTime
lastWasStop = 1;
static int GetTeknoParrotFFB()
{
ffbOffset = *((int*)secData + 2);
return ffbOffset;
}
static int RunningThread(void* ptr)
{
int cnt;
for (cnt = 0; cnt >= 0; ++cnt)
{
int const ff = GetTeknoParrotFFB();
myHelpers->log("in FR Ffbloop");
std::string ffs = std::to_string(ff);
myHelpers->log((char*)ffs.c_str());
if (ff < -65505 && ff > -65515)
{
myHelpers->log("moving wheel left");
double percentForce = (-65505 - ff) / 9.0;
double percentLength = 100;
myTriggers->Rumble(0, percentForce, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce);
}
else if (ff > 0 && ff < 16)
{
myHelpers->log("moving wheel right");
double percentForce = (16 - ff) / 9.0;
double percentLength = 100;
myTriggers->Rumble(percentForce, 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce);
}
}
}
void FordRacing::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) {
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
TeknoParrotGame();
SDL_Thread* thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void*)NULL);
while (SDL_WaitEvent(&e) != 0)
{
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
}
}

View File

@ -12,10 +12,9 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
*/
#pragma once
#include "../Common Files/TeknoParrotGame.h"
#include "../Common Files/Game.h"
class FordRacing : public TeknoParrotGame {
class FordRacing : public Game {
public:
FordRacing() : TeknoParrotGame() { }
void FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers);
};

View File

@ -13,10 +13,11 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include <string>
#include "FordRacingOther.h"
#include "SDL.h"
static EffectTriggers *myTriggers;
static EffectConstants *myConstants;
static Helpers *myHelpers;
static SDL_Event e;
static bool init = false;
static int __stdcall Out32(DWORD device, DWORD data)
@ -64,24 +65,44 @@ static bool Hook(void * toHook, void * ourFunct, int len) {
static DWORD jmpBackAddy;
void FordRacingOther::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
HMODULE hMod = GetModuleHandleA("inpout32.dll");
if (hMod)
static int RunningThread(void* ptr)
{
int cnt;
for (cnt = 0; cnt >= 0; ++cnt)
{
if (!init)
HMODULE hMod = GetModuleHandleA("inpout32.dll");
if (hMod)
{
int hookLength = 6;
DWORD hookAddress = (DWORD)GetProcAddress(GetModuleHandle(L"inpout32.dll"), "Out32");
if (hookAddress)
{
jmpBackAddy = hookAddress + hookLength;
Hook((void*)hookAddress, Out32, hookLength);
init = true;
}
if (!init)
{
int hookLength = 6;
DWORD hookAddress = (DWORD)GetProcAddress(GetModuleHandle(L"inpout32.dll"), "Out32");
if (hookAddress)
{
jmpBackAddy = hookAddress + hookLength;
Hook((void*)hookAddress, Out32, hookLength);
init = true;
}
}
}
}
return 0;
}
void FordRacingOther::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
SDL_Thread* thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void*)NULL);
while (SDL_WaitEvent(&e) != 0)
{
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
}
}

View File

@ -112,6 +112,10 @@ static int RunningThread(void* ptr)
void GRID::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) {
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
SDL_Thread* thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void*)NULL);
@ -121,8 +125,4 @@ void GRID::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers*
myConstants = constants;
myHelpers = helpers;
}
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
}

View File

@ -14,68 +14,95 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include <string>
#include "GTIClub3.h"
#include "math.h"
#include "SDL.h"
static EffectTriggers* myTriggers;
static EffectConstants* myConstants;
static Helpers* myHelpers;
static SDL_Event e;
static int RunningThread(void* ptr)
{
int cnt;
for (cnt = 0; cnt >= 0; ++cnt)
{
wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini");
int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename);
UINT8 ff = myHelpers->ReadByte(0x00918CBC, /* isRelativeOffset */ false);
UINT8 ff1 = myHelpers->ReadByte(0x00918CBD, /* isRelativeOffset */ false);
UINT8 ff2 = myHelpers->ReadByte(0x00918CBE, /* isRelativeOffset */ false);
UINT8 menu = myHelpers->ReadByte(0x518E8E, /* isRelativeOffset */ true);
myHelpers->log("got value: ");
std::string ffs = std::to_string(ff2);
myHelpers->log((char*)ffs.c_str());
if (FFBMode == 0)
{
if ((ff1 > 0x00)& (ff1 < 0x40)& (menu == 0))
{
double percentForce = (ff1) / 63.0;
double percentLength = 100;
myTriggers->Rumble(percentForce, percentForce, percentLength);
myTriggers->Sine(120, 120, percentForce);
}
if ((ff > 0x80)& (ff < 0x101)& (menu == 0))
{
myHelpers->log("moving wheel right");
double percentForce = (257 - ff) / 128.0;
double percentLength = 100;
myTriggers->Rumble(percentForce, 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce);
}
else if ((ff > 0x00)& (ff < 0x80)& (menu == 0))
{
myHelpers->log("moving wheel left");
double percentForce = (ff) / 127.0;
double percentLength = 100;
myTriggers->Rumble(0, percentForce, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce);
}
}
else
{
if ((ff1 > 0x00)& (ff1 < 0x40)& (menu == 0))
{
double percentForce = (ff1) / 63.0;
double percentLength = 100;
myTriggers->Rumble(pow(percentForce, 0.5), pow(percentForce, 0.5), percentLength);
myTriggers->Sine(120, 120, pow(percentForce, 0.5));
}
if ((ff > 0x80)& (ff < 0x101)& (menu == 0))
{
myHelpers->log("moving wheel right");
double percentForce = (257 - ff) / 128.0;
double percentLength = 100;
myTriggers->Rumble(0, pow(percentForce, 0.5), percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, (pow(percentForce, 0.5)));
}
else if ((ff > 0x00)& (ff < 0x80)& (menu == 0))
{
myHelpers->log("moving wheel left");
double percentForce = (ff) / 127.0;
double percentLength = 100;
myTriggers->Rumble(pow(percentForce, 0.5), 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, (pow(percentForce, 0.5)));
}
}
}
}
void GTIClub3::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectTriggers * triggers) {
wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini");
int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename);
UINT8 ff = helpers->ReadByte(0x00918CBC, /* isRelativeOffset */ false);
UINT8 ff1 = helpers->ReadByte(0x00918CBD, /* isRelativeOffset */ false);
UINT8 ff2 = helpers->ReadByte(0x00918CBE, /* isRelativeOffset */ false);
UINT8 menu = helpers->ReadByte(0x518E8E, /* isRelativeOffset */ true);
helpers->log("got value: ");
std::string ffs = std::to_string(ff2);
helpers->log((char *)ffs.c_str());
if (FFBMode == 0)
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
SDL_Thread* thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void*)NULL);
while (SDL_WaitEvent(&e) != 0)
{
if ((ff1 > 0x00) & (ff1 < 0x40) & (menu == 0))
{
double percentForce = (ff1) / 63.0;
double percentLength = 100;
triggers->Rumble(percentForce, percentForce, percentLength);
triggers->Sine(120, 120, percentForce);
}
if ((ff > 0x80) & (ff < 0x101) & (menu == 0))
{
helpers->log("moving wheel right");
double percentForce = (257 - ff) / 128.0;
double percentLength = 100;
triggers->Rumble(percentForce, 0, percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
}
else if ((ff > 0x00) & (ff < 0x80) & (menu == 0))
{
helpers->log("moving wheel left");
double percentForce = (ff) / 127.0;
double percentLength = 100;
triggers->Rumble(0, percentForce, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
}
}
else
{
if ((ff1 > 0x00) & (ff1 < 0x40) & (menu == 0))
{
double percentForce = (ff1) / 63.0;
double percentLength = 100;
triggers->Rumble(pow(percentForce, 0.5), pow(percentForce, 0.5), percentLength);
triggers->Sine(120, 120, pow(percentForce, 0.5));
}
if ((ff > 0x80) & (ff < 0x101) & (menu == 0))
{
helpers->log("moving wheel right");
double percentForce = (257 - ff) / 128.0;
double percentLength = 100;
triggers->Rumble(0, pow(percentForce, 0.5), percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, 0.5)));
}
else if ((ff > 0x00) & (ff < 0x80) & (menu == 0))
{
helpers->log("moving wheel left");
double percentForce = (ff) / 127.0;
double percentLength = 100;
triggers->Rumble(pow(percentForce, 0.5), 0, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, 0.5)));
}
}
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
}
}

View File

@ -274,6 +274,10 @@ static int RunningThread(void *ptr)
void HOTD4::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
SDL_Thread *thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void *)NULL);
@ -326,8 +330,4 @@ void HOTD4::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers
myConstants = constants;
myHelpers = helpers;
}
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
}

View File

@ -14,78 +14,102 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include <string>
#include "InitialD4.h"
#include "math.h"
#include "SDL.h"
static EffectTriggers* myTriggers;
static EffectConstants* myConstants;
static Helpers* myHelpers;
static SDL_Event e;
static int RunningThread(void* ptr)
{
int cnt;
for (cnt = 0; cnt >= 0; ++cnt)
{
wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini");
int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename);
UINT8 ff = myHelpers->ReadByte(0x089AE89A, /* isRelativeOffset */ false);
UINT8 ff1 = myHelpers->ReadByte(0x089AE899, /* isRelativeOffset */ false);
UINT8 ff2 = myHelpers->ReadByte(0x089AE898, /* isRelativeOffset */ false);
myHelpers->log("got value: ");
std::string ffs = std::to_string(ff);
myHelpers->log((char*)ffs.c_str());
if (ff2 == 0x86)
{
myTriggers->Spring(0.8);
}
if (ff2 == 0x85) //cars colliding or rubbing against wall etc
{
if (ff1 > 0)
{
double percentLength = 200;
double percentForce = (0.6);
myTriggers->Friction(percentForce);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
}
if (FFBMode == 1)
{
if (ff2 == 0x84)
{
if ((ff > 0x37) && (ff < 0x80) && (ff1 == 0))
{
myHelpers->log("moving wheel right");
double percentForce = (128 - ff) / 72.0;
double percentLength = 100;
double powforce = (ff - 55) / 72.0;
myTriggers->Rumble(pow(percentForce, powforce), 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, (pow(percentForce, powforce)));
}
else if ((ff > 0x00) && (ff < 0x49) && (ff1 == 1))
{
myHelpers->log("moving wheel left");
double percentForce = (ff) / 72.0;
double percentLength = 100;
double powforce = (73 - ff) / 72.0;
myTriggers->Rumble(0, pow(percentForce, powforce), percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, (pow(percentForce, powforce)));
}
}
}
else
{
if (ff2 == 0x84)
{
if ((ff > 0x37) && (ff < 0x80) && (ff1 == 0))
{
myHelpers->log("moving wheel right");
double percentForce = (128 - ff) / 72.0;
double percentLength = 100;
myTriggers->Rumble(percentForce, 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce);
}
else if ((ff > 0x00) && (ff < 0x49) && (ff1 == 1))
{
myHelpers->log("moving wheel left");
double percentForce = (ff) / 72.0;
double percentLength = 100;
myTriggers->Rumble(0, percentForce, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce);
}
}
}
}
}
void InitialD4::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectTriggers * triggers){
wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini");
int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename);
UINT8 ff = helpers->ReadByte(0x089AE89A, /* isRelativeOffset */ false);
UINT8 ff1 = helpers->ReadByte(0x089AE899, /* isRelativeOffset */ false);
UINT8 ff2 = helpers->ReadByte(0x089AE898, /* isRelativeOffset */ false);
helpers->log("got value: ");
std::string ffs = std::to_string(ff);
helpers->log((char *)ffs.c_str());
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
if (ff2 == 0x86)
SDL_Thread* thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void*)NULL);
while (SDL_WaitEvent(&e) != 0)
{
triggers->Spring(0.8);
}
if (ff2 == 0x85) //cars colliding or rubbing against wall etc
{
if (ff1 > 0)
{
double percentLength = 200;
double percentForce = (0.6);
triggers->Inertia(percentForce);
triggers->Friction(percentForce);
triggers->Damper(percentForce);
triggers->Rumble(percentForce, percentForce, percentLength);
}
}
if (FFBMode == 1)
{
if (ff2 == 0x84)
{
if ((ff > 0x37) && (ff < 0x80) && (ff1 == 0))
{
helpers->log("moving wheel right");
double percentForce = (128 - ff) / 72.0;
double percentLength = 100;
double powforce = (ff - 55) / 72.0;
triggers->Rumble(pow(percentForce, powforce), 0, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, powforce)));
}
else if ((ff > 0x00) && (ff < 0x49) && (ff1 == 1))
{
helpers->log("moving wheel left");
double percentForce = (ff) / 72.0;
double percentLength = 100;
double powforce = (73 - ff) / 72.0;
triggers->Rumble(0, pow(percentForce, powforce), percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, powforce)));
}
}
}
else
{
if (ff2 == 0x84)
{
if ((ff > 0x37) && (ff < 0x80) && (ff1 == 0))
{
helpers->log("moving wheel right");
double percentForce = (128 - ff) / 72.0;
double percentLength = 100;
triggers->Rumble(percentForce, 0, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
}
else if ((ff > 0x00) && (ff < 0x49) && (ff1 == 1))
{
helpers->log("moving wheel left");
double percentForce = (ff) / 72.0;
double percentLength = 100;
triggers->Rumble(0, percentForce, percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
}
}
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
}
}

View File

@ -14,77 +14,102 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include <string>
#include "InitialD4Japan.h"
#include "math.h"
#include "SDL.h"
static EffectTriggers* myTriggers;
static EffectConstants* myConstants;
static Helpers* myHelpers;
static SDL_Event e;
static int RunningThread(void* ptr)
{
int cnt;
for (cnt = 0; cnt >= 0; ++cnt)
{
wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini");
int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename);
UINT8 ff = myHelpers->ReadByte(0x0898985A, /* isRelativeOffset */ false);
UINT8 ff1 = myHelpers->ReadByte(0x08989859, /* isRelativeOffset */ false);
UINT8 ff2 = myHelpers->ReadByte(0x08989858, /* isRelativeOffset */ false);
myHelpers->log("got value: ");
std::string ffs = std::to_string(ff);
myHelpers->log((char*)ffs.c_str());
if (ff2 == 0x86)
{
myTriggers->Spring(0.8);
}
if (ff2 == 0x85) //cars colliding or rubbing against wall etc
{
if (ff1 > 0)
{
double percentLength = 200;
double percentForce = (0.6);
myTriggers->Friction(percentForce);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
}
if (FFBMode == 1)
{
if (ff2 == 0x84)
{
if ((ff > 0x37) && (ff < 0x80) && (ff1 == 0))
{
myHelpers->log("moving wheel right");
double percentForce = (128 - ff) / 72.0;
double percentLength = 100;
double powforce = (ff - 55) / 72.0;
myTriggers->Rumble(pow(percentForce, powforce), 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, (pow(percentForce, powforce)));
}
else if ((ff > 0x00) && (ff < 0x49) && (ff1 == 1))
{
myHelpers->log("moving wheel left");
double percentForce = (ff) / 72.0;
double percentLength = 100;
double powforce = (73 - ff) / 72.0;
myTriggers->Rumble(0, pow(percentForce, powforce), percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, (pow(percentForce, powforce)));
}
}
}
else
{
if (ff2 == 0x84)
{
if ((ff > 0x37) && (ff < 0x80) && (ff1 == 0))
{
myHelpers->log("moving wheel right");
double percentForce = (128 - ff) / 72.0;
double percentLength = 100;
myTriggers->Rumble(percentForce, 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce);
}
else if ((ff > 0x00) && (ff < 0x49) && (ff1 == 1))
{
myHelpers->log("moving wheel left");
double percentForce = (ff) / 72.0;
double percentLength = 100;
myTriggers->Rumble(0, percentForce, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce);
}
}
}
}
}
void InitialD4Japan::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectTriggers * triggers) {
wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini");
int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename);
UINT8 ff = helpers->ReadByte(0x0898985A, /* isRelativeOffset */ false);
UINT8 ff1 = helpers->ReadByte(0x08989859, /* isRelativeOffset */ false);
UINT8 ff2 = helpers->ReadByte(0x08989858, /* isRelativeOffset */ false);
helpers->log("got value: ");
std::string ffs = std::to_string(ff);
helpers->log((char *)ffs.c_str());
if (ff2 == 0x86)
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
SDL_Thread* thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void*)NULL);
while (SDL_WaitEvent(&e) != 0)
{
triggers->Spring(0.8);
}
if (ff2 == 0x85) //cars colliding or rubbing against wall etc
{
if (ff1 > 0)
{
double percentLength = 200;
double percentForce = (0.6);
triggers->Inertia(percentForce);
triggers->Friction(percentForce);
triggers->Damper(percentForce);
triggers->Rumble(percentForce, percentForce, percentLength);
}
}
if (FFBMode == 1)
{
if (ff2 == 0x84)
{
if ((ff > 0x37) && (ff < 0x80) && (ff1 == 0))
{
helpers->log("moving wheel right");
double percentForce = (128 - ff) / 72.0;
double percentLength = 100;
double powforce = (ff - 55) / 72.0;
triggers->Rumble(pow(percentForce, powforce), 0, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, powforce)));
}
else if ((ff > 0x00) && (ff < 0x49) && (ff1 == 1))
{
helpers->log("moving wheel left");
double percentForce = (ff) / 72.0;
double percentLength = 100;
double powforce = (73 - ff) / 72.0;
triggers->Rumble(0, pow(percentForce, powforce), percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, powforce)));
}
}
}
else
{
if (ff2 == 0x84)
{
if ((ff > 0x37) && (ff < 0x80) && (ff1 == 0))
{
helpers->log("moving wheel right");
double percentForce = (128 - ff) / 72.0;
double percentLength = 100;
triggers->Rumble(percentForce, 0, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
}
else if ((ff > 0x00) && (ff < 0x49) && (ff1 == 1))
{
helpers->log("moving wheel left");
double percentForce = (ff) / 72.0;
double percentLength = 100;
triggers->Rumble(0, percentForce, percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
}
}
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
}
}

View File

@ -14,78 +14,102 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include <string>
#include "InitialD5.h"
#include "math.h"
#include "SDL.h"
static EffectTriggers* myTriggers;
static EffectConstants* myConstants;
static Helpers* myHelpers;
static SDL_Event e;
static int RunningThread(void* ptr)
{
int cnt;
for (cnt = 0; cnt >= 0; ++cnt)
{
wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini");
int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename);
UINT8 ff = myHelpers->ReadByte(0x08CB6122, /* isRelativeOffset */ false);
UINT8 ff1 = myHelpers->ReadByte(0x08CB6121, /* isRelativeOffset */ false);
UINT8 ff2 = myHelpers->ReadByte(0x08CB6120, /* isRelativeOffset */ false);
myHelpers->log("got value: ");
std::string ffs = std::to_string(ff);
myHelpers->log((char*)ffs.c_str());
if (ff2 == 0x86)
{
myTriggers->Spring(0.8);
}
if (ff2 == 0x85) //cars colliding or rubbing against wall etc
{
if (ff1 > 0)
{
double percentLength = 200;
double percentForce = (0.6);
myTriggers->Friction(percentForce);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
}
if (FFBMode == 1)
{
if (ff2 == 0x84)
{
if ((ff > 0x37) && (ff < 0x80) && (ff1 == 0))
{
myHelpers->log("moving wheel right");
double percentForce = (128 - ff) / 72.0;
double percentLength = 100;
double powforce = (ff - 55) / 72.0;
myTriggers->Rumble(pow(percentForce, powforce), 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, (pow(percentForce, powforce)));
}
else if ((ff > 0x00) && (ff < 0x49) && (ff1 == 1))
{
myHelpers->log("moving wheel left");
double percentForce = (ff) / 72.0;
double percentLength = 100;
double powforce = (73 - ff) / 72.0;
myTriggers->Rumble(0, pow(percentForce, powforce), percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, (pow(percentForce, powforce)));
}
}
}
else
{
if (ff2 == 0x84)
{
if ((ff > 0x37) && (ff < 0x80) && (ff1 == 0))
{
myHelpers->log("moving wheel right");
double percentForce = (128 - ff) / 72.0;
double percentLength = 100;
myTriggers->Rumble(percentForce, 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce);
}
else if ((ff > 0x00) && (ff < 0x49) && (ff1 == 1))
{
myHelpers->log("moving wheel left");
double percentForce = (ff) / 72.0;
double percentLength = 100;
myTriggers->Rumble(0, percentForce, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce);
}
}
}
}
}
void InitialD5::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectTriggers * triggers) {
wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini");
int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename);
UINT8 ff = helpers->ReadByte(0x08CB6122, /* isRelativeOffset */ false);
UINT8 ff1 = helpers->ReadByte(0x08CB6121, /* isRelativeOffset */ false);
UINT8 ff2 = helpers->ReadByte(0x08CB6120, /* isRelativeOffset */ false);
helpers->log("got value: ");
std::string ffs = std::to_string(ff);
helpers->log((char *)ffs.c_str());
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
if (ff2 == 0x86)
SDL_Thread* thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void*)NULL);
while (SDL_WaitEvent(&e) != 0)
{
triggers->Spring(0.8);
}
if (ff2 == 0x85) //cars colliding or rubbing against wall etc
{
if (ff1 > 0)
{
double percentLength = 200;
double percentForce = (0.6);
triggers->Inertia(percentForce);
triggers->Friction(percentForce);
triggers->Damper(percentForce);
triggers->Rumble(percentForce, percentForce, percentLength);
}
}
if (FFBMode == 1)
{
if (ff2 == 0x84)
{
if ((ff > 0x37) && (ff < 0x80) && (ff1 == 0))
{
helpers->log("moving wheel right");
double percentForce = (128 - ff) / 72.0;
double percentLength = 100;
double powforce = (ff - 55) / 72.0;
triggers->Rumble(pow(percentForce, powforce), 0, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, powforce)));
}
else if ((ff > 0x00) && (ff < 0x49) && (ff1 == 1))
{
helpers->log("moving wheel left");
double percentForce = (ff) / 72.0;
double percentLength = 100;
double powforce = (73 - ff) / 72.0;
triggers->Rumble(0, pow(percentForce, powforce), percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, powforce)));
}
}
}
else
{
if (ff2 == 0x84)
{
if ((ff > 0x37) && (ff < 0x80) && (ff1 == 0))
{
helpers->log("moving wheel right");
double percentForce = (128 - ff) / 72.0;
double percentLength = 100;
triggers->Rumble(percentForce, 0, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
}
else if ((ff > 0x00) && (ff < 0x49) && (ff1 == 1))
{
helpers->log("moving wheel left");
double percentForce = (ff) / 72.0;
double percentLength = 100;
triggers->Rumble(0, percentForce, percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
}
}
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
}
}

View File

@ -13,6 +13,14 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include <string>
#include "InitialD6.h"
#include "SDL.h"
static EffectTriggers* myTriggers;
static EffectConstants* myConstants;
static Helpers* myHelpers;
static SDL_Event e;
static HANDLE hSection;
static LPVOID secData;
static int ffbOffset = 0;
static int carscollide(int ffcollide) {
switch (ffcollide) {
@ -122,77 +130,110 @@ static int rubbingwalls(int ffwalls) {
}
}
void InitialD6::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectTriggers * triggers)
static int TeknoParrotGame()
{
int ffrubbingwalls = 0;
int ffcarcollision = 0;
{
wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini");
int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename);
helpers->log("in ID6 Ffbloop");
const int ff = GetTeknoParrotFFB();
std::string ffs = std::to_string(ff);
helpers->log((char *)ffs.c_str());
ffcarcollision = carscollide(ff);
ffrubbingwalls = rubbingwalls(ff);
hSection = CreateFileMapping(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, 64, L"TeknoParrot_JvsState");
secData = MapViewOfFile(hSection, FILE_MAP_ALL_ACCESS, 0, 0, 64);
ffbOffset = *((int*)secData + 2);
return 0;
}
if (ff == 0x60000)
static int GetTeknoParrotFFB()
{
ffbOffset = *((int*)secData + 2);
return ffbOffset;
}
static int RunningThread(void* ptr)
{
int cnt;
for (cnt = 0; cnt >= 0; ++cnt)
{
int ffrubbingwalls = 0;
int ffcarcollision = 0;
{
triggers->Spring(0.8);
}
if (ffrubbingwalls > 0) // car rubbing against wall
{
double percentLength = 200;
double percentForce = (ffrubbingwalls / 31.0);
triggers->Inertia(percentForce);
triggers->Friction(percentForce);
triggers->Damper(percentForce);
triggers->Rumble(percentForce, percentForce, percentLength);
}
if (ffcarcollision > 0) //cars colliding or rubbing with each other
{
double percentLength = 200;
double percentForce = (ffcarcollision / 16.0);
triggers->Inertia(percentForce);
triggers->Friction(percentForce);
triggers->Damper(percentForce);
triggers->Rumble(percentForce, percentForce, percentLength);
}
if (FFBMode == 1)
{
if ((ff > 0x40037) & (ff < 0x40080))
wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini");
int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename);
myHelpers->log("in ID6 Ffbloop");
const int ff = GetTeknoParrotFFB();
std::string ffs = std::to_string(ff);
myHelpers->log((char*)ffs.c_str());
ffcarcollision = carscollide(ff);
ffrubbingwalls = rubbingwalls(ff);
if (ff == 0x60000)
{
double percentForce = (262272 - ff) / 72.0;
double percentLength = 100;
double powforce = (ff - 262199) / 72.0;
triggers->Rumble(pow(percentForce, powforce), 0, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, powforce)));
myTriggers->Spring(0.8);
}
else if ((ff > 0x40100) & (ff < 0x40149))
if (ffrubbingwalls > 0) // car rubbing against wall
{
double percentForce = (ff - 262400) / 72.0;
double percentLength = 100;
double powforce = (262473 - ff) / 72.0;
triggers->Rumble(0, pow(percentForce, powforce), percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, powforce)));
double percentLength = 200;
double percentForce = (ffrubbingwalls / 31.0);
myTriggers->Friction(percentForce);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
}
else
{
if ((ff > 0x40037) & (ff < 0x40080))
if (ffcarcollision > 0) //cars colliding or rubbing with each other
{
double percentForce = (262272 - ff) / 72.0;
double percentLength = 100;
triggers->Rumble(percentForce, 0, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
double percentLength = 200;
double percentForce = (ffcarcollision / 16.0);
myTriggers->Friction(percentForce);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if ((ff > 0x40100) & (ff < 0x40149))
if (FFBMode == 1)
{
double percentForce = (ff - 262400) / 72.0;
double percentLength = 100;
triggers->Rumble(0, percentForce, percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
if ((ff > 0x40037)& (ff < 0x40080))
{
double percentForce = (262272 - ff) / 72.0;
double percentLength = 100;
double powforce = (ff - 262199) / 72.0;
myTriggers->Rumble(pow(percentForce, powforce), 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, (pow(percentForce, powforce)));
}
else if ((ff > 0x40100)& (ff < 0x40149))
{
double percentForce = (ff - 262400) / 72.0;
double percentLength = 100;
double powforce = (262473 - ff) / 72.0;
myTriggers->Rumble(0, pow(percentForce, powforce), percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, (pow(percentForce, powforce)));
}
}
else
{
if ((ff > 0x40037)& (ff < 0x40080))
{
double percentForce = (262272 - ff) / 72.0;
double percentLength = 100;
myTriggers->Rumble(percentForce, 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce);
}
else if ((ff > 0x40100)& (ff < 0x40149))
{
double percentForce = (ff - 262400) / 72.0;
double percentLength = 100;
myTriggers->Rumble(0, percentForce, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce);
}
}
}
}
}
void InitialD6::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectTriggers * triggers){
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
TeknoParrotGame();
SDL_Thread* thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void*)NULL);
while (SDL_WaitEvent(&e) != 0)
{
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
}
}

View File

@ -12,10 +12,9 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
*/
#pragma once
#include "../Common Files/TeknoParrotGame.h"
#include "../Common Files/Game.h"
class InitialD6 : public TeknoParrotGame {
class InitialD6 : public Game {
public:
InitialD6() : TeknoParrotGame() { }
void FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers);
};

View File

@ -13,6 +13,14 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include <string>
#include "InitialD7.h"
#include "SDL.h"
static EffectTriggers* myTriggers;
static EffectConstants* myConstants;
static Helpers* myHelpers;
static SDL_Event e;
static HANDLE hSection;
static LPVOID secData;
static int ffbOffset = 0;
static int carscollide(int ffcollide) {
switch (ffcollide) {
@ -122,77 +130,110 @@ static int rubbingwalls(int ffwalls) {
}
}
void InitialD7::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectTriggers * triggers)
static int TeknoParrotGame()
{
int ffrubbingwalls = 0;
int ffcarcollision = 0;
{
wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini");
int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename);
helpers->log("in ID7 Ffbloop");
const int ff = GetTeknoParrotFFB();
std::string ffs = std::to_string(ff);
helpers->log((char *)ffs.c_str());
ffcarcollision = carscollide(ff);
ffrubbingwalls = rubbingwalls(ff);
hSection = CreateFileMapping(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, 64, L"TeknoParrot_JvsState");
secData = MapViewOfFile(hSection, FILE_MAP_ALL_ACCESS, 0, 0, 64);
ffbOffset = *((int*)secData + 2);
return 0;
}
if (ff == 0x60000)
static int GetTeknoParrotFFB()
{
ffbOffset = *((int*)secData + 2);
return ffbOffset;
}
static int RunningThread(void* ptr)
{
int cnt;
for (cnt = 0; cnt >= 0; ++cnt)
{
int ffrubbingwalls = 0;
int ffcarcollision = 0;
{
triggers->Spring(0.8);
}
if (ffrubbingwalls > 0) // car rubbing against wall
{
double percentLength = 200;
double percentForce = (ffrubbingwalls / 31.0);
triggers->Inertia(percentForce);
triggers->Friction(percentForce);
triggers->Damper(percentForce);
triggers->Rumble(percentForce, percentForce, percentLength);
}
if (ffcarcollision > 0) //cars colliding or rubbing with each other
{
double percentLength = 200;
double percentForce = (ffcarcollision / 16.0);
triggers->Inertia(percentForce);
triggers->Friction(percentForce);
triggers->Damper(percentForce);
triggers->Rumble(percentForce, percentForce, percentLength);
}
if (FFBMode == 1)
{
if ((ff > 0x40037) & (ff < 0x40080))
wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini");
int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename);
myHelpers->log("in ID6 Ffbloop");
const int ff = GetTeknoParrotFFB();
std::string ffs = std::to_string(ff);
myHelpers->log((char*)ffs.c_str());
ffcarcollision = carscollide(ff);
ffrubbingwalls = rubbingwalls(ff);
if (ff == 0x60000)
{
double percentForce = (262272 - ff) / 72.0;
double percentLength = 100;
double powforce = (ff - 262199) / 72.0;
triggers->Rumble(pow(percentForce, powforce), 0, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, powforce)));
myTriggers->Spring(0.8);
}
else if ((ff > 0x40100) & (ff < 0x40149))
if (ffrubbingwalls > 0) // car rubbing against wall
{
double percentForce = (ff - 262400) / 72.0;
double percentLength = 100;
double powforce = (262473 - ff) / 72.0;
triggers->Rumble(0, pow(percentForce, powforce), percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, powforce)));
double percentLength = 200;
double percentForce = (ffrubbingwalls / 31.0);
myTriggers->Friction(percentForce);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
}
else
{
if ((ff > 0x40037) & (ff < 0x40080))
if (ffcarcollision > 0) //cars colliding or rubbing with each other
{
double percentForce = (262272 - ff) / 72.0;
double percentLength = 100;
triggers->Rumble(percentForce, 0, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
double percentLength = 200;
double percentForce = (ffcarcollision / 16.0);
myTriggers->Friction(percentForce);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if ((ff > 0x40100) & (ff < 0x40149))
if (FFBMode == 1)
{
double percentForce = (ff - 262400) / 72.0;
double percentLength = 100;
triggers->Rumble(0, percentForce, percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
if ((ff > 0x40037)& (ff < 0x40080))
{
double percentForce = (262272 - ff) / 72.0;
double percentLength = 100;
double powforce = (ff - 262199) / 72.0;
myTriggers->Rumble(pow(percentForce, powforce), 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, (pow(percentForce, powforce)));
}
else if ((ff > 0x40100)& (ff < 0x40149))
{
double percentForce = (ff - 262400) / 72.0;
double percentLength = 100;
double powforce = (262473 - ff) / 72.0;
myTriggers->Rumble(0, pow(percentForce, powforce), percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, (pow(percentForce, powforce)));
}
}
else
{
if ((ff > 0x40037)& (ff < 0x40080))
{
double percentForce = (262272 - ff) / 72.0;
double percentLength = 100;
myTriggers->Rumble(percentForce, 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce);
}
else if ((ff > 0x40100)& (ff < 0x40149))
{
double percentForce = (ff - 262400) / 72.0;
double percentLength = 100;
myTriggers->Rumble(0, percentForce, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce);
}
}
}
}
}
void InitialD7::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) {
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
TeknoParrotGame();
SDL_Thread* thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void*)NULL);
while (SDL_WaitEvent(&e) != 0)
{
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
}
}

View File

@ -12,10 +12,9 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
*/
#pragma once
#include "../Common Files/TeknoParrotGame.h"
#include "../Common Files/Game.h"
class InitialD7 : public TeknoParrotGame {
class InitialD7 : public Game {
public:
InitialD7() : TeknoParrotGame() { }
void FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers);
};

View File

@ -13,6 +13,14 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include <string>
#include "InitialD8.h"
#include "SDL.h"
static EffectTriggers* myTriggers;
static EffectConstants* myConstants;
static Helpers* myHelpers;
static SDL_Event e;
static HANDLE hSection;
static LPVOID secData;
static int ffbOffset = 0;
static int carscollide(int ffcollide) {
switch (ffcollide) {
@ -122,77 +130,110 @@ static int rubbingwalls(int ffwalls) {
}
}
void InitialD8::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectTriggers * triggers)
static int TeknoParrotGame()
{
int ffrubbingwalls = 0;
int ffcarcollision = 0;
{
wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini");
int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename);
helpers->log("in ID8 Ffbloop");
const int ff = GetTeknoParrotFFB();
std::string ffs = std::to_string(ff);
helpers->log((char *)ffs.c_str());
ffcarcollision = carscollide(ff);
ffrubbingwalls = rubbingwalls(ff);
hSection = CreateFileMapping(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, 64, L"TeknoParrot_JvsState");
secData = MapViewOfFile(hSection, FILE_MAP_ALL_ACCESS, 0, 0, 64);
ffbOffset = *((int*)secData + 2);
return 0;
}
if (ff == 0x60000)
static int GetTeknoParrotFFB()
{
ffbOffset = *((int*)secData + 2);
return ffbOffset;
}
static int RunningThread(void* ptr)
{
int cnt;
for (cnt = 0; cnt >= 0; ++cnt)
{
int ffrubbingwalls = 0;
int ffcarcollision = 0;
{
triggers->Spring(0.8);
}
if (ffrubbingwalls > 0) // car rubbing against wall
{
double percentLength = 200;
double percentForce = (ffrubbingwalls / 31.0);
triggers->Inertia(percentForce);
triggers->Friction(percentForce);
triggers->Damper(percentForce);
triggers->Rumble(percentForce, percentForce, percentLength);
}
if (ffcarcollision > 0) //cars colliding or rubbing with each other
{
double percentLength = 200;
double percentForce = (ffcarcollision / 16.0);
triggers->Inertia(percentForce);
triggers->Friction(percentForce);
triggers->Damper(percentForce);
triggers->Rumble(percentForce, percentForce, percentLength);
}
if (FFBMode == 1)
{
if ((ff > 0x40037) & (ff < 0x40080))
wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini");
int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename);
myHelpers->log("in ID6 Ffbloop");
const int ff = GetTeknoParrotFFB();
std::string ffs = std::to_string(ff);
myHelpers->log((char*)ffs.c_str());
ffcarcollision = carscollide(ff);
ffrubbingwalls = rubbingwalls(ff);
if (ff == 0x60000)
{
double percentForce = (262272 - ff) / 72.0;
double percentLength = 100;
double powforce = (ff - 262199) / 72.0;
triggers->Rumble(pow(percentForce, powforce), 0, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, powforce)));
myTriggers->Spring(0.8);
}
else if ((ff > 0x40100) & (ff < 0x40149))
if (ffrubbingwalls > 0) // car rubbing against wall
{
double percentForce = (ff - 262400) / 72.0;
double percentLength = 100;
double powforce = (262473 - ff) / 72.0;
triggers->Rumble(0, pow(percentForce, powforce), percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, powforce)));
double percentLength = 200;
double percentForce = (ffrubbingwalls / 31.0);
myTriggers->Friction(percentForce);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
}
else
{
if ((ff > 0x40037) & (ff < 0x40080))
if (ffcarcollision > 0) //cars colliding or rubbing with each other
{
double percentForce = (262272 - ff) / 72.0;
double percentLength = 100;
triggers->Rumble(percentForce, 0, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
double percentLength = 200;
double percentForce = (ffcarcollision / 16.0);
myTriggers->Friction(percentForce);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if ((ff > 0x40100) & (ff < 0x40149))
if (FFBMode == 1)
{
double percentForce = (ff - 262400) / 72.0;
double percentLength = 100;
triggers->Rumble(0, percentForce, percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
if ((ff > 0x40037)& (ff < 0x40080))
{
double percentForce = (262272 - ff) / 72.0;
double percentLength = 100;
double powforce = (ff - 262199) / 72.0;
myTriggers->Rumble(pow(percentForce, powforce), 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, (pow(percentForce, powforce)));
}
else if ((ff > 0x40100)& (ff < 0x40149))
{
double percentForce = (ff - 262400) / 72.0;
double percentLength = 100;
double powforce = (262473 - ff) / 72.0;
myTriggers->Rumble(0, pow(percentForce, powforce), percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, (pow(percentForce, powforce)));
}
}
else
{
if ((ff > 0x40037)& (ff < 0x40080))
{
double percentForce = (262272 - ff) / 72.0;
double percentLength = 100;
myTriggers->Rumble(percentForce, 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce);
}
else if ((ff > 0x40100)& (ff < 0x40149))
{
double percentForce = (ff - 262400) / 72.0;
double percentLength = 100;
myTriggers->Rumble(0, percentForce, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce);
}
}
}
}
}
void InitialD8::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) {
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
TeknoParrotGame();
SDL_Thread* thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void*)NULL);
while (SDL_WaitEvent(&e) != 0)
{
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
}
}

View File

@ -12,10 +12,9 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
*/
#pragma once
#include "../Common Files/TeknoParrotGame.h"
#include "../Common Files/Game.h"
class InitialD8 : public TeknoParrotGame {
class InitialD8 : public Game {
public:
InitialD8() : TeknoParrotGame() { }
void FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers);
};

View File

@ -13,60 +13,87 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include <string>
#include "KODrive.h"
#include "SDL.h"
static EffectTriggers* myTriggers;
static EffectConstants* myConstants;
static Helpers* myHelpers;
static SDL_Event e;
static int RunningThread(void* ptr)
{
int cnt;
for (cnt = 0; cnt >= 0; ++cnt)
{
UINT8 ff = myHelpers->ReadByte(0x00B261F6, /* isRelativeOffset */ false);
UINT8 ff1 = myHelpers->ReadByte(0x00B261F5, /* isRelativeOffset */ false);
wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini");
int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename);
myHelpers->log("got value: ");
std::string ffs = std::to_string(ff);
myHelpers->log((char*)ffs.c_str());
if ((ff == 10) & (ff1 == 30))
{
double percentForce = 0.4;
double percentForce1 = 1.0;
double percentLength = 100;
myTriggers->Rumble(percentForce1, percentForce1, percentLength);
myTriggers->Sine(80, 80, percentForce);
}
if (FFBMode == 1)
{
if ((ff > 0x66)& (ff < 0x80)& (ff1 == 0))
{
myHelpers->log("moving wheel right");
double percentForce = (128 - ff) / 24.0;
double percentLength = 100;
myTriggers->Rumble(pow(percentForce, 0.5), 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, (pow(percentForce, 0.5)));
}
else if ((ff > 0x00)& (ff < 0x19)& (ff1 == 1))
{
myHelpers->log("moving wheel left");
double percentForce = (ff) / 24.0;
double percentLength = 100;
myTriggers->Rumble(0, pow(percentForce, 0.5), percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, (pow(percentForce, 0.5)));
}
}
else
{
if ((ff > 0x66)& (ff < 0x80)& (ff1 == 0))
{
myHelpers->log("moving wheel right");
double percentForce = (128 - ff) / 24.0;
double percentLength = 100;
myTriggers->Rumble(percentForce, 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce);
}
else if ((ff > 0x00)& (ff < 0x19)& (ff1 == 1))
{
myHelpers->log("moving wheel left");
double percentForce = (ff) / 24.0;
double percentLength = 100;
myTriggers->Rumble(0, percentForce, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce);
}
}
}
}
void KODrive::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectTriggers * triggers) {
UINT8 ff = helpers->ReadByte(0x00B261F6, /* isRelativeOffset */ false);
UINT8 ff1 = helpers->ReadByte(0x00B261F5, /* isRelativeOffset */ false);
wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini");
int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename);
helpers->log("got value: ");
std::string ffs = std::to_string(ff);
helpers->log((char *)ffs.c_str());
if ((ff == 10) & (ff1 == 30))
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
SDL_Thread* thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void*)NULL);
while (SDL_WaitEvent(&e) != 0)
{
double percentForce = 0.4;
double percentForce1 = 2.7;
double percentLength = 100;
triggers->Rumble(percentForce1, percentForce1, percentLength);
triggers->Sine(80, 80, percentForce);
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
}
if (FFBMode == 1)
{
if ((ff > 0x66) & (ff < 0x80) & (ff1 == 0))
{
helpers->log("moving wheel right");
double percentForce = (128 - ff) / 24.0;
double percentLength = 100;
triggers->Rumble(pow(percentForce, 0.5), 0, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, 0.5)));
}
else if ((ff > 0x00) & (ff < 0x19) & (ff1 == 1))
{
helpers->log("moving wheel left");
double percentForce = (ff) / 24.0;
double percentLength = 100;
triggers->Rumble(0, pow(percentForce, 0.5), percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, 0.5)));
}
}
else
{
if ((ff > 0x66) & (ff < 0x80) & (ff1 == 0))
{
helpers->log("moving wheel right");
double percentForce = (128 - ff) / 24.0;
double percentLength = 100;
triggers->Rumble(percentForce, 0, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
}
else if ((ff > 0x00) & (ff < 0x19) & (ff1 == 1))
{
helpers->log("moving wheel left");
double percentForce = (ff) / 24.0;
double percentLength = 100;
triggers->Rumble(0, percentForce, percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
}
}
}

View File

@ -15,44 +15,242 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include "LGI.h"
#include "SDL.h"
#include <Windows.h>
#include "SDL.h"
static EffectTriggers* myTriggers;
static EffectConstants* myConstants;
static Helpers* myHelpers;
static SDL_Event e;
extern int joystick_index1;
extern int joystick_index2;
extern SDL_Joystick* GameController2;
extern SDL_Haptic* ControllerHaptic2;
extern SDL_Haptic* haptic2;
void LGI::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
int ff = helpers->ReadIntPtr(0x0063BF5C, /* isRelativeOffset */ true);
UINT8 ff1 = helpers->ReadByte(ff + 0x44, /* isRelativeOffset */ false);
INT_PTR health1p1 = helpers->ReadIntPtr(0x00820024, /* isRelativeOffset*/ true);
INT_PTR health1p2 = helpers->ReadIntPtr(health1p1 + 0x4, /* isRelativeOffset */ false);
INT_PTR health1p3 = helpers->ReadIntPtr(health1p2 + 0x58, /* isRelativeOffset */ false);
INT_PTR health2p3 = helpers->ReadIntPtr(health1p2 + 0x5C, /* isRelativeOffset */ false);
float health1p = helpers->ReadFloat32(health1p3 + 0x14, /* isRelativeOffset */ false); //1p health
float health2p = helpers->ReadFloat32(health2p3 + 0x14, /* isRelativeOffset */ false); //2p health
helpers->log("got value: ");
std::string ffs = std::to_string(ff1);
helpers->log((char *)ffs.c_str());
float static oldFloat1 = 0.0;
float static oldFloat2 = 0.0;
float newFloat1 = health1p;
float newFloat2 = health2p;
static wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini");
wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini");
int configFeedbackLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("FeedbackLength"), 120, settingsFilename);
int HowtoRumbleKnockEffect = GetPrivateProfileInt(TEXT("Settings"), TEXT("HowtoRumbleKnockEffect"), 0, settingsFilename);
int HowtoRumbleMotorEffect = GetPrivateProfileInt(TEXT("Settings"), TEXT("HowtoRumbleMotorEffect"), 0, settingsFilename);
int HowtoRumbleHealthEffect = GetPrivateProfileInt(TEXT("Settings"), TEXT("HowtoRumbleHealthEffect"), 0, settingsFilename);
int Knock1pStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Knock1pStrength"), 0, settingsFilename);
int Motor1pStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Motor1pStrength"), 0, settingsFilename);
int Health1pStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Health1pStrength"), 0, settingsFilename);
int Knock2pStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Knock2pStrength"), 0, settingsFilename);
int Motor2pStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Motor2pStrength"), 0, settingsFilename);
int Health2pStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Health2pStrength"), 0, settingsFilename);
static int RunningThread(void* ptr)
{
int cnt;
for (cnt = 0; cnt >= 0; ++cnt)
{
int ff = myHelpers->ReadIntPtr(0x0063BF5C, /* isRelativeOffset */ true);
UINT8 ff1 = myHelpers->ReadByte(ff + 0x44, /* isRelativeOffset */ false);
INT_PTR health1p1 = myHelpers->ReadIntPtr(0x00820024, /* isRelativeOffset*/ true);
INT_PTR health1p2 = myHelpers->ReadIntPtr(health1p1 + 0x4, /* isRelativeOffset */ false);
INT_PTR health1p3 = myHelpers->ReadIntPtr(health1p2 + 0x58, /* isRelativeOffset */ false);
INT_PTR health2p3 = myHelpers->ReadIntPtr(health1p2 + 0x5C, /* isRelativeOffset */ false);
float health1p = myHelpers->ReadFloat32(health1p3 + 0x14, /* isRelativeOffset */ false); //1p health
float health2p = myHelpers->ReadFloat32(health2p3 + 0x14, /* isRelativeOffset */ false); //2p health
myHelpers->log("got value: ");
std::string ffs = std::to_string(ff1);
myHelpers->log((char*)ffs.c_str());
float static oldFloat1 = 0.0;
float static oldFloat2 = 0.0;
float newFloat1 = health1p;
float newFloat2 = health2p;
int configFeedbackLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("FeedbackLength"), 120, settingsFilename);
int HowtoRumbleKnockEffect = GetPrivateProfileInt(TEXT("Settings"), TEXT("HowtoRumbleKnockEffect"), 0, settingsFilename);
int HowtoRumbleMotorEffect = GetPrivateProfileInt(TEXT("Settings"), TEXT("HowtoRumbleMotorEffect"), 0, settingsFilename);
int HowtoRumbleHealthEffect = GetPrivateProfileInt(TEXT("Settings"), TEXT("HowtoRumbleHealthEffect"), 0, settingsFilename);
int Knock1pStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Knock1pStrength"), 0, settingsFilename);
int Motor1pStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Motor1pStrength"), 0, settingsFilename);
int Health1pStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Health1pStrength"), 0, settingsFilename);
int Knock2pStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Knock2pStrength"), 0, settingsFilename);
int Motor2pStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Motor2pStrength"), 0, settingsFilename);
int Health2pStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Health2pStrength"), 0, settingsFilename);
if ((oldFloat1 != newFloat1) && (health1p != 0x1))
{
if (HowtoRumbleHealthEffect == 0)
{
double percentForce = ((Health1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleHealthEffect == 1)
{
double percentForce = ((Health1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(0, percentForce, percentLength);
}
else if (HowtoRumbleHealthEffect == 2)
{
double percentForce = ((Health1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(percentForce, 0, percentLength);
}
}
if ((oldFloat2 != newFloat2) && (health2p != 0x1))
{
if (HowtoRumbleHealthEffect == 0)
{
double percentForce = ((Health2pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->RumbleDevice2(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleHealthEffect == 1)
{
double percentForce = ((Health2pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->RumbleDevice2(0, percentForce, percentLength);
}
else if (HowtoRumbleHealthEffect == 2)
{
double percentForce = ((Health2pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->RumbleDevice2(percentForce, 0, percentLength);
}
}
if (ff1 == 0x20)
{
if (HowtoRumbleKnockEffect == 0)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 1)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(0, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 2)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(percentForce, 0, percentLength);
}
}
if (ff1 == 0x40)
{
if (HowtoRumbleMotorEffect == 0)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 1)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(0, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 2)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(percentForce, 0, percentLength);
}
}
if (ff1 == 0x4)
{
if (HowtoRumbleKnockEffect == 0)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->RumbleDevice2(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 1)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->RumbleDevice2(0, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 2)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->RumbleDevice2(percentForce, 0, percentLength);
}
}
if (ff1 == 0x8)
{
if (HowtoRumbleMotorEffect == 0)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->RumbleDevice2(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 1)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->RumbleDevice2(0, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 2)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->RumbleDevice2(percentForce, 0, percentLength);
}
}
if (ff1 == 0x24)
{
if (HowtoRumbleKnockEffect == 0)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(percentForce, percentForce, percentLength);
myTriggers->RumbleDevice2(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 1)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(percentForce, percentForce, percentLength);
myTriggers->RumbleDevice2(0, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 2)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(percentForce, percentForce, percentLength);
myTriggers->RumbleDevice2(percentForce, 0, percentLength);
}
}
if (ff1 == 0x48)
{
if (HowtoRumbleMotorEffect == 0)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(percentForce, percentForce, percentLength);
myTriggers->RumbleDevice2(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 1)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(0, percentForce, percentLength);
myTriggers->RumbleDevice2(0, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 2)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(percentForce, 0, percentLength);
myTriggers->RumbleDevice2(percentForce, 0, percentLength);
}
}
oldFloat1 = newFloat1;
oldFloat2 = newFloat2;
}
}
void LGI::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
for (int i = 0; i < SDL_NumJoysticks(); i++)
{
wchar_t * deviceGUIDString2 = new wchar_t[256];
wchar_t* deviceGUIDString2 = new wchar_t[256];
int Device2GUID = GetPrivateProfileString(TEXT("Settings"), TEXT("Device2GUID"), NULL, deviceGUIDString2, 256, settingsFilename);
char joystick_guid[256];
sprintf(joystick_guid, "%S", deviceGUIDString2);
@ -93,180 +291,13 @@ void LGI::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers*
}
}
if ((oldFloat1 != newFloat1) && (health1p != 0x1))
{
if (HowtoRumbleHealthEffect == 0)
{
double percentForce = ((Health1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleHealthEffect == 1)
{
double percentForce = ((Health1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(0, percentForce, percentLength);
}
else if (HowtoRumbleHealthEffect == 2)
{
double percentForce = ((Health1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(percentForce, 0, percentLength);
}
}
if ((oldFloat2 != newFloat2) && (health2p != 0x1))
{
if (HowtoRumbleHealthEffect == 0)
{
double percentForce = ((Health2pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->RumbleDevice2(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleHealthEffect == 1)
{
double percentForce = ((Health2pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->RumbleDevice2(0, percentForce, percentLength);
}
else if (HowtoRumbleHealthEffect == 2)
{
double percentForce = ((Health2pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->RumbleDevice2(percentForce, 0, percentLength);
}
}
if (ff1 == 0x20)
{
if (HowtoRumbleKnockEffect == 0)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 1)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(0, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 2)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(percentForce, 0, percentLength);
}
}
if (ff1 == 0x40)
{
if (HowtoRumbleMotorEffect == 0)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 1)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(0, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 2)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(percentForce, 0, percentLength);
}
}
if (ff1 == 0x4)
{
if (HowtoRumbleKnockEffect == 0)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->RumbleDevice2(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 1)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->RumbleDevice2(0, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 2)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->RumbleDevice2(percentForce, 0, percentLength);
}
}
if (ff1 == 0x8)
{
if (HowtoRumbleMotorEffect == 0)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->RumbleDevice2(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 1)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->RumbleDevice2(0, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 2)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->RumbleDevice2(percentForce, 0, percentLength);
}
}
if (ff1 == 0x24)
{
if (HowtoRumbleKnockEffect == 0)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(percentForce, percentForce, percentLength);
triggers->RumbleDevice2(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 1)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(percentForce, percentForce, percentLength);
triggers->RumbleDevice2(0, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 2)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(percentForce, percentForce, percentLength);
triggers->RumbleDevice2(percentForce, 0, percentLength);
}
}
if (ff1 == 0x48)
{
if (HowtoRumbleMotorEffect == 0)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(percentForce, percentForce, percentLength);
triggers->RumbleDevice2(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 1)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(0, percentForce, percentLength);
triggers->RumbleDevice2(0, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 2)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(percentForce, 0, percentLength);
triggers->RumbleDevice2(percentForce, 0, percentLength);
}
}
oldFloat1 = newFloat1;
oldFloat2 = newFloat2;
SDL_Thread* thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void*)NULL);
while (SDL_WaitEvent(&e) != 0)
{
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
}
}

View File

@ -15,45 +15,324 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include "LGI3D.h"
#include "SDL.h"
#include <Windows.h>
static EffectTriggers* myTriggers;
static EffectConstants* myConstants;
static Helpers* myHelpers;
static SDL_Event e;
extern int joystick_index1;
extern int joystick_index2;
extern SDL_Haptic* haptic2;
extern SDL_Joystick* GameController2;
extern SDL_Haptic* ControllerHaptic2;
void LGI3D::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
int ff = helpers->ReadIntPtr(0x0065DA20, /* isRelativeOffset */ true);
UINT8 ff1 = helpers->ReadByte(ff + 0x44, /* isRelativeOffset */ false);
INT_PTR health1p1 = helpers->ReadIntPtr(0x008429F4, /* isRelativeOffset*/ true);
INT_PTR health1p2 = helpers->ReadIntPtr(health1p1 + 0x4, /* isRelativeOffset */ false);
INT_PTR health1p3 = helpers->ReadIntPtr(health1p2 + 0x74, /* isRelativeOffset */ false);
INT_PTR health2p3 = helpers->ReadIntPtr(health1p2 + 0x78, /* isRelativeOffset */ false);
float health1p = helpers->ReadFloat32(health1p3 + 0x14, /* isRelativeOffset */ false); //1p health
float health2p = helpers->ReadFloat32(health2p3 + 0x14, /* isRelativeOffset */ false); //2p health
helpers->log("got value: ");
std::string ffs = std::to_string(ff1);
helpers->log((char *)ffs.c_str());
float static oldFloat1 = 0.0;
float static oldFloat2 = 0.0;
float newFloat1 = health1p;
float newFloat2 = health2p;
static wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini");
wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini");
int configFeedbackLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("FeedbackLength"), 120, settingsFilename);
int HowtoRumbleKnockEffect = GetPrivateProfileInt(TEXT("Settings"), TEXT("HowtoRumbleKnockEffect"), 0, settingsFilename);
int HowtoRumbleMotorEffect = GetPrivateProfileInt(TEXT("Settings"), TEXT("HowtoRumbleMotorEffect"), 0, settingsFilename);
int HowtoRumbleHealthEffect = GetPrivateProfileInt(TEXT("Settings"), TEXT("HowtoRumbleHealthEffect"), 0, settingsFilename);
int Knock1pStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Knock1pStrength"), 0, settingsFilename);
int Motor1pStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Motor1pStrength"), 0, settingsFilename);
int Health1pStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Health1pStrength"), 0, settingsFilename);
int Knock2pStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Knock2pStrength"), 0, settingsFilename);
int Motor2pStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Motor2pStrength"), 0, settingsFilename);
int Health2pStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Health2pStrength"), 0, settingsFilename);
static int RunningThread(void* ptr)
{
int cnt;
for (cnt = 0; cnt >= 0; ++cnt)
{
int ff = myHelpers->ReadIntPtr(0x0065DA20, /* isRelativeOffset */ true);
UINT8 ff1 = myHelpers->ReadByte(ff + 0x44, /* isRelativeOffset */ false);
INT_PTR health1p1 = myHelpers->ReadIntPtr(0x008429F4, /* isRelativeOffset*/ true);
INT_PTR health1p2 = myHelpers->ReadIntPtr(health1p1 + 0x4, /* isRelativeOffset */ false);
INT_PTR health1p3 = myHelpers->ReadIntPtr(health1p2 + 0x74, /* isRelativeOffset */ false);
INT_PTR health2p3 = myHelpers->ReadIntPtr(health1p2 + 0x78, /* isRelativeOffset */ false);
float health1p = myHelpers->ReadFloat32(health1p3 + 0x14, /* isRelativeOffset */ false); //1p health
float health2p = myHelpers->ReadFloat32(health2p3 + 0x14, /* isRelativeOffset */ false); //2p health
myHelpers->log("got value: ");
std::string ffs = std::to_string(ff1);
myHelpers->log((char*)ffs.c_str());
float static oldFloat1 = 0.0;
float static oldFloat2 = 0.0;
float newFloat1 = health1p;
float newFloat2 = health2p;
wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini");
int configFeedbackLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("FeedbackLength"), 120, settingsFilename);
int HowtoRumbleKnockEffect = GetPrivateProfileInt(TEXT("Settings"), TEXT("HowtoRumbleKnockEffect"), 0, settingsFilename);
int HowtoRumbleMotorEffect = GetPrivateProfileInt(TEXT("Settings"), TEXT("HowtoRumbleMotorEffect"), 0, settingsFilename);
int HowtoRumbleHealthEffect = GetPrivateProfileInt(TEXT("Settings"), TEXT("HowtoRumbleHealthEffect"), 0, settingsFilename);
int Knock1pStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Knock1pStrength"), 0, settingsFilename);
int Motor1pStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Motor1pStrength"), 0, settingsFilename);
int Health1pStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Health1pStrength"), 0, settingsFilename);
int Knock2pStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Knock2pStrength"), 0, settingsFilename);
int Motor2pStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Motor2pStrength"), 0, settingsFilename);
int Health2pStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Health2pStrength"), 0, settingsFilename);
if ((oldFloat1 != newFloat1) && (health1p != 0x1))
{
if (HowtoRumbleHealthEffect == 0)
{
double percentForce = ((Health1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleHealthEffect == 1)
{
double percentForce = ((Health1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(0, percentForce, percentLength);
}
else if (HowtoRumbleHealthEffect == 2)
{
double percentForce = ((Health1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(percentForce, 0, percentLength);
}
}
if ((oldFloat2 != newFloat2) && (health2p != 0x1))
{
if (HowtoRumbleHealthEffect == 0)
{
double percentForce = ((Health2pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->RumbleDevice2(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleHealthEffect == 1)
{
double percentForce = ((Health2pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->RumbleDevice2(0, percentForce, percentLength);
}
else if (HowtoRumbleHealthEffect == 2)
{
double percentForce = ((Health2pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->RumbleDevice2(percentForce, 0, percentLength);
}
}
if (ff1 == 0x20)
{
if (HowtoRumbleKnockEffect == 0)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 1)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(0, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 2)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(percentForce, 0, percentLength);
}
}
if (ff1 == 0x40)
{
if (HowtoRumbleMotorEffect == 0)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 1)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(0, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 2)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(percentForce, 0, percentLength);
}
}
if (ff1 == 0x22)
{
if (HowtoRumbleKnockEffect == 0)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 1)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(0, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 2)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(percentForce, 0, percentLength);
}
}
if (ff1 == 0x42)
{
if (HowtoRumbleMotorEffect == 0)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 1)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(0, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 2)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(percentForce, 0, percentLength);
}
}
if (ff1 == 0x4)
{
if (HowtoRumbleKnockEffect == 0)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->RumbleDevice2(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 1)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->RumbleDevice2(0, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 2)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->RumbleDevice2(percentForce, 0, percentLength);
}
}
if (ff1 == 0x8)
{
if (HowtoRumbleMotorEffect == 0)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->RumbleDevice2(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 1)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->RumbleDevice2(0, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 2)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->RumbleDevice2(percentForce, 0, percentLength);
}
}
if (ff1 == 0x6)
{
if (HowtoRumbleKnockEffect == 0)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->RumbleDevice2(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 1)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->RumbleDevice2(0, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 2)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->RumbleDevice2(percentForce, 0, percentLength);
}
}
if (ff1 == 0xA)
{
if (HowtoRumbleMotorEffect == 0)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->RumbleDevice2(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 1)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->RumbleDevice2(0, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 2)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->RumbleDevice2(percentForce, 0, percentLength);
}
}
if (ff1 == 0x24)
{
if (HowtoRumbleKnockEffect == 0)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(percentForce, percentForce, percentLength);
myTriggers->RumbleDevice2(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 1)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(percentForce, percentForce, percentLength);
myTriggers->RumbleDevice2(0, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 2)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(percentForce, percentForce, percentLength);
myTriggers->RumbleDevice2(percentForce, 0, percentLength);
}
}
if (ff1 == 0x4A)
{
if (HowtoRumbleMotorEffect == 0)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(percentForce, percentForce, percentLength);
myTriggers->RumbleDevice2(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 1)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(0, percentForce, percentLength);
myTriggers->RumbleDevice2(0, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 2)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
myTriggers->Rumble(percentForce, 0, percentLength);
myTriggers->RumbleDevice2(percentForce, 0, percentLength);
}
}
oldFloat1 = newFloat1;
oldFloat2 = newFloat2;
}
}
void LGI3D::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
for (int i = 0; i < SDL_NumJoysticks(); i++)
{
wchar_t * deviceGUIDString2 = new wchar_t[256];
wchar_t* deviceGUIDString2 = new wchar_t[256];
int Device2GUID = GetPrivateProfileString(TEXT("Settings"), TEXT("Device2GUID"), NULL, deviceGUIDString2, 256, settingsFilename);
char joystick_guid[256];
sprintf(joystick_guid, "%S", deviceGUIDString2);
@ -94,264 +373,13 @@ void LGI3D::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers
}
}
if ((oldFloat1 != newFloat1) && (health1p != 0x1))
SDL_Thread* thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void*)NULL);
while (SDL_WaitEvent(&e) != 0)
{
if (HowtoRumbleHealthEffect == 0)
{
double percentForce = ((Health1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleHealthEffect == 1)
{
double percentForce = ((Health1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(0, percentForce, percentLength);
}
else if (HowtoRumbleHealthEffect == 2)
{
double percentForce = ((Health1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(percentForce, 0, percentLength);
}
}
if ((oldFloat2 != newFloat2) && (health2p != 0x1))
{
if (HowtoRumbleHealthEffect == 0)
{
double percentForce = ((Health2pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->RumbleDevice2(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleHealthEffect == 1)
{
double percentForce = ((Health2pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->RumbleDevice2(0, percentForce, percentLength);
}
else if (HowtoRumbleHealthEffect == 2)
{
double percentForce = ((Health2pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->RumbleDevice2(percentForce, 0, percentLength);
}
}
if (ff1 == 0x20)
{
if (HowtoRumbleKnockEffect == 0)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 1)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(0, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 2)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(percentForce, 0, percentLength);
}
}
if (ff1 == 0x40)
{
if (HowtoRumbleMotorEffect == 0)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 1)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(0, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 2)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(percentForce, 0, percentLength);
}
}
if (ff1 == 0x22)
{
if (HowtoRumbleKnockEffect == 0)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 1)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(0, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 2)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(percentForce, 0, percentLength);
}
}
if (ff1 == 0x42)
{
if (HowtoRumbleMotorEffect == 0)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 1)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(0, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 2)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(percentForce, 0, percentLength);
}
}
if (ff1 == 0x4)
{
if (HowtoRumbleKnockEffect == 0)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->RumbleDevice2(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 1)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->RumbleDevice2(0, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 2)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->RumbleDevice2(percentForce, 0, percentLength);
}
}
if (ff1 == 0x8)
{
if (HowtoRumbleMotorEffect == 0)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->RumbleDevice2(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 1)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->RumbleDevice2(0, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 2)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->RumbleDevice2(percentForce, 0, percentLength);
}
}
if (ff1 == 0x6)
{
if (HowtoRumbleKnockEffect == 0)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->RumbleDevice2(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 1)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->RumbleDevice2(0, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 2)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->RumbleDevice2(percentForce, 0, percentLength);
}
}
if (ff1 == 0xA)
{
if (HowtoRumbleMotorEffect == 0)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->RumbleDevice2(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 1)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->RumbleDevice2(0, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 2)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->RumbleDevice2(percentForce, 0, percentLength);
}
}
if (ff1 == 0x24)
{
if (HowtoRumbleKnockEffect == 0)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(percentForce, percentForce, percentLength);
triggers->RumbleDevice2(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 1)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(percentForce, percentForce, percentLength);
triggers->RumbleDevice2(0, percentForce, percentLength);
}
else if (HowtoRumbleKnockEffect == 2)
{
double percentForce = ((Knock1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(percentForce, percentForce, percentLength);
triggers->RumbleDevice2(percentForce, 0, percentLength);
}
}
if (ff1 == 0x4A)
{
if (HowtoRumbleMotorEffect == 0)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(percentForce, percentForce, percentLength);
triggers->RumbleDevice2(percentForce, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 1)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(0, percentForce, percentLength);
triggers->RumbleDevice2(0, percentForce, percentLength);
}
else if (HowtoRumbleMotorEffect == 2)
{
double percentForce = ((Motor1pStrength) / 100.0);
double percentLength = configFeedbackLength;
triggers->Rumble(percentForce, 0, percentLength);
triggers->RumbleDevice2(percentForce, 0, percentLength);
}
}
oldFloat1 = newFloat1;
oldFloat2 = newFloat2;
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -13,160 +13,183 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include <string>
#include "Machstorm.h"
typedef unsigned char U8;
typedef unsigned int U32;
typedef uint16_t U16;
#include "SDL.h"
static EffectTriggers* myTriggers;
static EffectConstants* myConstants;
static Helpers* myHelpers;
static SDL_Event e;
static int RunningThread(void* ptr)
{
int cnt;
for (cnt = 0; cnt >= 0; ++cnt)
{
static wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini");
int Power1RumbleStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power1RumbleStrength"), 0, settingsFilename);
int Power2RumbleStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power2RumbleStrength"), 0, settingsFilename);
int Power3RumbleStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power3RumbleStrength"), 0, settingsFilename);
int Power4RumbleStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power4RumbleStrength"), 0, settingsFilename);
int Power5RumbleStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power5RumbleStrength"), 0, settingsFilename);
int Power6RumbleStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power6RumbleStrength"), 0, settingsFilename);
int Power7RumbleStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power7RumbleStrength"), 0, settingsFilename);
int Power8RumbleStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power8RumbleStrength"), 0, settingsFilename);
int Power9RumbleStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power9RumbleStrength"), 0, settingsFilename);
int Power10RumbleStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power10RumbleStrength"), 0, settingsFilename);
int Power1RumbleLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power1RumbleLength"), 0, settingsFilename);
int Power2RumbleLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power2RumbleLength"), 0, settingsFilename);
int Power3RumbleLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power3RumbleLength"), 0, settingsFilename);
int Power4RumbleLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power4RumbleLength"), 0, settingsFilename);
int Power5RumbleLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power5RumbleLength"), 0, settingsFilename);
int Power6RumbleLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power6RumbleLength"), 0, settingsFilename);
int Power7RumbleLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power7RumbleLength"), 0, settingsFilename);
int Power8RumbleLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power8RumbleLength"), 0, settingsFilename);
int Power9RumbleLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power9RumbleLength"), 0, settingsFilename);
int Power10RumbleLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power10RumbleLength"), 0, settingsFilename);
int vibration = myHelpers->ReadInt32(0x6390E9, /* relative */ true);
int power = myHelpers->ReadInt32(0x639109, /* relative */ true);
if (vibration == 16842753)
{
if (power == 61542)
{
double percentLength = (Power1RumbleLength);
double percentForce = ((Power1RumbleStrength) / 100.0);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 61543)
{
double percentLength = (Power2RumbleLength);
double percentForce = ((Power2RumbleStrength) / 100.0);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 61544)
{
double percentLength = (Power3RumbleLength);
double percentForce = ((Power3RumbleStrength) / 100.0);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 61545)
{
double percentLength = (Power4RumbleLength);
double percentForce = ((Power4RumbleStrength) / 100.0);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 61546)
{
double percentLength = (Power5RumbleLength);
double percentForce = ((Power5RumbleStrength) / 100.0);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 61547)
{
double percentLength = (Power6RumbleLength);
double percentForce = ((Power6RumbleStrength) / 100.0);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 61548)
{
double percentLength = (Power7RumbleLength);
double percentForce = ((Power7RumbleStrength) / 100.0);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 61549)
{
double percentLength = (Power8RumbleLength);
double percentForce = ((Power8RumbleStrength) / 100.0);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 61550)
{
double percentLength = (Power9RumbleLength);
double percentForce = ((Power9RumbleStrength) / 100.0);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 61551)
{
double percentLength = (Power10RumbleLength);
double percentForce = ((Power10RumbleStrength) / 100.0);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
}
if (vibration == 1)
{
if (power == 16773366)
{
double percentLength = (Power1RumbleLength);
double percentForce = ((Power1RumbleStrength) / 100.0);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 16773367)
{
double percentLength = (Power2RumbleLength);
double percentForce = ((Power2RumbleStrength) / 100.0);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 16773368)
{
double percentLength = (Power3RumbleLength);
double percentForce = ((Power3RumbleStrength) / 100.0);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 16773369)
{
double percentLength = (Power4RumbleLength);
double percentForce = ((Power4RumbleStrength) / 100.0);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 16773370)
{
double percentLength = (Power5RumbleLength);
double percentForce = ((Power5RumbleStrength) / 100.0);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 16773371)
{
double percentLength = (Power6RumbleLength);
double percentForce = ((Power6RumbleStrength) / 100.0);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 16773372)
{
double percentLength = (Power7RumbleLength);
double percentForce = ((Power7RumbleStrength) / 100.0);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 16773373)
{
double percentLength = (Power8RumbleLength);
double percentForce = ((Power8RumbleStrength) / 100.0);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 16773374)
{
double percentLength = (Power9RumbleLength);
double percentForce = ((Power9RumbleStrength) / 100.0);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 16773375)
{
double percentLength = (Power10RumbleLength);
double percentForce = ((Power10RumbleStrength) / 100.0);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
}
}
return 0;
}
void Machstorm::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini");
int DomeFix = GetPrivateProfileInt(TEXT("Settings"), TEXT("DomeFix"), 0, settingsFilename);
int Power1RumbleStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power1RumbleStrength"), 0, settingsFilename);
int Power2RumbleStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power2RumbleStrength"), 0, settingsFilename);
int Power3RumbleStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power3RumbleStrength"), 0, settingsFilename);
int Power4RumbleStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power4RumbleStrength"), 0, settingsFilename);
int Power5RumbleStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power5RumbleStrength"), 0, settingsFilename);
int Power6RumbleStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power6RumbleStrength"), 0, settingsFilename);
int Power7RumbleStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power7RumbleStrength"), 0, settingsFilename);
int Power8RumbleStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power8RumbleStrength"), 0, settingsFilename);
int Power9RumbleStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power9RumbleStrength"), 0, settingsFilename);
int Power10RumbleStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power10RumbleStrength"), 0, settingsFilename);
int Power1RumbleLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power1RumbleLength"), 0, settingsFilename);
int Power2RumbleLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power2RumbleLength"), 0, settingsFilename);
int Power3RumbleLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power3RumbleLength"), 0, settingsFilename);
int Power4RumbleLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power4RumbleLength"), 0, settingsFilename);
int Power5RumbleLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power5RumbleLength"), 0, settingsFilename);
int Power6RumbleLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power6RumbleLength"), 0, settingsFilename);
int Power7RumbleLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power7RumbleLength"), 0, settingsFilename);
int Power8RumbleLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power8RumbleLength"), 0, settingsFilename);
int Power9RumbleLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power9RumbleLength"), 0, settingsFilename);
int Power10RumbleLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("Power10RumbleLength"), 0, settingsFilename);
int vibration = helpers->ReadInt32(0x6390E9, /* relative */ true);
int power = helpers->ReadInt32(0x639109, /* relative */ true);
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
if (vibration == 16842753)
SDL_Thread* thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void*)NULL);
while (SDL_WaitEvent(&e) != 0)
{
if (power == 61542)
{
double percentLength = (Power1RumbleLength);
double percentForce = ((Power1RumbleStrength) / 100.0);
triggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 61543)
{
double percentLength = (Power2RumbleLength);
double percentForce = ((Power2RumbleStrength) / 100.0);
triggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 61544)
{
double percentLength = (Power3RumbleLength);
double percentForce = ((Power3RumbleStrength) / 100.0);
triggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 61545)
{
double percentLength = (Power4RumbleLength);
double percentForce = ((Power4RumbleStrength) / 100.0);
triggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 61546)
{
double percentLength = (Power5RumbleLength);
double percentForce = ((Power5RumbleStrength) / 100.0);
triggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 61547)
{
double percentLength = (Power6RumbleLength);
double percentForce = ((Power6RumbleStrength) / 100.0);
triggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 61548)
{
double percentLength = (Power7RumbleLength);
double percentForce = ((Power7RumbleStrength) / 100.0);
triggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 61549)
{
double percentLength = (Power8RumbleLength);
double percentForce = ((Power8RumbleStrength) / 100.0);
triggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 61550)
{
double percentLength = (Power9RumbleLength);
double percentForce = ((Power9RumbleStrength) / 100.0);
triggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 61551)
{
double percentLength = (Power10RumbleLength);
double percentForce = ((Power10RumbleStrength) / 100.0);
triggers->Rumble(percentForce, percentForce, percentLength);
}
}
if (vibration == 1)
{
if (power == 16773366)
{
double percentLength = (Power1RumbleLength);
double percentForce = ((Power1RumbleStrength) / 100.0);
triggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 16773367)
{
double percentLength = (Power2RumbleLength);
double percentForce = ((Power2RumbleStrength) / 100.0);
triggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 16773368)
{
double percentLength = (Power3RumbleLength);
double percentForce = ((Power3RumbleStrength) / 100.0);
triggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 16773369)
{
double percentLength = (Power4RumbleLength);
double percentForce = ((Power4RumbleStrength) / 100.0);
triggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 16773370)
{
double percentLength = (Power5RumbleLength);
double percentForce = ((Power5RumbleStrength) / 100.0);
triggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 16773371)
{
double percentLength = (Power6RumbleLength);
double percentForce = ((Power6RumbleStrength) / 100.0);
triggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 16773372)
{
double percentLength = (Power7RumbleLength);
double percentForce = ((Power7RumbleStrength) / 100.0);
triggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 16773373)
{
double percentLength = (Power8RumbleLength);
double percentForce = ((Power8RumbleStrength) / 100.0);
triggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 16773374)
{
double percentLength = (Power9RumbleLength);
double percentForce = ((Power9RumbleStrength) / 100.0);
triggers->Rumble(percentForce, percentForce, percentLength);
}
else if (power == 16773375)
{
double percentLength = (Power10RumbleLength);
double percentForce = ((Power10RumbleStrength) / 100.0);
triggers->Rumble(percentForce, percentForce, percentLength);
}
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
}
}

View File

@ -14,7 +14,6 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#pragma once
#include "../Common Files/Game.h"
class Machstorm : public Game {
int lastWasStop = 0;
public:
void FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -13,106 +13,132 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include <string>
#include "MarioKartGPDX.h"
#include "SDL.h"
static EffectTriggers* myTriggers;
static EffectConstants* myConstants;
static Helpers* myHelpers;
static SDL_Event e;
static int RunningThread(void* ptr)
{
int cnt;
for (cnt = 0; cnt >= 0; ++cnt)
{
int ff1 = myHelpers->ReadInt32(0x564C5F, /* isRelativeOffset */ true); //shake
int ff2 = myHelpers->ReadInt32(0x559B68,/* isRelativeOffset */ true);
int ff3 = myHelpers->ReadInt32(ff2 + 0x5F8, /* isRelativeOffset */ false); // terrain data
int ff4 = myHelpers->ReadInt32(0x563860, /* isRelativeOffset */ true); //0-255 accl
int ff5 = myHelpers->ReadInt32(ff2 + 0x628, /* isRelativeOffset */ false); //kart flying or on ground
int ff6 = myHelpers->ReadInt32(0x5532C4,/* isRelativeOffset */ true);
int ff7 = myHelpers->ReadInt32(ff6 + 0x1F0, /* isRelativeOffset */ false);
int ff8 = myHelpers->ReadInt32(ff7 + 0x18, /* isRelativeOffset */ false);
int ff9 = myHelpers->ReadInt32(ff8 + 0x7C, /* isRelativeOffset */ false);
int ff10 = myHelpers->ReadInt32(ff9 + 0x164, /* isRelativeOffset */ false); // 1 during race only
int ff11 = myHelpers->ReadInt32(ff2 + 0x520, /* isRelativeOffset */ false); //1065353216 when kart moves
myHelpers->log("got value: ");
std::string ffs = std::to_string(ff1);
myHelpers->log((char*)ffs.c_str()); myHelpers->log("got value: ");
// Large Shake when hitting walls, other karts or getting hit by items
if ((4194308 == ff1) & (ff10 == 1))
{
double percentForce = 1.0;
double percentForce1 = 3.5;
double percentLength = (500);
myTriggers->Rumble(percentForce1, percentForce1, percentLength);
myTriggers->Sine(200, 200, percentForce);
}
// small friction when driving on dirt while moving
else if ((3 == ff3) & (ff10 == 1) & (ff5 == 1) & (ff11 == 1065353216))
{
double percentForce = (0.3);
double percentLength = (100);
myTriggers->Rumble(percentForce, 0, percentLength);
myTriggers->Friction(percentForce);
}
// Small constant when hitting bumps
else if ((10 == ff3) & (ff10 == 1) & (ff5 == 1) & (ff11 == 1065353216))
{
double percentForce = (0.2);
double percentLength = (50);
double percentForce1 = 3.0;
myTriggers->Rumble(percentForce1, percentForce1, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce);
}
// Wheel rumbles while driving on grass
else if ((4 == ff3) & (ff10 == 1) & (ff5 == 1) & (ff11 == 1065353216))
{
double percentForce = 0.2;
double percentLength = (50);
myTriggers->Rumble(0, percentForce, percentLength);
myTriggers->Sine(50, 50, percentForce);
}
//wheel hard to turn while driving through water
else if ((7 == ff3) & (ff10 == 1) & (ff5 == 1) & (ff11 == 1065353216))
{
double percentForce = (0.65);
myTriggers->Friction(percentForce);
}
//Wheel rumbles lightly when driving over tiles
else if ((12 == ff3) & (ff10 == 1) & (ff5 == 1) & (ff11 == 1065353216))
{
double percentForce = 0.1;
double percentForce1 = 0.2;
double percentLength = (150);
myTriggers->Rumble(percentForce1, 0, percentLength);
myTriggers->Sine(70, 70, percentForce);
}
//Wheel rumbles lightly when driving over sand
else if ((14 == ff3) & (ff10 == 1) & (ff5 == 1) & (ff11 == 1065353216))
{
double percentForce = 0.1;
double percentForce1 = 0.2;
double percentLength = (50);
myTriggers->Rumble(percentForce1, 0, percentLength);
myTriggers->Sine(70, 70, percentForce);
}
//Wheel rumbles lightly when driving over rough part of track
else if ((11 == ff3) & (ff10 == 1) & (ff5 == 1) & (ff11 == 1065353216))
{
double percentForce = 0.1;
double percentForce1 = 0.2;
double percentLength = (250);
myTriggers->Rumble(0, percentForce1, percentLength);
myTriggers->Sine(40, 50, percentForce);
}
//Wheel rumbles moderately when driving over wooden bridges
else if ((8 == ff3) & (ff10 == 1) & (ff5 == 1) & (ff11 == 1065353216))
{
double percentForce = 0.4;
double percentLength = (100);
myTriggers->Rumble(percentForce, percentForce, percentLength);
myTriggers->Sine(120, 120, percentForce);
}
}
return 0;
}
void MarioKartGPDX100::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
helpers->log("in MKDX Ffbloop");
int ff1 = helpers->ReadInt32(0x564C5F, /* isRelativeOffset */ true); //shake
int ff2 = helpers->ReadInt32(0x559B68,/* isRelativeOffset */ true);
int ff3 = helpers->ReadInt32(ff2 + 0x5F8, /* isRelativeOffset */ false); // terrain data
int ff4 = helpers->ReadInt32(0x563860, /* isRelativeOffset */ true); //0-255 accl
int ff5 = helpers->ReadInt32(ff2 + 0x628, /* isRelativeOffset */ false); //kart flying or on ground
int ff6 = helpers->ReadInt32(0x5532C4,/* isRelativeOffset */ true);
int ff7 = helpers->ReadInt32(ff6 + 0x1F0, /* isRelativeOffset */ false);
int ff8 = helpers->ReadInt32(ff7 + 0x18, /* isRelativeOffset */ false);
int ff9 = helpers->ReadInt32(ff8 + 0x7C, /* isRelativeOffset */ false);
int ff10 = helpers->ReadInt32(ff9 + 0x164, /* isRelativeOffset */ false); // 1 during race only
int ff11 = helpers->ReadInt32(ff2 + 0x520, /* isRelativeOffset */ false); //1065353216 when kart moves
helpers->log("got value: ");
std::string ffs = std::to_string(ff1);
helpers->log((char *)ffs.c_str()); helpers->log("got value: ");
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
// Large Shake when hitting walls, other karts or getting hit by items
if ((4194308 == ff1) & (ff10 == 1))
SDL_Thread* thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void*)NULL);
while (SDL_WaitEvent(&e) != 0)
{
double percentForce = 1.0;
double percentForce1 = 3.5;
double percentLength = (500);
triggers->Rumble(percentForce1, percentForce1, percentLength);
triggers->Sine(200, 200, percentForce);
}
// small friction when driving on dirt while moving
else if ((3 == ff3) & (ff10 == 1) & (ff5 == 1) & (ff11 == 1065353216))
{
double percentForce = (0.3);
double percentLength = (100);
triggers->Rumble(percentForce, 0, percentLength);
triggers->Friction(percentForce);
}
// Small constant when hitting bumps
else if ((10 == ff3) & (ff10 == 1) & (ff5 == 1) & (ff11 == 1065353216))
{
double percentForce = (0.2);
double percentLength = (50);
double percentForce1 = 3.0;
triggers->Rumble(percentForce1, percentForce1, percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
}
// Wheel rumbles while driving on grass
else if ((4 == ff3) & (ff10 == 1) & (ff5 == 1) & (ff11 == 1065353216))
{
double percentForce = 0.2;
double percentLength = (50);
triggers->Rumble(0, percentForce, percentLength);
triggers->Sine(50, 50, percentForce);
}
//wheel hard to turn while driving through water
else if ((7 == ff3) & (ff10 == 1) & (ff5 == 1) & (ff11 == 1065353216))
{
double percentForce = (0.65);
triggers->Friction(percentForce);
}
//Wheel rumbles lightly when driving over tiles
else if ((12 == ff3) & (ff10 == 1) & (ff5 == 1) & (ff11 == 1065353216))
{
double percentForce = 0.1;
double percentForce1 = 0.2;
double percentLength = (150);
triggers->Rumble(percentForce1, 0, percentLength);
triggers->Sine(70, 70, percentForce);
}
//Wheel rumbles lightly when driving over sand
else if ((14 == ff3) & (ff10 == 1) & (ff5 == 1) & (ff11 == 1065353216))
{
double percentForce = 0.1;
double percentForce1 = 0.2;
double percentLength = (50);
triggers->Rumble(percentForce1, 0, percentLength);
triggers->Sine(70, 70, percentForce);
}
//Wheel rumbles lightly when driving over rough part of track
else if ((11 == ff3) & (ff10 == 1) & (ff5 == 1) & (ff11 == 1065353216))
{
double percentForce = 0.1;
double percentForce1 = 0.2;
double percentLength = (250);
triggers->Rumble(0, percentForce1, percentLength);
triggers->Sine(40, 50, percentForce);
}
//Wheel rumbles moderately when driving over wooden bridges
else if ((8 == ff3) & (ff10 == 1) & (ff5 == 1) & (ff11 == 1065353216))
{
double percentForce = 0.4;
double percentLength = (100);
triggers->Rumble(percentForce, percentForce, percentLength);
triggers->Sine(120, 120, percentForce);
}
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
}
}

View File

@ -14,7 +14,6 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#pragma once
#include "../Common Files/Game.h"
class MarioKartGPDX100 : public Game {
int lastWasStop = 0;
public:
void FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers);

View File

@ -49,194 +49,222 @@ static int RoughTrackRumbleStrength = GetPrivateProfileInt(TEXT("Settings"), TEX
static int BridgeRumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("BridgeRumble"), 0, settingsFilename);
static int BridgeRumbleStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("BridgeRumbleStrength"), 0, settingsFilename);
#include "SDL.h"
static EffectTriggers* myTriggers;
static EffectConstants* myConstants;
static Helpers* myHelpers;
static SDL_Event e;
static int RunningThread(void* ptr)
{
int cnt;
for (cnt = 0; cnt >= 0; ++cnt)
{
INT_PTR ff1 = myHelpers->ReadIntPtr(0xA46974, /* isRelativeOffset */ true); //shake
INT_PTR ff2 = myHelpers->ReadIntPtr(0x00A416E4,/* isRelativeOffset */ true);
UINT8 ff3 = myHelpers->ReadByte(ff2 + 0x628, /* isRelativeOffset */ false); // terrain data
UINT8 ff5 = myHelpers->ReadByte(ff2 + 0x658, /* isRelativeOffset */ false); //kart flying or on ground
INT_PTR ff6 = myHelpers->ReadIntPtr(0x00A309A0,/* isRelativeOffset */ true);
INT_PTR ff7 = myHelpers->ReadIntPtr(ff6 + 0x304, /* isRelativeOffset */ false);
INT_PTR ff8 = myHelpers->ReadIntPtr(ff7 + 0xE8, /* isRelativeOffset */ false);
INT_PTR ff9 = myHelpers->ReadIntPtr(ff8 + 0x64, /* isRelativeOffset */ false);
INT_PTR ff10 = myHelpers->ReadIntPtr(ff9 + 0x38, /* isRelativeOffset */ false);
UINT8 ff11 = myHelpers->ReadByte(ff10 + 0x4C4, /* isRelativeOffset */ false); // 1 during race only
float Speed = myHelpers->ReadFloat32(ff2 + 0x558, /* isRelativeOffset */ false); //Speed of Kart
UINT8 ff13 = myHelpers->ReadByte(0xA39690, /* isRelativeOffset */ true); //picking up coins
UINT8 ff14 = myHelpers->ReadByte(0xA4528D, /* isRelativeOffset */ true); //picking up weapon box
UINT8 Wheel = myHelpers->ReadByte(0xA4652D, /* isRelativeOffset */ true); //0-255 steering
INT_PTR ff16 = myHelpers->ReadIntPtr(0x00A2E284, /* isRelativeOffset*/ true);
UINT8 ff17 = myHelpers->ReadByte(ff2 + 0x674, /* isRelativeOffset */ false); // Drift
UINT8 ff18 = myHelpers->ReadByte(ff16 + 0x3A4, /* isRelativeOffset */ false); // Boost
int static oldcoins = 0;
int newcoins = ff13;
int static oldweapon = 0;
int newweapon = ff14;
int static oldhitground = 0;
int newhitground = ff5;
myHelpers->log("got value: ");
std::string ffs = std::to_string(ff1);
myHelpers->log((char*)ffs.c_str()); myHelpers->log("got value: ");
if ((ConstantEffectForSteering == 1) && (ff11 == 1))
{
if ((Wheel >= 0) & (Wheel < 128))
{
double percentForce = ((128 - Wheel) / (ConstantEffectForSteeringStrength / 1.0));
double percentLength = 100;
myTriggers->Rumble(percentForce, 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce);
}
else if ((Wheel > 127)& (Wheel < 256))
{
double percentForce = ((Wheel - 127) / (ConstantEffectForSteeringStrength / 1.0));
double percentLength = 100;
myTriggers->Rumble(0, percentForce, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce);
}
}
if ((MainShakeRumble == 1) & (4194308 == ff1) & (ff11 == 1))
{
// Large Shake when hitting walls, other karts or getting hit by items
double percentForce = ((MainShakeRumbleStrength) / 100.0);
double percentLength = (500);
myTriggers->Rumble(percentForce, percentForce, percentLength);
myTriggers->Sine(200, 200, percentForce);
}
else if ((BoostRumble == 1) & (ff18 == 1) & (ff11 == 1))
{
// Shake when Boost
double percentForce = ((BoostRumbleStrength) / 100.0);
double percentLength = (100);
myTriggers->Rumble(percentForce, percentForce, percentLength);
myTriggers->Sine(60, 60, percentForce);
}
else if ((DriftRumble == 1) & (ff17 == 1) & (Wheel >= 0) & (Wheel < 128) & (ff11 == 1))
{
// Drift Effect including steering left
double percentForce = (((128 - Wheel) / 128.0) * (DriftRumbleControllerStrengthMultiplier / 100.0));
double percentLength = (100);
myTriggers->Rumble(percentForce, 0, percentLength);
myTriggers->Friction(percentForce);
}
else if ((DriftRumble == 1) & (ff17 == 1) & (Wheel > 127)& (Wheel < 256)& (ff11 == 1))
{
// Drift Effect including steering right
double percentForce = (((Wheel - 127) / 128.0) * (DriftRumbleControllerStrengthMultiplier / 100.0));
double percentLength = (100);
myTriggers->Rumble(0, percentForce, percentLength);
myTriggers->Friction(percentForce);
}
else if ((HitGroundRumble == 1) & (oldhitground != newhitground) & (ff5 == 1) & (ff11 == 1))
{
// Shake when hitting ground
double percentForce = ((HitGroundRumbleStrength) / 100.0);
double percentLength = (100);
myTriggers->Rumble(percentForce, percentForce, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce);
Sleep(50);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce);
}
else if ((WeaponRumble == 1) & (oldweapon != newweapon) & (ff11 == 1))
{
// Shake when picking up new weapons or using them
double percentForce = ((WeaponRumbleStrength) / 100.0);
double percentLength = (300);
myTriggers->Rumble(percentForce, percentForce, percentLength);
myTriggers->Sine(80, 50, percentForce);
}
else if ((CoinRumble == 1) & (oldcoins != newcoins) & (ff11 == 1))
{
// Shake when picking up coins
double percentForce = ((CoinRumbleStrength) / 100.0);
double percentLength = (200);
myTriggers->Rumble(percentForce, percentForce, percentLength);
myTriggers->Sine(50, 50, percentForce);
}
else if ((DirtRumble == 1) & (3 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1))
{
// small friction when driving on dirt while moving
double percentForce = ((DirtRumbleStrength) / 100.0);
double percentLength = (100);
myTriggers->Rumble(percentForce, 0, percentLength);
myTriggers->Friction(percentForce);
}
else if ((SpeedBumpRumble == 1) & (10 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1))
{
// Small constant when hitting bumps
double percentForce = ((SpeedBumpRumbleStrength) / 100.0);
double percentLength = (50);
myTriggers->Rumble(percentForce, percentForce, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, 0);
}
else if ((GrassRumble == 1) & (4 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1))
{
// Wheel rumbles while driving on grass
double percentForce = ((GrassRumbleStrength) / 100.0);
double percentLength = (50);
myTriggers->Rumble(0, percentForce, percentLength);
myTriggers->Sine(50, 50, percentForce);
}
else if ((CarpetRumble == 1) & (9 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1))
{
// Wheel rumbles while driving on carpet
double percentForce = ((CarpetRumbleStrength) / 100.0);
double percentLength = (50);
myTriggers->Rumble(0, percentForce, percentLength);
myTriggers->Sine(50, 50, percentForce);
}
else if ((WaterRumble == 1) & (7 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1)& (Wheel >= 0)& (Wheel < 128))
{
//wheel hard to turn while driving through water
double percentForce = ((WaterRumbleWheelStrength) / 100.0);
double percentForce1 = ((128 - Wheel / 128.0) * (WaterRumbleControllerStrengthMultiplier / 100.0));
double percentLength = (100);
myTriggers->Rumble(percentForce1, 0, percentLength);
myTriggers->Friction(percentForce);
}
else if ((WaterRumble == 1) & (7 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1)& (Wheel > 127))
{
double percentForce = ((WaterRumbleWheelStrength) / 100.0);
double percentForce1 = ((Wheel - 127 / 128.0) * (WaterRumbleControllerStrengthMultiplier / 100.0));
double percentLength = (100);
myTriggers->Rumble(0, percentForce1, percentLength);
myTriggers->Friction(percentForce);
}
else if ((TileRumble == 1) & (12 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1))
{
//Wheel rumbles lightly when driving over tiles
double percentForce = ((TileRumbleStrength) / 100.0);
double percentLength = (150);
myTriggers->Rumble(0, percentForce, percentLength);
myTriggers->Friction(percentForce);
}
else if ((SandRumble == 1) & (14 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1))
{
//Wheel rumbles lightly when driving over sand
double percentForce = ((SandRumbleStrength) / 100.0);
double percentLength = (50);
myTriggers->Rumble(percentForce, 0, percentLength);
myTriggers->Sine(70, 70, percentForce);
}
else if ((RoughTrackRumble == 1) & (11 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1))
{
//Wheel rumbles lightly when driving over rough part of track
double percentForce = ((RoughTrackRumbleStrength) / 100.0);
double percentLength = (100);
myTriggers->Rumble(0, percentForce, percentLength);
myTriggers->Sine(40, 50, percentForce);
}
else if ((BridgeRumble == 1) & (8 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1))
{
//Wheel rumbles moderately when driving over wooden bridges
double percentForce = ((BridgeRumbleStrength) / 100.0);
double percentLength = (100);
myTriggers->Rumble(percentForce, percentForce, percentLength);
myTriggers->Sine(120, 120, percentForce);
}
oldcoins = newcoins;
oldweapon = newweapon;
oldhitground = newhitground;
}
return 0;
}
void MarioKartGPDX110::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
INT_PTR ff1 = helpers->ReadIntPtr(0xA46974, /* isRelativeOffset */ true); //shake
INT_PTR ff2 = helpers->ReadIntPtr(0x00A416E4,/* isRelativeOffset */ true);
UINT8 ff3 = helpers->ReadByte(ff2 + 0x628, /* isRelativeOffset */ false); // terrain data
UINT8 ff5 = helpers->ReadByte(ff2 + 0x658, /* isRelativeOffset */ false); //kart flying or on ground
INT_PTR ff6 = helpers->ReadIntPtr(0x00A309A0,/* isRelativeOffset */ true);
INT_PTR ff7 = helpers->ReadIntPtr(ff6 + 0x304, /* isRelativeOffset */ false);
INT_PTR ff8 = helpers->ReadIntPtr(ff7 + 0xE8, /* isRelativeOffset */ false);
INT_PTR ff9 = helpers->ReadIntPtr(ff8 + 0x64, /* isRelativeOffset */ false);
INT_PTR ff10 = helpers->ReadIntPtr(ff9 + 0x38, /* isRelativeOffset */ false);
UINT8 ff11 = helpers->ReadByte(ff10 + 0x4C4, /* isRelativeOffset */ false); // 1 during race only
float Speed = helpers->ReadFloat32(ff2 + 0x558, /* isRelativeOffset */ false); //Speed of Kart
UINT8 ff13 = helpers->ReadByte(0xA39690, /* isRelativeOffset */ true); //picking up coins
UINT8 ff14 = helpers->ReadByte(0xA4528D, /* isRelativeOffset */ true); //picking up weapon box
UINT8 Wheel = helpers->ReadByte(0xA4652D, /* isRelativeOffset */ true); //0-255 steering
INT_PTR ff16 = helpers->ReadIntPtr(0x00A2E284, /* isRelativeOffset*/ true);
UINT8 ff17 = helpers->ReadByte(ff2 + 0x674, /* isRelativeOffset */ false); // Drift
UINT8 ff18 = helpers->ReadByte(ff16 + 0x3A4, /* isRelativeOffset */ false); // Boost
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
int static oldcoins = 0;
int newcoins = ff13;
int static oldweapon = 0;
int newweapon = ff14;
int static oldhitground = 0;
int newhitground = ff5;
helpers->log("got value: ");
std::string ffs = std::to_string(ff1);
helpers->log((char *)ffs.c_str()); helpers->log("got value: ");
if ((ConstantEffectForSteering == 1) && (ff11 == 1))
SDL_Thread* thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void*)NULL);
while (SDL_WaitEvent(&e) != 0)
{
if ((Wheel >= 0) & (Wheel < 128))
{
double percentForce = ((128 - Wheel) / (ConstantEffectForSteeringStrength / 1.0));
double percentLength = 100;
triggers->Rumble(percentForce, 0, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
}
else if ((Wheel > 127) & (Wheel < 256))
{
double percentForce = ((Wheel - 127) / (ConstantEffectForSteeringStrength / 1.0));
double percentLength = 100;
triggers->Rumble(0, percentForce, percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
}
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
}
if ((MainShakeRumble == 1) & (4194308 == ff1) & (ff11 == 1))
{
// Large Shake when hitting walls, other karts or getting hit by items
double percentForce = ((MainShakeRumbleStrength) / 100.0);
double percentLength = (500);
triggers->Rumble(percentForce, percentForce, percentLength);
triggers->Sine(200, 200, percentForce);
}
else if ((BoostRumble == 1) & (ff18 == 1) & (ff11 == 1))
{
// Shake when Boost
double percentForce = ((BoostRumbleStrength) / 100.0);
double percentLength = (100);
triggers->Rumble(percentForce, percentForce, percentLength);
triggers->Sine(60, 60, percentForce);
}
else if ((DriftRumble == 1) & (ff17 == 1) & (Wheel >= 0) & (Wheel < 128) & (ff11 == 1))
{
// Drift Effect including steering left
double percentForce = (((128 - Wheel) / 128.0) * (DriftRumbleControllerStrengthMultiplier / 100.0));
double percentLength = (100);
triggers->Rumble(percentForce, 0, percentLength);
triggers->Friction(percentForce);
}
else if ((DriftRumble == 1) & (ff17 == 1) & (Wheel > 127) & (Wheel < 256) & (ff11 == 1))
{
// Drift Effect including steering right
double percentForce = (((Wheel - 127) / 128.0) * (DriftRumbleControllerStrengthMultiplier / 100.0));
double percentLength = (100);
triggers->Rumble(0, percentForce, percentLength);
triggers->Friction(percentForce);
}
else if ((HitGroundRumble == 1) & (oldhitground != newhitground) & (ff5 == 1) & (ff11 == 1))
{
// Shake when hitting ground
double percentForce = ((HitGroundRumbleStrength) / 100.0);
double percentLength = (100);
triggers->Rumble(percentForce, percentForce, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
Sleep(50);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
}
else if ((WeaponRumble == 1) & (oldweapon != newweapon) & (ff11 == 1))
{
// Shake when picking up new weapons or using them
double percentForce = ((WeaponRumbleStrength) / 100.0);
double percentLength = (300);
triggers->Rumble(percentForce, percentForce, percentLength);
triggers->Sine(80, 50, percentForce);
}
else if ((CoinRumble == 1) & (oldcoins != newcoins) & (ff11 == 1))
{
// Shake when picking up coins
double percentForce = ((CoinRumbleStrength) / 100.0);
double percentLength = (200);
triggers->Rumble(percentForce, percentForce, percentLength);
triggers->Sine(50, 50, percentForce);
}
else if ((DirtRumble == 1) & (3 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1))
{
// small friction when driving on dirt while moving
double percentForce = ((DirtRumbleStrength) / 100.0);
double percentLength = (100);
triggers->Rumble(percentForce, 0, percentLength);
triggers->Friction(percentForce);
}
else if ((SpeedBumpRumble == 1) & (10 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1))
{
// Small constant when hitting bumps
double percentForce = ((SpeedBumpRumbleStrength) / 100.0);
double percentLength = (50);
triggers->Rumble(percentForce, percentForce, percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, 0);
}
else if ((GrassRumble == 1) & (4 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1))
{
// Wheel rumbles while driving on grass
double percentForce = ((GrassRumbleStrength) / 100.0);
double percentLength = (50);
triggers->Rumble(0, percentForce, percentLength);
triggers->Sine(50, 50, percentForce);
}
else if ((CarpetRumble == 1) & (9 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1))
{
// Wheel rumbles while driving on carpet
double percentForce = ((CarpetRumbleStrength) / 100.0);
double percentLength = (50);
triggers->Rumble(0, percentForce, percentLength);
triggers->Sine(50, 50, percentForce);
}
else if ((WaterRumble == 1) & (7 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1) & (Wheel >= 0) & (Wheel < 128))
{
//wheel hard to turn while driving through water
double percentForce = ((WaterRumbleWheelStrength) / 100.0);
double percentForce1 = ((128 - Wheel / 128.0) * (WaterRumbleControllerStrengthMultiplier / 100.0));
double percentLength = (100);
triggers->Rumble(percentForce1, 0, percentLength);
triggers->Friction(percentForce);
}
else if ((WaterRumble == 1) & (7 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1) & (Wheel > 127))
{
double percentForce = ((WaterRumbleWheelStrength) / 100.0);
double percentForce1 = ((Wheel - 127 / 128.0) * (WaterRumbleControllerStrengthMultiplier / 100.0));
double percentLength = (100);
triggers->Rumble(0, percentForce1, percentLength);
triggers->Friction(percentForce);
}
else if ((TileRumble == 1) & (12 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1))
{
//Wheel rumbles lightly when driving over tiles
double percentForce = ((TileRumbleStrength) / 100.0);
double percentLength = (150);
triggers->Rumble(0, percentForce, percentLength);
triggers->Friction(percentForce);
}
else if ((SandRumble == 1) & (14 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1))
{
//Wheel rumbles lightly when driving over sand
double percentForce = ((SandRumbleStrength) / 100.0);
double percentLength = (50);
triggers->Rumble(percentForce, 0, percentLength);
triggers->Sine(70, 70, percentForce);
}
else if ((RoughTrackRumble == 1) & (11 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1))
{
//Wheel rumbles lightly when driving over rough part of track
double percentForce = ((RoughTrackRumbleStrength) / 100.0);
double percentLength = (100);
triggers->Rumble(0, percentForce, percentLength);
triggers->Sine(40, 50, percentForce);
}
else if ((BridgeRumble == 1) & (8 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1))
{
//Wheel rumbles moderately when driving over wooden bridges
double percentForce = ((BridgeRumbleStrength) / 100.0);
double percentLength = (100);
triggers->Rumble(percentForce, percentForce, percentLength);
triggers->Sine(120, 120, percentForce);
}
oldcoins = newcoins;
oldweapon = newweapon;
oldhitground = newhitground;
}

View File

@ -14,7 +14,6 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#pragma once
#include "../Common Files/Game.h"
class MarioKartGPDX110 : public Game {
int lastWasStop = 0;
public:
void FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers);

View File

@ -255,7 +255,13 @@ static int RunningThread(void *ptr)
}
return 0;
}
void OutRun2Fake::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
SDL_Thread *thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void *)NULL);
int ff = myHelpers->ReadInt32(0x0827A1A0, /* isRelativeOffset */ false);

View File

@ -20,6 +20,7 @@ static EffectConstants *myConstants;
static Helpers *myHelpers;
static SDL_Event e;
static int SpeedStrength;
static bool init = true;
static wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini");
static int ShowButtonNumbersForSetup = GetPrivateProfileInt(TEXT("Settings"), TEXT("ShowButtonNumbersForSetup"), 0, settingsFilename);
static int ChangeGearsViaPlugin = GetPrivateProfileInt(TEXT("Settings"), TEXT("ChangeGearsViaPlugin"), 0, settingsFilename);
@ -94,6 +95,16 @@ static int RunningThread(void *ptr)
float ffspeed = myHelpers->ReadFloat32(0x08273DF0, /* isRelativeOffset */ false); //speedo
UINT8 static oldgear = 0;
float newgear = gear;
if (init)
{
DWORD tempdw = 0x08105A48;
DWORD loadffb = (DWORD)(void*)or2FfbFunction;
DWORD tempdw2 = loadffb - tempdw - 5;
*(BYTE*)tempdw = 0xE9;
*(DWORD*)(tempdw + 1) = tempdw2;
init = false;
}
if ((ffspeed >= 0.1) && (ffspeed <= 80))
{
@ -153,21 +164,16 @@ static int RunningThread(void *ptr)
}
void OutRun2Real::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
SDL_Thread *thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void *)NULL);
while (SDL_WaitEvent(&e) != 0)
{
bool init = true;
if (init)
{
DWORD tempdw = 0x08105A48;
DWORD loadffb = (DWORD)(void *)or2FfbFunction;
DWORD tempdw2 = loadffb - tempdw - 5;
*(BYTE *)tempdw = 0xE9;
*(DWORD *)(tempdw + 1) = tempdw2;
init = false;
}
{
UINT8 transmission = helpers->ReadByte(0x082932C2, /* isRelativeOffset */ false); // Auto or Manual
myTriggers = triggers;
myConstants = constants;

View File

@ -13,52 +13,79 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include <string>
#include "PokkenTournament.h"
#include "SDL.h"
static EffectTriggers* myTriggers;
static EffectConstants* myConstants;
static Helpers* myHelpers;
static SDL_Event e;
static int RunningThread(void* ptr)
{
int cnt;
for (cnt = 0; cnt >= 0; ++cnt)
{
INT_PTR ffAddress = myHelpers->ReadIntPtr(0x00E97F10, /* isRelativeOffset*/ true);
INT_PTR ff1 = myHelpers->ReadIntPtr(ffAddress + 0x60, /* isRelativeOffset */ false);
INT_PTR ff2 = myHelpers->ReadIntPtr(ff1 + 0x8, /* isRelativeOffset */ false);
float ff3 = myHelpers->ReadFloat32(ff2 + 0xCC, /* isRelativeOffset */ false); //health
INT_PTR ffAddress4 = myHelpers->ReadIntPtr(0x00EC4C20, /* isRelativeOffset*/ true);
INT_PTR ff5 = myHelpers->ReadIntPtr(ffAddress4 + 0x60, /* isRelativeOffset */ false);
INT_PTR ff6 = myHelpers->ReadIntPtr(ff5 + 0x120, /* isRelativeOffset */ false);
INT_PTR ff7 = myHelpers->ReadIntPtr(ff6 + 0x698, /* isRelativeOffset */ false); //1 during battle except for first startup
wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini");
int RumbleStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("RumbleStrength"), 0, settingsFilename);
int RumbleLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("RumbleLength"), 0, settingsFilename);
int HowtoRumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("HowtoRumble"), 0, settingsFilename);
float static oldFloat = 0.0;
float newFloat = ff3;
myHelpers->log("got value: ");
std::string ffs = std::to_string(ff3);
myHelpers->log((char*)ffs.c_str());
if ((oldFloat != newFloat))
{
if (HowtoRumble == 0)
{
double percentForce = ((RumbleStrength) / 100.0);
double percentLength = (RumbleLength);
myTriggers->Rumble(percentForce, percentForce, percentLength);
}
else if (HowtoRumble == 1)
{
double percentForce = ((RumbleStrength) / 100.0);
double percentLength = (RumbleLength);
myTriggers->Rumble(0, percentForce, percentLength);
}
else if (HowtoRumble == 2)
{
double percentForce = ((RumbleStrength) / 100.0);
double percentLength = (RumbleLength);
myTriggers->Rumble(percentForce, 0, percentLength);
}
}
oldFloat = newFloat;
}
return 0;
}
void PokkenTournament::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
INT_PTR ffAddress = helpers->ReadIntPtr(0x00E97F10, /* isRelativeOffset*/ true);
INT_PTR ff1 = helpers->ReadIntPtr(ffAddress + 0x60, /* isRelativeOffset */ false);
INT_PTR ff2 = helpers->ReadIntPtr(ff1 + 0x8, /* isRelativeOffset */ false);
float ff3 = helpers->ReadFloat32(ff2 + 0xCC, /* isRelativeOffset */ false); //health
INT_PTR ffAddress4 = helpers->ReadIntPtr(0x00EC4C20, /* isRelativeOffset*/ true);
INT_PTR ff5 = helpers->ReadIntPtr(ffAddress4 + 0x60, /* isRelativeOffset */ false);
INT_PTR ff6 = helpers->ReadIntPtr(ff5 + 0x120, /* isRelativeOffset */ false);
INT_PTR ff7 = helpers->ReadIntPtr(ff6 + 0x698, /* isRelativeOffset */ false); //1 during battle except for first startup
SDL_Thread* thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void*)NULL);
wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini");
int RumbleStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("RumbleStrength"), 0, settingsFilename);
int RumbleLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("RumbleLength"), 0, settingsFilename);
int HowtoRumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("HowtoRumble"), 0, settingsFilename);
float static oldFloat = 0.0;
float newFloat = ff3;
helpers->log("got value: ");
std::string ffs = std::to_string(ff3);
helpers->log((char *)ffs.c_str());
if ((oldFloat != newFloat))
while (SDL_WaitEvent(&e) != 0)
{
if (HowtoRumble == 0)
{
double percentForce = ((RumbleStrength) / 100.0);
double percentLength = (RumbleLength);
triggers->Rumble(percentForce, percentForce, percentLength);
}
else if (HowtoRumble == 1)
{
double percentForce = ((RumbleStrength) / 100.0);
double percentLength = (RumbleLength);
triggers->Rumble(0, percentForce, percentLength);
}
else if (HowtoRumble == 2)
{
double percentForce = ((RumbleStrength) / 100.0);
double percentLength = (RumbleLength);
triggers->Rumble(percentForce, 0, percentLength);
}
}
oldFloat = newFloat;
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
}
}

View File

@ -14,7 +14,6 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#pragma once
#include "../Common Files/Game.h"
class PokkenTournament : public Game {
int lastWasStop = 0;
public:
void FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers);

View File

@ -292,6 +292,10 @@ static int RunningThread(void *ptr)
void RoadFighters3D::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
if (InputDeviceWheelEnable == 1)
{
SDL_Thread *thread;

View File

@ -13,93 +13,121 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include <string>
#include "SegaRacingClassic.h"
#include "SDL.h"
static EffectTriggers* myTriggers;
static EffectConstants* myConstants;
static Helpers* myHelpers;
static SDL_Event e;
static int RunningThread(void* ptr)
{
int cnt;
for (cnt = 0; cnt >= 0; ++cnt)
{
UINT8 ff = myHelpers->ReadByte(0x834C19, /* isRelativeOffset */ false);
myHelpers->log("got value: ");
std::string ffs = std::to_string(ff);
myHelpers->log((char*)ffs.c_str());
wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini");
int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename);
if (FFBMode == 0)
{
if ((ff > 0xD7)& (ff < 0xE0))
{
//Clutch
double percentForce = (224 - ff) / 8.0;
double percentLength = 100;
myTriggers->Friction(percentForce);
}
else if ((ff > 0xBF)& (ff < 0xC8))
{
//Centering
double percentForce = (200 - ff) / 8.0;
double percentLength = 100;
myTriggers->Spring(pow(percentForce, 0.1));
}
else if ((ff > 0xB7)& (ff < 0xC0))
{
//Uncentering
double percentForce = (192 - ff) / 8.0;
double percentLength = 100;
myTriggers->Sine(70, 80, percentForce);
}
else if ((ff > 0xA7)& (ff < 0xB0))
{
//Roll Left
double percentForce = (176 - ff) / 8.0;
double percentLength = 100;
myTriggers->Rumble(0, percentForce, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce);
}
else if ((ff > 0x97)& (ff < 0xA0))
{
//Roll Right
double percentForce = (160 - ff) / 8.0;
double percentLength = 100;
myTriggers->Rumble(percentForce, 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce);
}
}
else
{
if ((ff > 0xD7)& (ff < 0xE0))
{
//Clutch
double percentForce = (224 - ff) / 8.0;
double percentLength = 100;
myTriggers->Friction(pow(percentForce, 0.5));
}
else if ((ff > 0xBF)& (ff < 0xC8))
{
//Centering
double percentForce = (200 - ff) / 8.0;
double percentLength = 100;
myTriggers->Spring(pow(percentForce, 0.1));
}
else if ((ff > 0xB7)& (ff < 0xC0))
{
//Uncentering
double percentForce = (192 - ff) / 8.0;
double percentLength = 100;
myTriggers->Sine(70, 80, pow(percentForce, 0.5));
}
else if ((ff > 0xA7)& (ff < 0xB0))
{
//Roll Left
double percentForce = (176 - ff) / 8.0;
double percentLength = 100;
myTriggers->Rumble(0, pow(percentForce, 0.5), percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, (pow(percentForce, 0.5)));
}
else if ((ff > 0x97)& (ff < 0xA0))
{
//Roll Right
double percentForce = (160 - ff) / 8.0;
double percentLength = 100;
myTriggers->Rumble(pow(percentForce, 0.5), 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, (pow(percentForce, 0.5)));
}
}
}
return 0;
}
void SegaRacingClassic::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
UINT8 ff = helpers->ReadByte(0x834C19, /* isRelativeOffset */ false);
helpers->log("got value: ");
std::string ffs = std::to_string(ff);
helpers->log((char *)ffs.c_str());
wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini");
int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename);
if (FFBMode == 0)
{
if ((ff > 0xD7) & (ff < 0xE0))
{
//Clutch
double percentForce = (224 - ff) / 8.0;
double percentLength = 100;
triggers->Friction(percentForce);
}
else if ((ff > 0xBF) & (ff < 0xC8))
{
//Centering
double percentForce = (200 - ff ) / 8.0;
double percentLength = 100;
triggers->Spring(pow(percentForce, 0.1));
}
else if ((ff > 0xB7) & (ff < 0xC0))
{
//Uncentering
double percentForce = (192 - ff) / 8.0;
double percentLength = 100;
triggers->Sine(70, 80, percentForce);
}
else if ((ff > 0xA7) & (ff < 0xB0))
{
//Roll Left
double percentForce = (176 - ff) / 8.0;
double percentLength = 100;
triggers->Rumble(0, percentForce, percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
}
else if ((ff > 0x97) & (ff < 0xA0))
{
//Roll Right
double percentForce = (160 - ff) / 8.0;
double percentLength = 100;
triggers->Rumble(percentForce, 0, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
}
}
else
{
if ((ff > 0xD7) & (ff < 0xE0))
{
//Clutch
double percentForce = (224 - ff) / 8.0;
double percentLength = 100;
triggers->Friction(pow(percentForce, 0.5));
}
else if ((ff > 0xBF) & (ff < 0xC8))
{
//Centering
double percentForce = (200 - ff) / 8.0;
double percentLength = 100;
triggers->Spring(pow(percentForce, 0.1));
}
else if ((ff > 0xB7) & (ff < 0xC0))
{
//Uncentering
double percentForce = (192 - ff) / 8.0;
double percentLength = 100;
triggers->Sine(70, 80, pow(percentForce, 0.5));
}
else if ((ff > 0xA7) & (ff < 0xB0))
{
//Roll Left
double percentForce = (176 - ff) / 8.0;
double percentLength = 100;
triggers->Rumble(0, pow(percentForce, 0.5), percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, 0.5)));
}
else if ((ff > 0x97) & (ff < 0xA0))
{
//Roll Right
double percentForce = (160 - ff) / 8.0;
double percentLength = 100;
triggers->Rumble(pow(percentForce, 0.5), 0, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, 0.5)));
}
}
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
SDL_Thread* thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void*)NULL);
while (SDL_WaitEvent(&e) != 0)
{
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
}
}

View File

@ -14,7 +14,6 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#pragma once
#include "../Common Files/Game.h"
class SegaRacingClassic : public Game {
int lastWasStop = 0;
public:
void FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers);

View File

@ -13,40 +13,73 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include <string>
#include "SegaRally3.h"
#include "SDL.h"
static EffectTriggers* myTriggers;
static EffectConstants* myConstants;
static Helpers* myHelpers;
static SDL_Event e;
static HANDLE hSection;
static LPVOID secData;
static int ffbOffset = 0;
void SegaRally3::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
helpers->log("in SR3 Ffbloop");
const int ff = GetTeknoParrotFFB();
std::string ffs = std::to_string(ff);
helpers->log((char *)ffs.c_str());
static int TeknoParrotGame()
{
hSection = CreateFileMapping(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, 64, L"TeknoParrot_JvsState");
secData = MapViewOfFile(hSection, FILE_MAP_ALL_ACCESS, 0, 0, 64);
ffbOffset = *((int*)secData + 2);
return 0;
}
if (ff > 15)
static int GetTeknoParrotFFB()
{
ffbOffset = *((int*)secData + 2);
return ffbOffset;
}
static int RunningThread(void* ptr)
{
int cnt;
for (cnt = 0; cnt >= 0; ++cnt)
{
helpers->log("moving wheel right");
// assume that 30 is the weakest and 16 is the strongest
double percentForce = (31 - ff) / 15.0;
double percentLength = 100;
// direction from left => makes wheel turn right
triggers->Rumble(percentForce, 0, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
lastWasStop = 0;
}
else if (ff > 0)
{
helpers->log("moving wheel left");
// assume that 1 is the strongest and 15 is the weakest
double percentForce = (16 - ff) / 15.0;
double percentLength = 100;
// direction from right => makes wheel turn left
triggers->Rumble(0, percentForce, percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
lastWasStop = 0;
}
else
{
if (lastWasStop == 0) {
triggers->Constant(constants->DIRECTION_FROM_LEFT, 0); // just pass the hash of 0 strength so we update lastEffectHash & lastEffectTime
lastWasStop = 1;
myHelpers->log("in SR3 Ffbloop");
const int ff = GetTeknoParrotFFB();
std::string ffs = std::to_string(ff);
myHelpers->log((char*)ffs.c_str());
if (ff > 15)
{
myHelpers->log("moving wheel right");
double percentForce = (31 - ff) / 15.0;
double percentLength = 100;
myTriggers->Rumble(percentForce, 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce);
}
else if (ff > 0)
{
myHelpers->log("moving wheel left");
double percentForce = (16 - ff) / 15.0;
double percentLength = 100;
myTriggers->Rumble(0, percentForce, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce);
}
}
}
void SegaRally3::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
TeknoParrotGame();
SDL_Thread* thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void*)NULL);
while (SDL_WaitEvent(&e) != 0)
{
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
}
}

View File

@ -12,10 +12,9 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
*/
#pragma once
#include "../Common Files/TeknoParrotGame.h"
#include "../Common Files/Game.h"
class SegaRally3 : public TeknoParrotGame {
class SegaRally3 : public Game {
public:
SegaRally3() : TeknoParrotGame() { }
void FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers);
};

View File

@ -13,44 +13,64 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include <string>
#include "SonicSegaAllStarsRacing.h"
#include "SDL.h"
static EffectTriggers* myTriggers;
static EffectConstants* myConstants;
static Helpers* myHelpers;
static SDL_Event e;
void SonicSegaAllStarsRacing::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
INT_PTR FFBEnable = helpers->ReadByte(0x5CD858, /* isRelativeOffset*/ true);
INT_PTR FFB = helpers->ReadByte(0x5CD864, /* isRelativeOffset*/ true);
static int RunningThread(void* ptr)
{
int cnt;
for (cnt = 0; cnt >= 0; ++cnt)
{
INT_PTR FFBEnable = myHelpers->ReadByte(0x5CD858, /* isRelativeOffset*/ true);
INT_PTR FFB = myHelpers->ReadByte(0x5CD864, /* isRelativeOffset*/ true);
{
//Enable FFB
helpers->WriteByte(0x5CD858, 0x03, true);
}
{
//Trigger friction to stop any oscillation
double percentForce = 0.2;
triggers->Friction(percentForce);
}
if ((FFB > 0) & (FFB < 19))
{
helpers->log("moving wheel right");
double percentForce = (FFB) / 18.0;
double percentLength = 100;
triggers->Rumble(0, percentForce, percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
lastWasStop = 0;
{
//Enable FFB
myHelpers->WriteByte(0x5CD858, 0x03, true);
}
}
else if ((FFB > 237) & (FFB < 256))
{
helpers->log("moving wheel right");
double percentForce = (256 - FFB) / 18.0;
double percentLength = 100;
triggers->Rumble(percentForce, 0, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
lastWasStop = 0;
}
else
{
if (lastWasStop == 0) {
triggers->Constant(constants->DIRECTION_FROM_LEFT, 0); // just pass the hash of 0 strength so we update lastEffectHash & lastEffectTime
lastWasStop = 1;
{
//Trigger friction to stop any oscillation
double percentForce = 0.2;
myTriggers->Friction(percentForce);
}
if ((FFB > 0)& (FFB < 19))
{
myHelpers->log("moving wheel right");
double percentForce = (FFB) / 18.0;
double percentLength = 100;
myTriggers->Rumble(0, percentForce, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce);
}
else if ((FFB > 237)& (FFB < 256))
{
myHelpers->log("moving wheel right");
double percentForce = (256 - FFB) / 18.0;
double percentLength = 100;
myTriggers->Rumble(percentForce, 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce);
}
}
return 0;
}
void SonicSegaAllStarsRacing::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
SDL_Thread* thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void*)NULL);
while (SDL_WaitEvent(&e) != 0)
{
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
}
}

View File

@ -14,7 +14,6 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#pragma once
#include "../Common Files/Game.h"
class SonicSegaAllStarsRacing : public Game {
int lastWasStop = 0;
public:
void FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers);

View File

@ -14,7 +14,6 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#pragma once
#include "../Common Files/Game.h"
class TestGame : public Game {
int lastWasStop = 0;
public:
void FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers);

View File

@ -136,178 +136,197 @@ static int GearChangeThread(void* ptr)
return 0;
}
void WMMT5::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers)
static int RunningThread(void* ptr)
{
if (!init)
int cnt;
for (cnt = 0; cnt >= 0; ++cnt)
{
if (!init)
{
init = true;
SDL_CreateThread(InputThread, "InputThread", (void*)NULL);
SDL_CreateThread(SpamThread, "SpamThread", (void*)NULL);
}
float spring = myHelpers->ReadFloat32(0x196F18C, true);
float friction = myHelpers->ReadFloat32(0x196F190, true);
float collisions = myHelpers->ReadFloat32(0x196F194, true);
float tiresSlip = myHelpers->ReadFloat32(0x196F188, true);
int speed = myHelpers->ReadInt32(0x196FEBC, true);
std::string msg = "spring: " + std::to_string(spring) + " | friction: " + std::to_string(friction)
+ " | collisions: " + std::to_string(collisions) + " | tires slip: " + std::to_string(tiresSlip)
+ " | speed: " + std::to_string(speed);
myHelpers->log((char*)msg.c_str());
double percentForce;
if (0.001 > spring && !gameFfbStarted)
{
myHelpers->log("fake spring+friction until game's FFB starts");
percentForce = 0.3 * SpringStrength / 100.0;
myTriggers->Spring(percentForce);
percentForce = 0.5 * FrictionStrength / 100.0;
myTriggers->Friction(percentForce);
}
else
{
if (!gameFfbStarted)
{
myHelpers->log("game's FFB started");
gameFfbStarted = true;
}
percentForce = (1.0 * spring) * SpringStrength / 100.0;
myTriggers->Spring(percentForce);
percentForce = (1.0 * friction) * FrictionStrength / 100.0;
myTriggers->Friction(percentForce);
}
if (0 < collisions)
{
if (0.209 <= collisions && 0.311 >= collisions)
{
myHelpers->log("joint/stripe on the right");
percentForce = (1.0 * collisions) * JointsAndStripesStrength / 100.0;
myTriggers->Sine(80, 80, percentForce);
myTriggers->Rumble(0, percentForce, 150);
}
else
{
myHelpers->log("collision on the right");
percentForce = (1.0 * collisions) * CollisionsStrength / 100.0;
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce);
myTriggers->Rumble(0, percentForce, 150);
}
}
else if (0 > collisions)
{
if (-0.209 >= collisions && -0.311 <= collisions)
{
myHelpers->log("joint/stripe on the left");
percentForce = (1.0 * collisions) * JointsAndStripesStrength / 100.0;
myTriggers->Sine(80, 80, percentForce);
myTriggers->Rumble(0, -1.0 * percentForce, 150);
}
else
{
myHelpers->log("collision on the left");
percentForce = (-1.0 * collisions) * CollisionsStrength / 100.0;
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce);
myTriggers->Rumble(0, percentForce, 150);
}
}
else
{
myHelpers->log("resetting collision");
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, 0);
}
if (0 < tiresSlip)
{
myHelpers->log("tires slip left");
bool highSpeedVibrations = (294 <= speed) && (1.0 * tiresSlip) < (LimitBetweenHighSpeedVibrationsAndTiresSlip / 1000.0);
percentForce = (-1.0 * tiresSlip) * (highSpeedVibrations ? HighSpeedVibrationsStrength : TiresSlipStrength) / 100.0;
myTriggers->Sine(100, 100, percentForce);
if (!highSpeedVibrations && ((0 == JointsAndStripesStrength && 0 == CollisionsStrength) || (0.001 > collisions && -0.001 < collisions)))
{
myTriggers->Rumble(0, -1.0 * percentForce, 150);
}
}
else if (0 > tiresSlip)
{
myHelpers->log("tires slip right");
bool highSpeedVibrations = (294 <= speed) && (-1.0 * tiresSlip) < (LimitBetweenHighSpeedVibrationsAndTiresSlip / 1000.0);
percentForce = (-1.0 * tiresSlip) * (highSpeedVibrations ? HighSpeedVibrationsStrength : TiresSlipStrength) / 100.0;
myTriggers->Sine(100, 100, percentForce);
if (!highSpeedVibrations && ((0 == JointsAndStripesStrength && 0 == CollisionsStrength) || (0.001 > collisions && -0.001 < collisions)))
{
myTriggers->Rumble(0, percentForce, 150);
}
}
INT_PTR ptr1 = myHelpers->ReadIntPtr(0x199A450, true);
UINT8 gear = myHelpers->ReadByte(ptr1 + 0x398, false);
if (0 < WheelSpinStrength)
{
INT_PTR ptr1 = myHelpers->ReadIntPtr(0x1948F10, true);
INT_PTR ptr2 = myHelpers->ReadIntPtr(ptr1 + 0x180 + 0xa8 + 0x18, false);
UINT8 power = myHelpers->ReadByte(ptr2 + 0x98, false);
int rpm = myHelpers->ReadInt32(0x1970038, true);
int diff = 0x0A <= power ? 0 : 20;
if (
1 == gear && 10 < speed && (
((30 - diff) > speed && 3500 < rpm)
|| ((55 - diff) > speed && 5500 < rpm)
|| ((75 - diff) > speed && 7000 < rpm)
|| ((100 - diff) > speed && 7800 < rpm)
)
)
{
percentForce = (((100.0 - speed) / 100.0) * ((rpm * 100.0 / 8500.0) / 100.0)) * WheelSpinStrength / 100.0;
myTriggers->Sine(120, 120, percentForce);
myTriggers->Rumble(0, percentForce, 150);
msg = "tires spin: gear: " + std::to_string(gear) + " | speed: " + std::to_string(speed)
+ " | rpm: " + std::to_string(rpm) + " | force: " + std::to_string(percentForce);
myHelpers->log((char*)msg.c_str());
}
else if (
2 == gear && 10 < speed && (
((110 - (2 * diff)) > speed && 5000 < rpm)
|| ((130 - (2 * diff)) > speed && 6000 < rpm)
|| ((145 - (2 * diff)) > speed && 6500 < rpm)
|| ((160 - (2 * diff)) > speed && 7000 < rpm)
)
)
{
percentForce = (((160.0 - speed) / 150.0) * ((rpm * 100.0 / 8500.0) / 100.0)) * WheelSpinStrength / 100.0;
myTriggers->Sine(120, 120, percentForce);
myTriggers->Rumble(0, percentForce, 150);
msg = "tires spin: gear: " + std::to_string(gear) + " | speed: " + std::to_string(speed)
+ " | rpm: " + std::to_string(rpm) + " | force: " + std::to_string(percentForce);
myHelpers->log((char*)msg.c_str());
}
}
if (0 < GearChangeStrength)
{
ptr1 = myHelpers->ReadIntPtr(0x199A468, true);
float time = myHelpers->ReadFloat32(ptr1 + 0x18, false);
if (oldgear != gear && 0 < gear && 0 < time)
{
msg = "oldgear: " + std::to_string(oldgear) + " | gear: " + std::to_string(gear)
+ " | time: " + std::to_string(time) + " | speed: " + std::to_string(speed);
myHelpers->log((char*)msg.c_str());
}
if (oldgear != gear && 0 < gear && 0.5 < time && 0.1 <= speed)
{
SDL_CreateThread(GearChangeThread, "GearChangeThread", (void*)NULL);
}
oldgear = gear;
}
}
return 0;
}
void WMMT5::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers){
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
SDL_Thread* thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void*)NULL);
while (SDL_WaitEvent(&e) != 0)
{
init = true;
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
SDL_CreateThread(InputThread, "InputThread", (void*)NULL);
SDL_CreateThread(SpamThread, "SpamThread", (void*)NULL);
}
float spring = helpers->ReadFloat32(0x196F18C, true);
float friction = helpers->ReadFloat32(0x196F190, true);
float collisions = helpers->ReadFloat32(0x196F194, true);
float tiresSlip = helpers->ReadFloat32(0x196F188, true);
int speed = helpers->ReadInt32(0x196FEBC, true);
std::string msg = "spring: " + std::to_string(spring) + " | friction: " + std::to_string(friction)
+ " | collisions: " + std::to_string(collisions) + " | tires slip: " + std::to_string(tiresSlip)
+ " | speed: " + std::to_string(speed);
helpers->log((char*)msg.c_str());
double percentForce;
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)
{
helpers->log("game's FFB started");
gameFfbStarted = true;
}
percentForce = (1.0 * spring) * SpringStrength / 100.0;
triggers->Spring(percentForce);
percentForce = (1.0 * friction) * FrictionStrength / 100.0;
triggers->Friction(percentForce);
}
if (0 < collisions)
{
if (0.209 <= collisions && 0.311 >= collisions)
{
helpers->log("joint/stripe on the right");
percentForce = (1.0 * collisions) * JointsAndStripesStrength / 100.0;
triggers->Sine(80, 80, percentForce);
triggers->Rumble(0, percentForce, 150);
}
else
{
helpers->log("collision on the right");
percentForce = (1.0 * collisions) * CollisionsStrength / 100.0;
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
triggers->Rumble(0, percentForce, 150);
}
}
else if (0 > collisions)
{
if (-0.209 >= collisions && -0.311 <= collisions)
{
helpers->log("joint/stripe on the left");
percentForce = (1.0 * collisions) * JointsAndStripesStrength / 100.0;
triggers->Sine(80, 80, percentForce);
triggers->Rumble(0, -1.0 * percentForce, 150);
}
else
{
helpers->log("collision on the left");
percentForce = (-1.0 * collisions) * CollisionsStrength / 100.0;
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
triggers->Rumble(0, percentForce, 150);
}
}
else
{
helpers->log("resetting collision");
triggers->Constant(constants->DIRECTION_FROM_LEFT, 0);
}
if (0 < tiresSlip)
{
helpers->log("tires slip left");
bool highSpeedVibrations = (294 <= speed) && (1.0 * tiresSlip) < (LimitBetweenHighSpeedVibrationsAndTiresSlip / 1000.0);
percentForce = (-1.0 * tiresSlip) * (highSpeedVibrations ? HighSpeedVibrationsStrength : TiresSlipStrength) / 100.0;
triggers->Sine(100, 100, percentForce);
if (!highSpeedVibrations && ((0 == JointsAndStripesStrength && 0 == CollisionsStrength) || (0.001 > collisions && -0.001 < collisions)))
{
triggers->Rumble(0, -1.0 * percentForce, 150);
}
}
else if (0 > tiresSlip)
{
helpers->log("tires slip right");
bool highSpeedVibrations = (294 <= speed) && (-1.0 * tiresSlip) < (LimitBetweenHighSpeedVibrationsAndTiresSlip / 1000.0);
percentForce = (-1.0 * tiresSlip) * (highSpeedVibrations ? HighSpeedVibrationsStrength : TiresSlipStrength) / 100.0;
triggers->Sine(100, 100, percentForce);
if (!highSpeedVibrations && ((0 == JointsAndStripesStrength && 0 == CollisionsStrength) || (0.001 > collisions && -0.001 < collisions)))
{
triggers->Rumble(0, percentForce, 150);
}
}
INT_PTR ptr1 = helpers->ReadIntPtr(0x199A450, true);
UINT8 gear = helpers->ReadByte(ptr1 + 0x398, false);
if (0 < WheelSpinStrength)
{
INT_PTR ptr1 = myHelpers->ReadIntPtr(0x1948F10, true);
INT_PTR ptr2 = myHelpers->ReadIntPtr(ptr1 + 0x180 + 0xa8 + 0x18, false);
UINT8 power = myHelpers->ReadByte(ptr2 + 0x98, false);
int rpm = helpers->ReadInt32(0x1970038, true);
int diff = 0x0A <= power ? 0 : 20;
if (
1 == gear && 10 < speed && (
((30 - diff) > speed && 3500 < rpm)
|| ((55 - diff) > speed && 5500 < rpm)
|| ((75 - diff) > speed && 7000 < rpm)
|| ((100 - diff) > speed && 7800 < rpm)
)
)
{
percentForce = (((100.0 - speed) / 100.0) * ((rpm * 100.0 / 8500.0) / 100.0)) * WheelSpinStrength / 100.0;
triggers->Sine(120, 120, percentForce);
triggers->Rumble(0, percentForce, 150);
msg = "tires spin: gear: " + std::to_string(gear) + " | speed: " + std::to_string(speed)
+ " | rpm: " + std::to_string(rpm) + " | force: " + std::to_string(percentForce);
helpers->log((char*)msg.c_str());
}
else if (
2 == gear && 10 < speed && (
((110 - (2 * diff)) > speed && 5000 < rpm)
|| ((130 - (2 * diff)) > speed && 6000 < rpm)
|| ((145 - (2 * diff)) > speed && 6500 < rpm)
|| ((160 - (2 * diff)) > speed && 7000 < rpm)
)
)
{
percentForce = (((160.0 - speed) / 150.0) * ((rpm * 100.0 / 8500.0) / 100.0)) * WheelSpinStrength / 100.0;
triggers->Sine(120, 120, percentForce);
triggers->Rumble(0, percentForce, 150);
msg = "tires spin: gear: " + std::to_string(gear) + " | speed: " + std::to_string(speed)
+ " | rpm: " + std::to_string(rpm) + " | force: " + std::to_string(percentForce);
helpers->log((char*)msg.c_str());
}
}
if (0 < GearChangeStrength)
{
ptr1 = helpers->ReadIntPtr(0x199A468, true);
float time = helpers->ReadFloat32(ptr1 + 0x18, false);
if (oldgear != gear && 0 < gear && 0 < time)
{
msg = "oldgear: " + std::to_string(oldgear) + " | gear: " + std::to_string(gear)
+ " | time: " + std::to_string(time) + " | speed: " + std::to_string(speed);
helpers->log((char*)msg.c_str());
}
if (oldgear != gear && 0 < gear && 0.5 < time && 0.1 <= speed)
{
SDL_CreateThread(GearChangeThread, "GearChangeThread", (void*)NULL);
}
oldgear = gear;
}
}
}

View File

@ -14,7 +14,6 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#pragma once
#include "../Common Files/Game.h"
class WMMT5 : public Game {
int lastWasStop = 0;
public:
void FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers);

View File

@ -13,6 +13,11 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include <string>
#include "WackyRaces.h"
#include "SDL.h"
static EffectTriggers* myTriggers;
static EffectConstants* myConstants;
static Helpers* myHelpers;
static SDL_Event e;
int ttx2wr(int ffRaw) {
switch (ffRaw) {
@ -83,53 +88,58 @@ int ttx2wr(int ffRaw) {
}
}
void WackyRaces::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
int ff = 0;
static int RunningThread(void* ptr)
{
int cnt;
for (cnt = 0; cnt >= 0; ++cnt)
{
long ffAddress = helpers->ReadInt32(0x7E00590, /* isRelativeOffset*/ true);
int ffRaw = helpers->ReadInt32(ffAddress + 0x45, /* isRelativeOffset */ false);
int lampArray[7] = { 16, 1024, 512, 128, 8, 256, 16384 };
for (int i = 0; i < 7; i++) {
if ((ffRaw & lampArray[i]) == lampArray[i]) {
ffRaw -= lampArray[i];
}
};
ff = ttx2wr(ffRaw);
}
int ff = 0;
//helpers->log("got value: ");
//std::string ffs = std::to_string(ff);
//helpers->log((char *)ffs.c_str());
{
long ffAddress = myHelpers->ReadInt32(0x7E00590, /* isRelativeOffset*/ true);
int ffRaw = myHelpers->ReadInt32(ffAddress + 0x45, /* isRelativeOffset */ false);
int lampArray[7] = { 16, 1024, 512, 128, 8, 256, 16384 };
for (int i = 0; i < 7; i++) {
if ((ffRaw & lampArray[i]) == lampArray[i]) {
ffRaw -= lampArray[i];
}
};
ff = ttx2wr(ffRaw);
}
if (ff > 15)
{
helpers->log("moving wheel left");
// assume that 30 is the weakest and 16 is the strongest
double percentForce = (31 - ff) / 15.0;
double percentLength = 100;
// direction from left => makes wheel turn right
triggers->Rumble(0, percentForce, percentLength);
triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); // old logic: 31 - ff
lastWasStop = 0;
}
else if (ff > 0)
{
helpers->log("moving wheel right");
// assume that 1 is the strongest and 15 is the weakest
double percentForce = (16 - ff) / 15.0;
double percentLength = 100;
// direction from right => makes wheel turn left
triggers->Rumble(percentForce, 0, percentLength);
triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); // old logic: 15 - ff
lastWasStop = 0;
}
else
{
if (lastWasStop == 0) {
triggers->Constant(constants->DIRECTION_FROM_LEFT, 0); // just pass the hash of 0 strength so we update lastEffectHash & lastEffectTime
lastWasStop = 1;
if (ff > 15)
{
myHelpers->log("moving wheel left");
double percentForce = (31 - ff) / 15.0;
double percentLength = 100;
myTriggers->Rumble(0, percentForce, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce);
}
else if (ff > 0)
{
myHelpers->log("moving wheel right");
double percentForce = (16 - ff) / 15.0;
double percentLength = 100;
myTriggers->Rumble(percentForce, 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce);
}
}
return 0;
}
void WackyRaces::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
SDL_Thread* thread;
thread = SDL_CreateThread(RunningThread, "RunningThread", (void*)NULL);
while (SDL_WaitEvent(&e) != 0)
{
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
}
}

View File

@ -15,7 +15,6 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include "../Common Files/Game.h"
class WackyRaces : public Game {
int lastWasStop = 0;
public:
void FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers);