diff options
| author | Ryan Houdek <Sonicadvance1@gmail.com> | 2015-01-21 13:29:39 -0600 |
|---|---|---|
| committer | Ryan Houdek <Sonicadvance1@gmail.com> | 2015-01-21 13:29:39 -0600 |
| commit | ca10ce36cced027758e37f5f98031317d2b3f2f0 (patch) | |
| tree | 4f13cebacf7e00fad88e9d8291248efbbb008640 /Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp | |
| parent | 7fba4856ce9acdfff962ea12f05f7312d70db052 (diff) | |
| parent | 817abdd579b2918d55141ac8efc9f8c4ef720634 (diff) | |
Merge pull request #1923 from Sonicadvance1/remove_sdl_assumption
Remove an assumption in SDL.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp b/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp index a1fd428a0d..2525e273b8 100644 --- a/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp +++ b/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp @@ -38,21 +38,31 @@ void Init( std::vector<Core::Device*>& devices ) // multiple joysticks with the same name shall get unique ids starting at 0 std::map<std::string, int> name_counts; - if (SDL_Init( SDL_INIT_FLAGS ) >= 0) +#ifdef USE_SDL_HAPTIC + if (SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC) >= 0) + { + // Correctly initialized + } + else +#endif + if (SDL_Init(SDL_INIT_JOYSTICK) < 0) + { + // Failed to initialize + return; + } + + // joysticks + for (int i = 0; i < SDL_NumJoysticks(); ++i) { - // joysticks - for (int i = 0; i < SDL_NumJoysticks(); ++i) + SDL_Joystick* dev = SDL_JoystickOpen(i); + if (dev) { - SDL_Joystick* dev = SDL_JoystickOpen(i); - if (dev) - { - Joystick* js = new Joystick(dev, i, name_counts[GetJoystickName(i)]++); - // only add if it has some inputs/outputs - if (js->Inputs().size() || js->Outputs().size()) - devices.push_back( js ); - else - delete js; - } + Joystick* js = new Joystick(dev, i, name_counts[GetJoystickName(i)]++); + // only add if it has some inputs/outputs + if (js->Inputs().size() || js->Outputs().size()) + devices.push_back( js ); + else + delete js; } } } |
