Merge pull request #2 from Boomslangnz/fix-fanatec-duplicate-controller-issue
Fix Fanatec duplicate controller issue
This commit is contained in:
commit
0d7f31cdda
22
DllMain.cpp
22
DllMain.cpp
@ -953,6 +953,8 @@ void Initialize(int device_index)
|
|||||||
hlp.log("numJoysticks = ");
|
hlp.log("numJoysticks = ");
|
||||||
std::string njs = std::to_string(numJoysticks);
|
std::string njs = std::to_string(numJoysticks);
|
||||||
hlp.log((char *)njs.c_str());
|
hlp.log((char *)njs.c_str());
|
||||||
|
char firstJoystickSelectedText[256];
|
||||||
|
SDL_Joystick* FirstGameController = NULL;
|
||||||
for (int i = 0; i< SDL_NumJoysticks(); i++)
|
for (int i = 0; i< SDL_NumJoysticks(); i++)
|
||||||
{
|
{
|
||||||
SDL_Joystick* js = SDL_JoystickOpen(i);
|
SDL_Joystick* js = SDL_JoystickOpen(i);
|
||||||
@ -979,9 +981,27 @@ void Initialize(int device_index)
|
|||||||
joystick1Index = i;
|
joystick1Index = i;
|
||||||
GameController = SDL_JoystickOpen(i);
|
GameController = SDL_JoystickOpen(i);
|
||||||
ControllerHaptic = SDL_HapticOpenFromJoystick(GameController);
|
ControllerHaptic = SDL_HapticOpenFromJoystick(GameController);
|
||||||
break;
|
// 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)
|
||||||
|
{
|
||||||
|
sprintf(firstJoystickSelectedText, "No haptic joystick found, selecting first joystick matching the GUID: %d / Name: %s / GUID: %s\n", i, name, guid_str);
|
||||||
|
FirstGameController = GameController;
|
||||||
|
}
|
||||||
|
// We select the first haptic controller matching the guid.
|
||||||
|
if (ControllerHaptic != NULL)
|
||||||
|
{
|
||||||
|
sprintf(text, "Haptic joystick found: %d / Name: %s / GUID: %s\n", i, name, guid_str);
|
||||||
|
hlp.log(text);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// If no haptic controller has been found, we select the first controller matching the guid.
|
||||||
|
if (ControllerHaptic == NULL)
|
||||||
|
{
|
||||||
|
GameController = FirstGameController;
|
||||||
|
hlp.log(firstJoystickSelectedText);
|
||||||
|
}
|
||||||
haptic = ControllerHaptic;
|
haptic = ControllerHaptic;
|
||||||
if ((SDL_HapticRumbleSupported(haptic) == SDL_TRUE && EnableRumble == 1))
|
if ((SDL_HapticRumbleSupported(haptic) == SDL_TRUE && EnableRumble == 1))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user