1
0
mirror of synced 2024-11-23 22:40:57 +01:00

Modify Joystick Instance stuff

This commit is contained in:
Aaron M 2021-02-17 20:54:00 +13:00
parent 1d41447940
commit 7965d74479
17 changed files with 21 additions and 21 deletions

View File

@ -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)

View File

@ -13,7 +13,7 @@ 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);

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);
}
}