From 13b43fb573dc758168253930efb53f1925c09c0d Mon Sep 17 00:00:00 2001 From: Boomslangnz Date: Sun, 21 Jul 2024 10:14:02 +1200 Subject: [PATCH] Changes to Initial D FFB etc --- Common Files/Game.cpp | 17 +++++++++++++++++ Common Files/Game.h | 2 ++ DInput8Wrapper.aps | Bin 2740 -> 2740 bytes DInput8Wrapper.rc | Bin 5212 -> 5212 bytes Game Files/Demul.cpp | 15 ++++++++------- Game Files/IDTAv231.cpp | 15 ++++++++------- Game Files/InitialD0v131.cpp | 15 ++++++++------- Game Files/InitialD0v211.cpp | 15 ++++++++------- Game Files/InitialD0v230.cpp | 22 ++++++++-------------- Game Files/InitialD4.cpp | 15 ++++++++------- Game Files/InitialD4Japan.cpp | 15 ++++++++------- Game Files/InitialD5.cpp | 15 ++++++++------- Game Files/KODrive.cpp | 17 +++++++++-------- Game Files/SWDC2018.cpp | 23 +++++++++++++++-------- Version.txt | 2 +- 15 files changed, 108 insertions(+), 80 deletions(-) diff --git a/Common Files/Game.cpp b/Common Files/Game.cpp index 8701f92..e45b85e 100644 --- a/Common Files/Game.cpp +++ b/Common Files/Game.cpp @@ -78,6 +78,14 @@ UINT8 Helpers::WriteByte(INT_PTR offset, UINT8 val, bool isRelativeOffset) return val; } +WORD Helpers::WriteWord(INT_PTR offset, WORD val, bool isRelativeOffset) +{ + SIZE_T written; + LPVOID trueOffset = (isRelativeOffset ? GetTranslatedOffset(offset) : (LPVOID)offset); + WriteProcessMemory(GetCurrentProcess(), trueOffset, &val, sizeof(WORD), &written); + return val; +} + INT_PTR Helpers::WriteIntPtr(INT_PTR offset, INT_PTR val, bool isRelativeOffset) { SIZE_T written; @@ -123,6 +131,15 @@ INT_PTR Helpers::ReadIntPtr(INT_PTR offset, bool isRelativeOffset) return val; }; +WORD Helpers::ReadWord(INT_PTR offset, bool isRelativeOffset) +{ + SIZE_T read; + LPVOID trueOffset = (isRelativeOffset ? GetTranslatedOffset(offset) : (LPVOID)offset); + WORD val; + ReadProcessMemory(GetCurrentProcess(), trueOffset, &val, sizeof(WORD), &read); + return val; +}; + long long Helpers::ReadLong(INT_PTR offset, bool isRelativeOffset) { SIZE_T read; diff --git a/Common Files/Game.h b/Common Files/Game.h index 3debe07..b70c5f8 100644 --- a/Common Files/Game.h +++ b/Common Files/Game.h @@ -106,10 +106,12 @@ public: LPVOID GetTranslatedOffset(INT_PTR offset); int ReadInt32(INT_PTR offset, bool isRelativeOffset); UINT8 ReadByte(INT_PTR offset, bool isRelativeOffset); + WORD ReadWord(INT_PTR offset, bool isRelativeOffset); float WriteFloat32(INT_PTR offset, float val, bool isRelativeOffset); UINT8 WriteByte(INT_PTR offset, UINT8 val, bool isRelativeOffset); INT_PTR WriteIntPtr(INT_PTR offset, INT_PTR val, bool isRelativeOffset); UINT8 WriteNop(INT_PTR offset, int countBytes, bool isRelativeOffset); + WORD WriteWord(INT_PTR offset, WORD val, bool isRelativeOffset); INT_PTR ReadIntPtr(INT_PTR offset, bool isRelativeOffset); long long ReadLong(INT_PTR offset, bool isRelativeOffset); float ReadFloat32(INT_PTR offset, bool isRelativeOffset); diff --git a/DInput8Wrapper.aps b/DInput8Wrapper.aps index 44f5a0ed124cf0a538f18891357411f58c096ea8..17df7d58bdcd31643e55defb903957cb50b429f3 100644 GIT binary patch delta 36 ncmdlYx&8j0|+oNm~2jEQ)FZ`+T6~r4Wc%4FfsuEl+_2E delta 36 ncmdlYx&900|+oN7;jExQ)FZ`+}zHt4Wc%4FfsuEl#&OS diff --git a/DInput8Wrapper.rc b/DInput8Wrapper.rc index 85f4579152679474f46bbb36a7d507de43a157ee..7a5c48c176380ee9838606f4ee0edc447b6cf28e 100644 GIT binary patch delta 38 rcmcbkaYtiA7&oKQ&0@^G9@LdZr delta 38 rcmcbkaYtiA7&oKg&0@^G9@DK|v diff --git a/Game Files/Demul.cpp b/Game Files/Demul.cpp index e71f2e2..5f2b1cb 100644 --- a/Game Files/Demul.cpp +++ b/Game Files/Demul.cpp @@ -322,6 +322,7 @@ int fasterspeed(int ffspeed) { static int InitialDFFBLoop() { DWORD FFB = myHelpers->ReadInt32(FFBAddress, false); + WORD FFBStr = myHelpers->ReadWord(FFBAddress + 0x02, false); BYTE* ffb = reinterpret_cast(&FFB); @@ -332,34 +333,34 @@ static int InitialDFFBLoop() myTriggers->Spring(1.0); } - if (ffb[0] == 0x85 && ffb[1] > 0x00 && ffb[2] > 0x00) + if (ffb[0] == 0x85 && ffb[1] > 0x00 && FFBStr > 0x00) { - double percentForce = ffb[2] / 127.0; + double percentForce = FFBStr / 32767.0; double Period = ffb[1] / 127.0 * 120.0; double percentLength = 100; myTriggers->Rumble(percentForce, percentForce, percentLength); myTriggers->Sine(static_cast(Period), 0, percentForce); } - if (ffb[0] == 0x86 && ffb[2] > 0x00) + if (ffb[0] == 0x86 && FFBStr) { - double percentForce = ffb[2] / 127.0; + double percentForce = FFBStr / 32767.0; double percentLength = 100; myTriggers->Spring(percentForce); } - if (ffb[0] == 0x84 && ffb[2] > 0x00) + if (ffb[0] == 0x84 && FFBStr > 0x00) { if (ffb[1] == 0x00) { - double percentForce = (128 - ffb[2]) / 127.0; + double percentForce = (32767.0 - FFBStr) / 32767.0; double percentLength = 100; myTriggers->Rumble(percentForce, 0, percentLength); myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce); } else if (ffb[1] == 0x01) { - double percentForce = (ffb[2] / 127.0); + double percentForce = (FFBStr / 32767.0); double percentLength = 100; myTriggers->Rumble(0, percentForce, percentLength); myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce); diff --git a/Game Files/IDTAv231.cpp b/Game Files/IDTAv231.cpp index f5e145e..ca1d9a1 100644 --- a/Game Files/IDTAv231.cpp +++ b/Game Files/IDTAv231.cpp @@ -30,6 +30,7 @@ void InitialDTA231::FFBLoop(EffectConstants* constants, Helpers* helpers, Effect triggers->Damper(DamperStrength / 100.0); DWORD FFB = helpers->ReadInt32(0x3D35838, true); + WORD FFBStr = helpers->ReadWord(0x3D3583A, true); BYTE* ffb = reinterpret_cast(&FFB); @@ -38,34 +39,34 @@ void InitialDTA231::FFBLoop(EffectConstants* constants, Helpers* helpers, Effect triggers->Spring(1.0); } - if (ffb[0] == 0x85 && ffb[1] > 0x00 && ffb[2] > 0x00) + if (ffb[0] == 0x85 && ffb[1] > 0x00 && FFBStr > 0x00) { - double percentForce = ffb[2] / 127.0; + double percentForce = FFBStr / 32767.0; double Period = ffb[1] / 127.0 * 120.0; double percentLength = 100; triggers->Rumble(percentForce, percentForce, percentLength); triggers->Sine(static_cast(Period), 0, percentForce); } - if (ffb[0] == 0x86 && ffb[2] > 0x00) + if (ffb[0] == 0x86 && FFBStr) { - double percentForce = ffb[2] / 127.0; + double percentForce = FFBStr / 32767.0; double percentLength = 100; triggers->Spring(percentForce); } - if (ffb[0] == 0x84 && ffb[2] > 0x00) + if (ffb[0] == 0x84 && FFBStr > 0x00) { if (ffb[1] == 0x00) { - double percentForce = (128 - ffb[2]) / 127.0; + double percentForce = (32767.0 - FFBStr) / 32767.0; double percentLength = 100; triggers->Rumble(percentForce, 0, percentLength); triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); } else if (ffb[1] == 0x01) { - double percentForce = (ffb[2] / 127.0); + double percentForce = (FFBStr / 32767.0); double percentLength = 100; triggers->Rumble(0, percentForce, percentLength); triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); diff --git a/Game Files/InitialD0v131.cpp b/Game Files/InitialD0v131.cpp index e2b85d9..4fcd720 100644 --- a/Game Files/InitialD0v131.cpp +++ b/Game Files/InitialD0v131.cpp @@ -44,6 +44,7 @@ void InitialD0::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTrig triggers->Damper(DamperStrength / 100.0); DWORD FFB = helpers->ReadInt32(0x168317C, true); + WORD FFBStr = helpers->ReadWord(0x168317E, true); BYTE* ffb = reinterpret_cast(&FFB); @@ -52,34 +53,34 @@ void InitialD0::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTrig triggers->Spring(1.0); } - if (ffb[0] == 0x85 && ffb[1] > 0x00 && ffb[2] > 0x00) + if (ffb[0] == 0x85 && ffb[1] > 0x00 && FFBStr > 0x00) { - double percentForce = ffb[2] / 127.0; + double percentForce = FFBStr / 32767.0; double Period = ffb[1] / 127.0 * 120.0; double percentLength = 100; triggers->Rumble(percentForce, percentForce, percentLength); triggers->Sine(static_cast(Period), 0, percentForce); } - if (ffb[0] == 0x86 && ffb[2] > 0x00) + if (ffb[0] == 0x86 && FFBStr) { - double percentForce = ffb[2] / 127.0; + double percentForce = FFBStr / 32767.0; double percentLength = 100; triggers->Spring(percentForce); } - if (ffb[0] == 0x84 && ffb[2] > 0x00) + if (ffb[0] == 0x84 && FFBStr > 0x00) { if (ffb[1] == 0x00) { - double percentForce = (128 - ffb[2]) / 127.0; + double percentForce = (32767.0 - FFBStr) / 32767.0; double percentLength = 100; triggers->Rumble(percentForce, 0, percentLength); triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); } else if (ffb[1] == 0x01) { - double percentForce = (ffb[2] / 127.0); + double percentForce = (FFBStr / 32767.0); double percentLength = 100; triggers->Rumble(0, percentForce, percentLength); triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); diff --git a/Game Files/InitialD0v211.cpp b/Game Files/InitialD0v211.cpp index 48a1cd3..24f1436 100644 --- a/Game Files/InitialD0v211.cpp +++ b/Game Files/InitialD0v211.cpp @@ -44,6 +44,7 @@ void InitialD0v211::FFBLoop(EffectConstants* constants, Helpers* helpers, Effect triggers->Damper(DamperStrength / 100.0); DWORD FFB = helpers->ReadInt32(0x18A720C, true); + WORD FFBStr = helpers->ReadWord(0x18A720E, true); BYTE* ffb = reinterpret_cast(&FFB); @@ -52,34 +53,34 @@ void InitialD0v211::FFBLoop(EffectConstants* constants, Helpers* helpers, Effect triggers->Spring(1.0); } - if (ffb[0] == 0x85 && ffb[1] > 0x00 && ffb[2] > 0x00) + if (ffb[0] == 0x85 && ffb[1] > 0x00 && FFBStr > 0x00) { - double percentForce = ffb[2] / 127.0; + double percentForce = FFBStr / 32767.0; double Period = ffb[1] / 127.0 * 120.0; double percentLength = 100; triggers->Rumble(percentForce, percentForce, percentLength); triggers->Sine(static_cast(Period), 0, percentForce); } - if (ffb[0] == 0x86 && ffb[2] > 0x00) + if (ffb[0] == 0x86 && FFBStr) { - double percentForce = ffb[2] / 127.0; + double percentForce = FFBStr / 32767.0; double percentLength = 100; triggers->Spring(percentForce); } - if (ffb[0] == 0x84 && ffb[2] > 0x00) + if (ffb[0] == 0x84 && FFBStr > 0x00) { if (ffb[1] == 0x00) { - double percentForce = (128 - ffb[2]) / 127.0; + double percentForce = (32767.0 - FFBStr) / 32767.0; double percentLength = 100; triggers->Rumble(percentForce, 0, percentLength); triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); } else if (ffb[1] == 0x01) { - double percentForce = (ffb[2] / 127.0); + double percentForce = (FFBStr / 32767.0); double percentLength = 100; triggers->Rumble(0, percentForce, percentLength); triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); diff --git a/Game Files/InitialD0v230.cpp b/Game Files/InitialD0v230.cpp index 20de671..a7553d8 100644 --- a/Game Files/InitialD0v230.cpp +++ b/Game Files/InitialD0v230.cpp @@ -44,6 +44,7 @@ void InitialD0v230::FFBLoop(EffectConstants* constants, Helpers* helpers, Effect triggers->Damper(DamperStrength / 100.0); DWORD FFB = helpers->ReadInt32(0x18B54DC, true); + WORD FFBStr = helpers->ReadWord(0x18B54DE, true); BYTE* ffb = reinterpret_cast(&FFB); @@ -52,41 +53,34 @@ void InitialD0v230::FFBLoop(EffectConstants* constants, Helpers* helpers, Effect triggers->Spring(1.0); } - if (ffb[0] == 0x85 && ffb[1] > 0x00 && ffb[2] > 0x00) + if (ffb[0] == 0x85 && ffb[1] > 0x00 && FFBStr > 0x00) { - double percentForce = ffb[2] / 127.0; + double percentForce = FFBStr / 32767.0; double Period = ffb[1] / 127.0 * 120.0; double percentLength = 100; triggers->Rumble(percentForce, percentForce, percentLength); triggers->Sine(static_cast(Period), 0, percentForce); } - if (ffb[0] == 0x86 && ffb[2] > 0x00) + if (ffb[0] == 0x86 && FFBStr) { - double percentForce = ffb[2] / 127.0; + double percentForce = FFBStr / 32767.0; double percentLength = 100; triggers->Spring(percentForce); } - if (ffb[0] == 0x86 && ffb[2] > 0x00) - { - double percentForce = ffb[2] / 127.0; - double percentLength = 100; - triggers->Spring(percentForce); - } - - if (ffb[0] == 0x84 && ffb[2] > 0x00) + if (ffb[0] == 0x84 && FFBStr > 0x00) { if (ffb[1] == 0x00) { - double percentForce = (128 - ffb[2]) / 127.0; + double percentForce = (32767.0 - FFBStr) / 32767.0; double percentLength = 100; triggers->Rumble(percentForce, 0, percentLength); triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); } else if (ffb[1] == 0x01) { - double percentForce = (ffb[2] / 127.0); + double percentForce = (FFBStr / 32767.0); double percentLength = 100; triggers->Rumble(0, percentForce, percentLength); triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); diff --git a/Game Files/InitialD4.cpp b/Game Files/InitialD4.cpp index 94b5dc6..f86bfdf 100644 --- a/Game Files/InitialD4.cpp +++ b/Game Files/InitialD4.cpp @@ -20,6 +20,7 @@ extern int DamperStrength; void InitialD4::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) { DWORD FFB = helpers->ReadInt32(0x089AE898, false); + WORD FFBStr = helpers->ReadWord(0x089AE89A, false); BYTE* ffb = reinterpret_cast(&FFB); @@ -28,34 +29,34 @@ void InitialD4::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTrig triggers->Spring(1.0); } - if (ffb[0] == 0x85 && ffb[1] > 0x00 && ffb[2] > 0x00) + if (ffb[0] == 0x85 && ffb[1] > 0x00 && FFBStr > 0x00) { - double percentForce = ffb[2] / 127.0; + double percentForce = FFBStr / 32767.0; double Period = ffb[1] / 127.0 * 120.0; double percentLength = 100; triggers->Rumble(percentForce, percentForce, percentLength); triggers->Sine(static_cast(Period), 0, percentForce); } - if (ffb[0] == 0x86 && ffb[2] > 0x00) + if (ffb[0] == 0x86 && FFBStr) { - double percentForce = ffb[2] / 127.0; + double percentForce = FFBStr / 32767.0; double percentLength = 100; triggers->Spring(percentForce); } - if (ffb[0] == 0x84 && ffb[2] > 0x00) + if (ffb[0] == 0x84 && FFBStr > 0x00) { if (ffb[1] == 0x00) { - double percentForce = (128 - ffb[2]) / 127.0; + double percentForce = (32767.0 - FFBStr) / 32767.0; double percentLength = 100; triggers->Rumble(percentForce, 0, percentLength); triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); } else if (ffb[1] == 0x01) { - double percentForce = (ffb[2] / 127.0); + double percentForce = (FFBStr / 32767.0); double percentLength = 100; triggers->Rumble(0, percentForce, percentLength); triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); diff --git a/Game Files/InitialD4Japan.cpp b/Game Files/InitialD4Japan.cpp index 9ba678c..e67d515 100644 --- a/Game Files/InitialD4Japan.cpp +++ b/Game Files/InitialD4Japan.cpp @@ -24,6 +24,7 @@ void InitialD4Japan::FFBLoop(EffectConstants* constants, Helpers* helpers, Effec triggers->Damper(DamperStrength / 100.0); DWORD FFB = helpers->ReadInt32(0x08989858, false); + WORD FFBStr = helpers->ReadWord(0x0898985A, false); BYTE* ffb = reinterpret_cast(&FFB); @@ -32,34 +33,34 @@ void InitialD4Japan::FFBLoop(EffectConstants* constants, Helpers* helpers, Effec triggers->Spring(1.0); } - if (ffb[0] == 0x85 && ffb[1] > 0x00 && ffb[2] > 0x00) + if (ffb[0] == 0x85 && ffb[1] > 0x00 && FFBStr > 0x00) { - double percentForce = ffb[2] / 127.0; + double percentForce = FFBStr / 32767.0; double Period = ffb[1] / 127.0 * 120.0; double percentLength = 100; triggers->Rumble(percentForce, percentForce, percentLength); triggers->Sine(static_cast(Period), 0, percentForce); } - if (ffb[0] == 0x86 && ffb[2] > 0x00) + if (ffb[0] == 0x86 && FFBStr) { - double percentForce = ffb[2] / 127.0; + double percentForce = FFBStr / 32767.0; double percentLength = 100; triggers->Spring(percentForce); } - if (ffb[0] == 0x84 && ffb[2] > 0x00) + if (ffb[0] == 0x84 && FFBStr > 0x00) { if (ffb[1] == 0x00) { - double percentForce = (128 - ffb[2]) / 127.0; + double percentForce = (32767.0 - FFBStr) / 32767.0; double percentLength = 100; triggers->Rumble(percentForce, 0, percentLength); triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); } else if (ffb[1] == 0x01) { - double percentForce = (ffb[2] / 127.0); + double percentForce = (FFBStr / 32767.0); double percentLength = 100; triggers->Rumble(0, percentForce, percentLength); triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); diff --git a/Game Files/InitialD5.cpp b/Game Files/InitialD5.cpp index 1362956..ad026c8 100644 --- a/Game Files/InitialD5.cpp +++ b/Game Files/InitialD5.cpp @@ -24,6 +24,7 @@ void InitialD5::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTrig triggers->Damper(DamperStrength / 100.0); DWORD FFB = helpers->ReadInt32(0x8CB6120, false); + WORD FFBStr = helpers->ReadWord(0x8CB6122, false); BYTE* ffb = reinterpret_cast(&FFB); @@ -32,34 +33,34 @@ void InitialD5::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTrig triggers->Spring(1.0); } - if (ffb[0] == 0x85 && ffb[1] > 0x00 && ffb[2] > 0x00) + if (ffb[0] == 0x85 && ffb[1] > 0x00 && FFBStr > 0x00) { - double percentForce = ffb[2] / 127.0; + double percentForce = FFBStr / 32767.0; double Period = ffb[1] / 127.0 * 120.0; double percentLength = 100; triggers->Rumble(percentForce, percentForce, percentLength); triggers->Sine(static_cast(Period), 0, percentForce); } - if (ffb[0] == 0x86 && ffb[2] > 0x00) + if (ffb[0] == 0x86 && FFBStr) { - double percentForce = ffb[2] / 127.0; + double percentForce = FFBStr / 32767.0; double percentLength = 100; triggers->Spring(percentForce); } - if (ffb[0] == 0x84 && ffb[2] > 0x00) + if (ffb[0] == 0x84 && FFBStr > 0x00) { if (ffb[1] == 0x00) { - double percentForce = (128 - ffb[2]) / 127.0; + double percentForce = (32767.0 - FFBStr) / 32767.0; double percentLength = 100; triggers->Rumble(percentForce, 0, percentLength); triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); } else if (ffb[1] == 0x01) { - double percentForce = (ffb[2] / 127.0); + double percentForce = (FFBStr / 32767.0); double percentLength = 100; triggers->Rumble(0, percentForce, percentLength); triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); diff --git a/Game Files/KODrive.cpp b/Game Files/KODrive.cpp index ecbaed5..8655432 100644 --- a/Game Files/KODrive.cpp +++ b/Game Files/KODrive.cpp @@ -23,6 +23,7 @@ void KODrive::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTrigge triggers->Damper(DamperStrength / 100.0); DWORD FFB = helpers->ReadInt32(0x7261F4, true); + WORD FFBStr = helpers->ReadWord(0x7261F6, true); BYTE* ffb = reinterpret_cast(&FFB); @@ -31,34 +32,34 @@ void KODrive::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTrigge triggers->Spring(1.0); } - if (ffb[0] == 0x85 && ffb[1] > 0x00 && ffb[2] > 0x00) + if (ffb[0] == 0x85 && ffb[1] > 0x00 && FFBStr > 0x00) { - double percentForce = ffb[2] / 24.0; - double Period = ffb[1] / 128.0 * 120.0; + double percentForce = FFBStr / 32767.0; + double Period = ffb[1] / 127.0 * 120.0; double percentLength = 100; triggers->Rumble(percentForce, percentForce, percentLength); triggers->Sine(static_cast(Period), 0, percentForce); } - if (ffb[0] == 0x86 && ffb[2] > 0x00) + if (ffb[0] == 0x86 && FFBStr) { - double percentForce = ffb[2] / 24.0; + double percentForce = FFBStr / 32767.0; double percentLength = 100; triggers->Spring(percentForce); } - if (ffb[0] == 0x84 && ffb[2] > 0x00) + if (ffb[0] == 0x84 && FFBStr > 0x00) { if (ffb[1] == 0x00) { - double percentForce = (128 - ffb[2]) / 24.0; + double percentForce = (32767.0 - FFBStr) / 32767.0; double percentLength = 100; triggers->Rumble(percentForce, 0, percentLength); triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); } else if (ffb[1] == 0x01) { - double percentForce = (ffb[2] / 24.0); + double percentForce = (FFBStr / 32767.0); double percentLength = 100; triggers->Rumble(0, percentForce, percentLength); triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); diff --git a/Game Files/SWDC2018.cpp b/Game Files/SWDC2018.cpp index 3c783f0..9318425 100644 --- a/Game Files/SWDC2018.cpp +++ b/Game Files/SWDC2018.cpp @@ -22,6 +22,7 @@ static bool Version103; static bool Version230; static DWORD FFB; +static WORD FFBStr; static wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini"); static int EscapeKeyExitViaPlugin = GetPrivateProfileInt(TEXT("Settings"), TEXT("EscapeKeyExitViaPlugin"), 0, settingsFilename); @@ -70,10 +71,16 @@ void SWDC::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* else { if (Version103) + { FFB = helpers->ReadInt32(0x8E5CCF4, true); + FFBStr = helpers->ReadWord(0x8E5CCF6, true); + } if (Version230) + { FFB = helpers->ReadInt32(0x9BC7B18, true); + FFBStr = helpers->ReadWord(0x9BC7B1A, true); + } if (EnableDamper) triggers->Damper(DamperStrength / 100.0); @@ -85,34 +92,34 @@ void SWDC::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers->Spring(1.0); } - if (ffb[0] == 0x85 && ffb[1] > 0x00 && ffb[2] > 0x00) + if (ffb[0] == 0x85 && ffb[1] > 0x00 && FFBStr > 0x00) { - double percentForce = ffb[2] / 127.0; + double percentForce = FFBStr / 32767.0; double Period = ffb[1] / 127.0 * 120.0; double percentLength = 100; triggers->Rumble(percentForce, percentForce, percentLength); triggers->Sine(static_cast(Period), 0, percentForce); } - if (ffb[0] == 0x86 && ffb[2] > 0x00) + if (ffb[0] == 0x86 && FFBStr) { - double percentForce = ffb[2] / 127.0; + double percentForce = FFBStr / 32767.0; double percentLength = 100; triggers->Spring(percentForce); } - if (ffb[0] == 0x84 && ffb[2] > 0x00) + if (ffb[0] == 0x84 && FFBStr > 0x00) { if (ffb[1] == 0x00) { - double percentForce = (128 - ffb[2]) / 127.0; + double percentForce = (32767.0 - FFBStr) / 32767.0; double percentLength = 100; triggers->Rumble(percentForce, 0, percentLength); triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); } - else if(ffb[1] == 0x01) + else if (ffb[1] == 0x01) { - double percentForce = (ffb[2] / 127.0); + double percentForce = (FFBStr / 32767.0); double percentLength = 100; triggers->Rumble(0, percentForce, percentLength); triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); diff --git a/Version.txt b/Version.txt index ee73eee..538661b 100644 --- a/Version.txt +++ b/Version.txt @@ -1 +1 @@ -v2.0.0.51 \ No newline at end of file +v2.0.0.52 \ No newline at end of file