From 7965d74479d7512dc46a033c4cfd2d5c3d781a8d Mon Sep 17 00:00:00 2001 From: Aaron M Date: Wed, 17 Feb 2021 20:54:00 +1300 Subject: [PATCH] Modify Joystick Instance stuff --- DllMain.cpp | 4 ++-- Game Files/AfterburnerClimax.cpp | 2 +- Game Files/AliensExtermination.cpp | 2 +- Game Files/ButtonRumble.cpp | 2 +- Game Files/DemulATVTrackInputs.cpp | 2 +- Game Files/DemulFasterThanSpeedInputs.cpp | 2 +- Game Files/DemulInitialDInputs.cpp | 2 +- Game Files/DemulMaximumSpeedInputs.cpp | 2 +- Game Files/DemulNascarInputs.cpp | 2 +- Game Files/DemulSmashingDriveInputs.cpp | 2 +- Game Files/GoldenGun.cpp | 2 +- Game Files/HOTD4.cpp | 2 +- Game Files/LGI.cpp | 2 +- Game Files/LGI3D.cpp | 2 +- Game Files/MAMESupermodel.cpp | 4 ++-- Game Files/Rambo.cpp | 2 +- Game Files/StormRacerG.cpp | 6 +++--- 17 files changed, 21 insertions(+), 21 deletions(-) diff --git a/DllMain.cpp b/DllMain.cpp index 7f6b074..ddd7c78 100644 --- a/DllMain.cpp +++ b/DllMain.cpp @@ -1036,7 +1036,6 @@ void Initialize(int device_index) { SDL_Joystick* js = SDL_JoystickOpen(i); const char* name = SDL_JoystickName(js); - joystick_index1 = SDL_JoystickInstanceID(js); guid = SDL_JoystickGetGUID(js); if (ForceShowDeviceGUIDMessageBox == 1) { @@ -1055,8 +1054,9 @@ void Initialize(int device_index) SDL_JoystickClose(js); if (!memcmp(&guid, &dev_guid, sizeof(SDL_JoystickGUID))) { - joystick1Index = i; + joystick1Index = i; GameController = SDL_JoystickOpen(i); + joystick_index1 = SDL_JoystickInstanceID(GameController); ControllerHaptic = SDL_HapticOpenFromJoystick(GameController); // We save the first controller matching the guid to select this one if no haptic controller with the same guid is found. if (FirstGameController == NULL) diff --git a/Game Files/AfterburnerClimax.cpp b/Game Files/AfterburnerClimax.cpp index 70232a2..50401f4 100644 --- a/Game Files/AfterburnerClimax.cpp +++ b/Game Files/AfterburnerClimax.cpp @@ -13,7 +13,7 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>. #include #include "AfterburnerClimax.h" -#include "SDL.h" + void AfterburnerClimax::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) { UINT8 ff = helpers->ReadByte(0x08347A5E, /* isRelativeOffset */ false); diff --git a/Game Files/AliensExtermination.cpp b/Game Files/AliensExtermination.cpp index e76968f..e03f462 100644 --- a/Game Files/AliensExtermination.cpp +++ b/Game Files/AliensExtermination.cpp @@ -85,7 +85,6 @@ void AliensExtermination::FFBLoop(EffectConstants* constants, Helpers* helpers, continue; } SDL_Joystick* js2 = SDL_JoystickOpen(i); - joystick_index2 = SDL_JoystickInstanceID(js2); SDL_JoystickGUID guid = SDL_JoystickGetGUID(js2); char guid_str[1024]; SDL_JoystickGetGUIDString(guid, guid_str, sizeof(guid_str)); @@ -97,6 +96,7 @@ void AliensExtermination::FFBLoop(EffectConstants* constants, Helpers* helpers, if (!memcmp(&guid, &dev_guid, sizeof(SDL_JoystickGUID))) { GameController2 = SDL_JoystickOpen(i); + joystick_index2 = SDL_JoystickInstanceID(GameController2); ControllerHaptic2 = SDL_HapticOpenFromJoystick(GameController2); break; } diff --git a/Game Files/ButtonRumble.cpp b/Game Files/ButtonRumble.cpp index 6b7343d..bd2eb16 100644 --- a/Game Files/ButtonRumble.cpp +++ b/Game Files/ButtonRumble.cpp @@ -73,7 +73,6 @@ void ButtonRumble::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectT continue; } SDL_Joystick* js2 = SDL_JoystickOpen(i); - joystick_index2 = SDL_JoystickInstanceID(js2); SDL_JoystickGUID guid = SDL_JoystickGetGUID(js2); char guid_str[1024]; SDL_JoystickGetGUIDString(guid, guid_str, sizeof(guid_str)); @@ -85,6 +84,7 @@ void ButtonRumble::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectT if (!memcmp(&guid, &dev_guid, sizeof(SDL_JoystickGUID))) { GameController2 = SDL_JoystickOpen(i); + joystick_index2 = SDL_JoystickInstanceID(GameController2); ControllerHaptic2 = SDL_HapticOpenFromJoystick(GameController2); break; } diff --git a/Game Files/DemulATVTrackInputs.cpp b/Game Files/DemulATVTrackInputs.cpp index 00f9f17..9a2333d 100644 --- a/Game Files/DemulATVTrackInputs.cpp +++ b/Game Files/DemulATVTrackInputs.cpp @@ -73,7 +73,6 @@ void ATVTrackInputsEnabled(Helpers* helpers) for (int i = 0; i < SDL_NumJoysticks(); i++) { SDL_Joystick* js2 = SDL_JoystickOpen(i); - joystick_index2 = SDL_JoystickInstanceID(js2); SDL_JoystickGUID guid = SDL_JoystickGetGUID(js2); char guid_str[1024]; SDL_JoystickGetGUIDString(guid, guid_str, sizeof(guid_str)); @@ -86,6 +85,7 @@ void ATVTrackInputsEnabled(Helpers* helpers) if (!memcmp(&guid, &dev_guid, sizeof(SDL_JoystickGUID))) { GameController2 = SDL_JoystickOpen(i); + joystick_index2 = SDL_JoystickInstanceID(GameController2); break; } } diff --git a/Game Files/DemulFasterThanSpeedInputs.cpp b/Game Files/DemulFasterThanSpeedInputs.cpp index 27e6423..95e215c 100644 --- a/Game Files/DemulFasterThanSpeedInputs.cpp +++ b/Game Files/DemulFasterThanSpeedInputs.cpp @@ -68,7 +68,6 @@ void FasterThanSpeedInputsEnabled(Helpers* helpers) for (int i = 0; i < SDL_NumJoysticks(); i++) { SDL_Joystick* js2 = SDL_JoystickOpen(i); - joystick_index2 = SDL_JoystickInstanceID(js2); SDL_JoystickGUID guid = SDL_JoystickGetGUID(js2); char guid_str[1024]; SDL_JoystickGetGUIDString(guid, guid_str, sizeof(guid_str)); @@ -81,6 +80,7 @@ void FasterThanSpeedInputsEnabled(Helpers* helpers) if (!memcmp(&guid, &dev_guid, sizeof(SDL_JoystickGUID))) { GameController2 = SDL_JoystickOpen(i); + joystick_index2 = SDL_JoystickInstanceID(GameController2); break; } } diff --git a/Game Files/DemulInitialDInputs.cpp b/Game Files/DemulInitialDInputs.cpp index 1ce12be..a5c473e 100644 --- a/Game Files/DemulInitialDInputs.cpp +++ b/Game Files/DemulInitialDInputs.cpp @@ -75,7 +75,6 @@ void InitialDInputsEnabled(Helpers* helpers) for (int i = 0; i < SDL_NumJoysticks(); i++) { SDL_Joystick* js2 = SDL_JoystickOpen(i); - joystick_index2 = SDL_JoystickInstanceID(js2); SDL_JoystickGUID guid = SDL_JoystickGetGUID(js2); char guid_str[1024]; SDL_JoystickGetGUIDString(guid, guid_str, sizeof(guid_str)); @@ -88,6 +87,7 @@ void InitialDInputsEnabled(Helpers* helpers) if (!memcmp(&guid, &dev_guid, sizeof(SDL_JoystickGUID))) { GameController2 = SDL_JoystickOpen(i); + joystick_index2 = SDL_JoystickInstanceID(GameController2); break; } } diff --git a/Game Files/DemulMaximumSpeedInputs.cpp b/Game Files/DemulMaximumSpeedInputs.cpp index ceadde4..ee7b011 100644 --- a/Game Files/DemulMaximumSpeedInputs.cpp +++ b/Game Files/DemulMaximumSpeedInputs.cpp @@ -65,7 +65,6 @@ void MaximumSpeedInputsEnabled(Helpers* helpers) for (int i = 0; i < SDL_NumJoysticks(); i++) { SDL_Joystick* js2 = SDL_JoystickOpen(i); - joystick_index2 = SDL_JoystickInstanceID(js2); SDL_JoystickGUID guid = SDL_JoystickGetGUID(js2); char guid_str[1024]; SDL_JoystickGetGUIDString(guid, guid_str, sizeof(guid_str)); @@ -78,6 +77,7 @@ void MaximumSpeedInputsEnabled(Helpers* helpers) if (!memcmp(&guid, &dev_guid, sizeof(SDL_JoystickGUID))) { GameController2 = SDL_JoystickOpen(i); + joystick_index2 = SDL_JoystickInstanceID(GameController2); break; } } diff --git a/Game Files/DemulNascarInputs.cpp b/Game Files/DemulNascarInputs.cpp index bfc007d..0e977ac 100644 --- a/Game Files/DemulNascarInputs.cpp +++ b/Game Files/DemulNascarInputs.cpp @@ -77,7 +77,6 @@ void NascarInputsEnabled(Helpers* helpers) for (int i = 0; i < SDL_NumJoysticks(); i++) { SDL_Joystick* js2 = SDL_JoystickOpen(i); - joystick_index2 = SDL_JoystickInstanceID(js2); SDL_JoystickGUID guid = SDL_JoystickGetGUID(js2); char guid_str[1024]; SDL_JoystickGetGUIDString(guid, guid_str, sizeof(guid_str)); @@ -90,6 +89,7 @@ void NascarInputsEnabled(Helpers* helpers) if (!memcmp(&guid, &dev_guid, sizeof(SDL_JoystickGUID))) { GameController2 = SDL_JoystickOpen(i); + joystick_index2 = SDL_JoystickInstanceID(GameController2); break; } } diff --git a/Game Files/DemulSmashingDriveInputs.cpp b/Game Files/DemulSmashingDriveInputs.cpp index c7d3ba2..db5f854 100644 --- a/Game Files/DemulSmashingDriveInputs.cpp +++ b/Game Files/DemulSmashingDriveInputs.cpp @@ -69,7 +69,6 @@ void SmashingDriveInputsEnabled(Helpers* helpers) for (int i = 0; i < SDL_NumJoysticks(); i++) { SDL_Joystick* js2 = SDL_JoystickOpen(i); - joystick_index2 = SDL_JoystickInstanceID(js2); SDL_JoystickGUID guid = SDL_JoystickGetGUID(js2); char guid_str[1024]; SDL_JoystickGetGUIDString(guid, guid_str, sizeof(guid_str)); @@ -82,6 +81,7 @@ void SmashingDriveInputsEnabled(Helpers* helpers) if (!memcmp(&guid, &dev_guid, sizeof(SDL_JoystickGUID))) { GameController2 = SDL_JoystickOpen(i); + joystick_index2 = SDL_JoystickInstanceID(GameController2); break; } } diff --git a/Game Files/GoldenGun.cpp b/Game Files/GoldenGun.cpp index 3b856a8..ae2dcfa 100644 --- a/Game Files/GoldenGun.cpp +++ b/Game Files/GoldenGun.cpp @@ -83,7 +83,6 @@ void GoldenGun::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTrig continue; } SDL_Joystick* js2 = SDL_JoystickOpen(i); - joystick_index2 = SDL_JoystickInstanceID(js2); SDL_JoystickGUID guid = SDL_JoystickGetGUID(js2); char guid_str[1024]; SDL_JoystickGetGUIDString(guid, guid_str, sizeof(guid_str)); @@ -95,6 +94,7 @@ void GoldenGun::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTrig if (!memcmp(&guid, &dev_guid, sizeof(SDL_JoystickGUID))) { GameController2 = SDL_JoystickOpen(i); + joystick_index2 = SDL_JoystickInstanceID(GameController2); ControllerHaptic2 = SDL_HapticOpenFromJoystick(GameController2); break; } diff --git a/Game Files/HOTD4.cpp b/Game Files/HOTD4.cpp index 326230d..0fa45ab 100644 --- a/Game Files/HOTD4.cpp +++ b/Game Files/HOTD4.cpp @@ -305,7 +305,6 @@ void HOTD4::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers continue; } SDL_Joystick* js2 = SDL_JoystickOpen(i); - joystick_index2 = SDL_JoystickInstanceID(js2); SDL_JoystickGUID guid = SDL_JoystickGetGUID(js2); char guid_str[1024]; SDL_JoystickGetGUIDString(guid, guid_str, sizeof(guid_str)); @@ -317,6 +316,7 @@ void HOTD4::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers if (!memcmp(&guid, &dev_guid, sizeof(SDL_JoystickGUID))) { GameController2 = SDL_JoystickOpen(i); + joystick_index2 = SDL_JoystickInstanceID(GameController2); ControllerHaptic2 = SDL_HapticOpenFromJoystick(GameController2); break; } diff --git a/Game Files/LGI.cpp b/Game Files/LGI.cpp index 8b5cb41..e3a1d31 100644 --- a/Game Files/LGI.cpp +++ b/Game Files/LGI.cpp @@ -71,7 +71,6 @@ void LGI::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* continue; } SDL_Joystick* js2 = SDL_JoystickOpen(i); - joystick_index2 = SDL_JoystickInstanceID(js2); SDL_JoystickGUID guid = SDL_JoystickGetGUID(js2); char guid_str[1024]; SDL_JoystickGetGUIDString(guid, guid_str, sizeof(guid_str)); @@ -83,6 +82,7 @@ void LGI::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* if (!memcmp(&guid, &dev_guid, sizeof(SDL_JoystickGUID))) { GameController2 = SDL_JoystickOpen(i); + joystick_index2 = SDL_JoystickInstanceID(GameController2); ControllerHaptic2 = SDL_HapticOpenFromJoystick(GameController2); break; } diff --git a/Game Files/LGI3D.cpp b/Game Files/LGI3D.cpp index cbab785..55902d7 100644 --- a/Game Files/LGI3D.cpp +++ b/Game Files/LGI3D.cpp @@ -72,7 +72,6 @@ void LGI3D::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers continue; } SDL_Joystick* js2 = SDL_JoystickOpen(i); - joystick_index2 = SDL_JoystickInstanceID(js2); SDL_JoystickGUID guid = SDL_JoystickGetGUID(js2); char guid_str[1024]; SDL_JoystickGetGUIDString(guid, guid_str, sizeof(guid_str)); @@ -84,6 +83,7 @@ void LGI3D::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers if (!memcmp(&guid, &dev_guid, sizeof(SDL_JoystickGUID))) { GameController2 = SDL_JoystickOpen(i); + joystick_index2 = SDL_JoystickInstanceID(GameController2); ControllerHaptic2 = SDL_HapticOpenFromJoystick(GameController2); break; } diff --git a/Game Files/MAMESupermodel.cpp b/Game Files/MAMESupermodel.cpp index 5eb4803..8b0789d 100644 --- a/Game Files/MAMESupermodel.cpp +++ b/Game Files/MAMESupermodel.cpp @@ -1565,7 +1565,6 @@ void MAMESupermodel::FFBLoop(EffectConstants* constants, Helpers* helpers, Effec continue; } SDL_Joystick* js2 = SDL_JoystickOpen(i); - joystick_index2 = SDL_JoystickInstanceID(js2); SDL_JoystickGUID guid = SDL_JoystickGetGUID(js2); char guid_str[1024]; SDL_JoystickGetGUIDString(guid, guid_str, sizeof(guid_str)); @@ -1577,6 +1576,7 @@ void MAMESupermodel::FFBLoop(EffectConstants* constants, Helpers* helpers, Effec if (!memcmp(&guid, &dev_guid, sizeof(SDL_JoystickGUID))) { GameController2 = SDL_JoystickOpen(i); + joystick_index2 = SDL_JoystickInstanceID(GameController2); ControllerHaptic2 = SDL_HapticOpenFromJoystick(GameController2); break; } @@ -1603,7 +1603,6 @@ void MAMESupermodel::FFBLoop(EffectConstants* constants, Helpers* helpers, Effec continue; } SDL_Joystick* js3 = SDL_JoystickOpen(i); - joystick_index3 = SDL_JoystickInstanceID(js3); SDL_JoystickGUID guid2 = SDL_JoystickGetGUID(js3); char guid_str2[1024]; SDL_JoystickGetGUIDString(guid2, guid_str2, sizeof(guid_str2)); @@ -1615,6 +1614,7 @@ void MAMESupermodel::FFBLoop(EffectConstants* constants, Helpers* helpers, Effec if (!memcmp(&guid2, &dev_guid2, sizeof(SDL_JoystickGUID))) { GameController3 = SDL_JoystickOpen(i); + joystick_index3 = SDL_JoystickInstanceID(GameController3); ControllerHaptic3 = SDL_HapticOpenFromJoystick(GameController3); break; } diff --git a/Game Files/Rambo.cpp b/Game Files/Rambo.cpp index 7bc473b..748db01 100644 --- a/Game Files/Rambo.cpp +++ b/Game Files/Rambo.cpp @@ -90,7 +90,6 @@ void Rambo::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers continue; } SDL_Joystick* js2 = SDL_JoystickOpen(i); - joystick_index2 = SDL_JoystickInstanceID(js2); SDL_JoystickGUID guid = SDL_JoystickGetGUID(js2); char guid_str[1024]; SDL_JoystickGetGUIDString(guid, guid_str, sizeof(guid_str)); @@ -102,6 +101,7 @@ void Rambo::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers if (!memcmp(&guid, &dev_guid, sizeof(SDL_JoystickGUID))) { GameController2 = SDL_JoystickOpen(i); + joystick_index2 = SDL_JoystickInstanceID(GameController2); ControllerHaptic2 = SDL_HapticOpenFromJoystick(GameController2); break; } diff --git a/Game Files/StormRacerG.cpp b/Game Files/StormRacerG.cpp index ea9ec9b..f913efa 100644 --- a/Game Files/StormRacerG.cpp +++ b/Game Files/StormRacerG.cpp @@ -69,17 +69,17 @@ void StormRacerG::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTr if (FFB & 0x01) { - myTriggers->Rumble(percentForce, percentForce, 150); + triggers->Rumble(percentForce, percentForce, 150); } if (FFB & 0x02) { - myTriggers->Rumble(percentForce, percentForce, 150); + triggers->Rumble(percentForce, percentForce, 150); } if (FFB & 0x08) { - myTriggers->Rumble(percentForce, percentForce, 150); + triggers->Rumble(percentForce, percentForce, 150); } }