diff --git a/Config/FFBPlugin.ini b/Config/FFBPlugin.ini
index 5867acc..5b11032 100644
--- a/Config/FFBPlugin.ini
+++ b/Config/FFBPlugin.ini
@@ -117,9 +117,6 @@ DamperStrength=100
[GRID]
GameId=10
FeedbackLength=80
-SpringStrength=65
-GearChangeStrength=50
-GearChangeLength=80
EnableDamper=0
DamperStrength=100
diff --git a/Dinput8Wrapper.vcxproj.filters b/Dinput8Wrapper.vcxproj.filters
index 3c6c19b..06e4af9 100644
--- a/Dinput8Wrapper.vcxproj.filters
+++ b/Dinput8Wrapper.vcxproj.filters
@@ -112,7 +112,6 @@
Game Files
-
@@ -152,6 +151,7 @@
+
@@ -263,9 +263,6 @@
Common Header Files
-
- Common Header Files
-
Common Header Files
@@ -371,6 +368,9 @@
Common Header Files
+
+ Common Header Files
+
diff --git a/Game Files/GRID.cpp b/Game Files/GRID.cpp
index ec0815c..43e2e5c 100644
--- a/Game Files/GRID.cpp
+++ b/Game Files/GRID.cpp
@@ -14,97 +14,72 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include
#include "GRID.h"
#include "SDL.h"
+
static EffectTriggers* myTriggers;
static EffectConstants* myConstants;
static Helpers* myHelpers;
-static bool gearshift = false;
+
extern int EnableDamper;
extern int DamperStrength;
-static wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini");
-static int SpringStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("SpringStrength"), 0, settingsFilename);
-static int GearChangeStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("GearChangeStrength"), 20, settingsFilename);
-static int GearChangeLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("GearChangeLength"), 200, settingsFilename);
+static bool init;
+
+static int FFBCounter;
+
+static int(__stdcall* Out32Ori)(DWORD device, DWORD data);
+static int __stdcall Out32Hook(DWORD device, DWORD data)
+{
+ if (device == 0x378)
+ {
+ ++FFBCounter;
+
+ if (FFBCounter == 5)
+ {
+ FFBCounter = 0;
+
+ if (data > 15)
+ {
+ double percentForce = (31 - data) / 15.0;
+ double percentLength = 100;
+ myTriggers->Rumble(percentForce, 0, percentLength);
+ myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce);
+ }
+ else if (data > 0)
+ {
+ double percentForce = (16 - data) / 15.0;
+ double percentLength = 100;
+ myTriggers->Rumble(0, percentForce, percentLength);
+ myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce);
+ }
+ }
+ }
+
+ return Out32Ori(device, data);
+}
+
+static int(__fastcall* EnableFFBOri)(int a1, double a2);
+static int __fastcall EnableFFBHook(int a1, double a2)
+{
+ EnableFFBOri(a1, a2);
+ *(BYTE*)(a1 + 92) = 1;
+ return 0;
+}
void GRID::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) {
-
- INT_PTR WallBase = helpers->ReadIntPtr(0xB1B7F0, true);
- INT_PTR WallBase1 = helpers->ReadIntPtr(WallBase + 0x730, false);
- INT_PTR WallBase2 = helpers->ReadIntPtr(WallBase1 + 0x4, false);
- INT_PTR WallBase3 = helpers->ReadIntPtr(WallBase2 + 0x4, false);
- float WallBase4 = helpers->ReadFloat32(WallBase3 + 0x118, false);
- INT_PTR PanelBase = helpers->ReadIntPtr(0xA3FA34, true);
- INT_PTR PanelBase1 = helpers->ReadIntPtr(PanelBase + 0x678, false);
- INT_PTR PanelBase2 = helpers->ReadIntPtr(PanelBase1 + 0x14, false);
- INT_PTR PanelBase3 = helpers->ReadIntPtr(PanelBase2 + 0x30, false);
- UINT8 PanelBase4 = helpers->ReadByte(PanelBase3 + 0x2C, false);
- UINT8 Wheels = helpers->ReadByte(PanelBase3 + 0xB4, false);
- UINT8 Skids = helpers->ReadByte(PanelBase3 + 0x100, false);
- UINT8 AI = helpers->ReadByte(PanelBase3 + 0x3D4, false);
- UINT8 gear = helpers->ReadByte(0x414F7898, false);
- INT_PTR speedoBase = helpers->ReadIntPtr(0x28C008, true);
- INT_PTR speedoBase1 = helpers->ReadIntPtr(speedoBase + 0xD0, false);
- INT_PTR speedoBase2 = helpers->ReadIntPtr(speedoBase1 + 0x460, false);
- INT_PTR speedoBase3 = helpers->ReadIntPtr(speedoBase2 + 0x184, false);
- float speedo = helpers->ReadFloat32(speedoBase3 + 0x4F4, false);
-
- UINT8 static oldgear = 0;
- UINT8 newgear = gear;
-
- triggers->Springi(SpringStrength / 100.0);
-
- if (EnableDamper)
- triggers->Damper(DamperStrength / 100.0);
-
- if (oldgear != newgear && speedo > 0)
- gearshift = true;
-
- if (gearshift)
+ if (!init)
{
- myHelpers->log("gear change");
- double percentForce = GearChangeStrength / 100.0;
- myTriggers->Sine(GearChangeLength, 0, percentForce);
- myTriggers->Rumble(0, percentForce, 150);
- gearshift = false;
+ init = true;
+
+ HMODULE hMod = GetModuleHandleA("inpout32.dll");
+ if (hMod)
+ {
+ MH_Initialize();
+ MH_CreateHook((void*)0xB9CDE0, EnableFFBHook, (void**)&EnableFFBOri);
+ MH_CreateHookApi(L"inpout32.dll", "Out32", Out32Hook, (void**)&Out32Ori);
+ MH_EnableHook(MH_ALL_HOOKS);
+ }
}
- if (Wheels > 0)
- {
- double percentForce = Wheels / 37.0;
- double percentLength = 100;
- triggers->Rumble(percentForce, percentForce, percentLength);
- triggers->Sine(80, 80, percentForce);
- }
-
- if (Skids > 12 && speedo > 0)
- {
- double percentForce = ((Skids - 12) / 8.0);
- double percentLength = 100;
- triggers->Rumble(percentForce, 0, percentLength);
- }
-
- if (AI > 0 && PanelBase4 > 0)
- {
- double percentForce = PanelBase4 / 8.0;
- double percentLength = 100;
- triggers->Rumble(percentForce, percentForce, percentLength);
- }
-
- if (WallBase4 > 0 && PanelBase4 > 0)
- {
- double percentForce = PanelBase4 / 8.0;
- double percentLength = 100;
- triggers->Rumble(percentForce, 0, percentLength);
- triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce);
- }
- else if (WallBase4 < 0 && PanelBase4 > 0)
- {
- double percentForce = PanelBase4 / 8.0;
- double percentLength = 100;
- triggers->Rumble(0, percentForce, percentLength);
- triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);
- }
- oldgear = newgear;
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
diff --git a/Game Files/RoadFighters3D.cpp b/Game Files/RoadFighters3D.cpp
index 87db38d..c9146ac 100644
--- a/Game Files/RoadFighters3D.cpp
+++ b/Game Files/RoadFighters3D.cpp
@@ -104,8 +104,7 @@ static int ThreadLoop()
int cabid = myHelpers->ReadByte((INT_PTR)gl_hjgtDll + 0x951034, false);
int cabid2 = myHelpers->ReadByte((INT_PTR)gl_hjgtDll + 0x952B9C, false);
float timeroutofmenu = myHelpers->ReadByte((INT_PTR)gl_hjgtDll + 0x94BEE8, false);
- uintptr_t jgtBase;
- jgtBase = (uintptr_t)GetModuleHandleA("jgt.dll");
+ uintptr_t jgtBase = (uintptr_t)GetModuleHandleA("jgt.dll");
if (CabinetID == 2)
{
diff --git a/Game Files/SegaRally3Other.cpp b/Game Files/SegaRally3Other.cpp
index 8be4c64..ac7b5b5 100644
--- a/Game Files/SegaRally3Other.cpp
+++ b/Game Files/SegaRally3Other.cpp
@@ -20,14 +20,14 @@ static int __stdcall Out32(DWORD device, DWORD data)
{
double percentForce = (31 - data) / 15.0;
double percentLength = 100;
- myTriggers->LeftRight(percentForce, 0, percentLength);
+ myTriggers->Rumble(percentForce, 0, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce);
}
else if (data > 0)
{
double percentForce = (16 - data) / 15.0;
double percentLength = 100;
- myTriggers->LeftRight(0, percentForce, percentLength);
+ myTriggers->Rumble(0, percentForce, percentLength);
myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce);
}
return 0;