From 16dcfcf5e51f56f4afc2410c808e494e4497ac09 Mon Sep 17 00:00:00 2001 From: "Lars A. Doucet" Date: Tue, 16 Jun 2015 09:31:09 -0500 Subject: [PATCH] Legacy: add a simple joystick model identification hack per Nils' suggestions --- legacy/project/src/sdl2/SDL2Stage.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/legacy/project/src/sdl2/SDL2Stage.cpp b/legacy/project/src/sdl2/SDL2Stage.cpp index 06fe9c19d..4a561bbff 100644 --- a/legacy/project/src/sdl2/SDL2Stage.cpp +++ b/legacy/project/src/sdl2/SDL2Stage.cpp @@ -1395,6 +1395,24 @@ void ProcessEvent(SDL_Event &inEvent) Event joystick(etJoyDeviceAdded); sgJoystick = SDL_JoystickOpen(inEvent.jdevice.which); //which: joystick device index 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); sgJoysticksId.push_back(joystick.id); sgJoysticksIndex.push_back(inEvent.jdevice.which);