diff options
| author | Jordan Woyak <jordan.woyak@gmail.com> | 2010-06-06 06:28:18 +0000 |
|---|---|---|
| committer | Jordan Woyak <jordan.woyak@gmail.com> | 2010-06-06 06:28:18 +0000 |
| commit | 0af55bd85bda4b978a3ae000258dfe6e72a63139 (patch) | |
| tree | 75b31edfac27c384b9540c072d7b5a46b8cc5dbb /Source/Core/InputCommon/Src/ControllerInterface | |
| parent | 08636392b6e33d5fb1fb5d5d2b9a56537fa2c2a9 (diff) | |
Improve the SDL/XInput hackery of my last commit. Fixes the device refresh button crash.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5628 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/InputCommon/Src/ControllerInterface')
| -rw-r--r-- | Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp b/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp index 308518be44..52562169b6 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp +++ b/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp @@ -18,11 +18,11 @@ namespace ciface namespace SDL { +// just a struct with an int that is set to ZERO by default struct ZeroedInt{ZeroedInt():value(0){}unsigned int value;}; + void Init( std::vector<ControllerInterface::Device*>& devices ) { - // just a struct with an int that is set to ZERO by default - // this is used to number the joysticks // multiple joysticks with the same name shall get unique ids starting at 0 std::map<std::string, ZeroedInt> name_counts; @@ -55,22 +55,23 @@ Joystick::Joystick(SDL_Joystick* const joystick, const int sdl_index, const unsi // to not use SDL for an XInput device // too many people on the forums pick the SDL device and ask: // "why don't my 360 gamepad triggers/rumble work correctly" - #ifdef _WIN32 - // checking the name is probably good (and hacky) enough - // but i'll double check with the num of buttons/axes - if ( - ("Controller (Xbox 360 Wireless Receiver for Windows)" == GetName()) - && (10 == SDL_JoystickNumButtons(joystick)) - && (5 == SDL_JoystickNumAxes(joystick)) - && (1 == SDL_JoystickNumHats(joystick)) - && (0 == SDL_JoystickNumBalls(joystick)) - ) - { - // this device won't be used - return; - } - - #endif +#ifdef _WIN32 + // checking the name is probably good (and hacky) enough + // but i'll double check with the num of buttons/axes + std::string lcasename = GetName(); + std::transform(lcasename.begin(), lcasename.end(), lcasename.begin(), tolower); + + if ((std::string::npos != lcasename.find("xbox 360")) + && (10 == SDL_JoystickNumButtons(joystick)) + && (5 == SDL_JoystickNumAxes(joystick)) + && (1 == SDL_JoystickNumHats(joystick)) + && (0 == SDL_JoystickNumBalls(joystick)) + ) + { + // this device won't be used + return; + } +#endif // get buttons for ( int i = 0; i < SDL_JoystickNumButtons( m_joystick ); ++i ) |
