Legacy: add a simple joystick model identification hack per Nils' suggestions

This commit is contained in:
Lars A. Doucet
2015-06-16 09:31:09 -05:00
parent a20fbaa89b
commit 16dcfcf5e5

View File

@@ -1395,6 +1395,24 @@ void ProcessEvent(SDL_Event &inEvent)
Event joystick(etJoyDeviceAdded); Event joystick(etJoyDeviceAdded);
sgJoystick = SDL_JoystickOpen(inEvent.jdevice.which); //which: joystick device index sgJoystick = SDL_JoystickOpen(inEvent.jdevice.which); //which: joystick device index
joystick.id = SDL_JoystickInstanceID(sgJoystick); joystick.id = SDL_JoystickInstanceID(sgJoystick);
//get string id
const char * gamepadstring = SDL_JoystickName(sgJoystick);
if (strcmp (gamepadstring, "PLAYSTATION(R)3 Controller") == 0) //PS3 controller
{
joystick.x = 1;
}
else if (strcmp (gamepadstring, "Wireless Controller") == 0) //PS4 controller
{
joystick.x = 2;
}
else if (strcmp (gamepadstring, "OUYA Game Controller") == 0) //OUYA controller
{
joystick.x = 3;
}
else //default (XBox 360, basically)
{
joystick.x = 0;
}
sgJoysticks.push_back(sgJoystick); sgJoysticks.push_back(sgJoystick);
sgJoysticksId.push_back(joystick.id); sgJoysticksId.push_back(joystick.id);
sgJoysticksIndex.push_back(inEvent.jdevice.which); sgJoysticksIndex.push_back(inEvent.jdevice.which);