From 5adaa122606c98d9388e518576a7e139b12a4699 Mon Sep 17 00:00:00 2001 From: Kelly Youngblood Date: Sat, 3 Sep 2016 21:14:44 -0500 Subject: [PATCH] Adds auto-detection for PS3 cocntroller. --- SDL/SDLJoystick.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/SDL/SDLJoystick.cpp b/SDL/SDLJoystick.cpp index be2c2212b8da..9fca4a7b61b8 100644 --- a/SDL/SDLJoystick.cpp +++ b/SDL/SDLJoystick.cpp @@ -17,16 +17,22 @@ SDLJoystick::SDLJoystick(bool init_SDL ): thread(NULL), running(true) { SDL_setenv("SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS", "1", 0); SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO); } - if (g_Config.bPS3Controller) - fillMappingPS3(); - else - fillMapping(); int numjoys = SDL_NumJoysticks(); SDL_JoystickEventState(SDL_ENABLE); for (int i = 0; i < numjoys; i++) { joys.push_back(SDL_JoystickOpen(i)); +// printf("Initialized joystick %d: %s",i,SDL_JoystickNameForIndex(i)); + if(strstr(SDL_JoystickNameForIndex(i),"PLAYSTATION(R)3 Controller")) + g_Config.bPS3Controller = true; } + + if (g_Config.bPS3Controller) + fillMappingPS3(); + else + fillMapping(); + + } SDLJoystick::~SDLJoystick(){