summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2013-02-07 19:42:01 -0600
committerJordan Woyak <jordan.woyak@gmail.com>2013-02-07 20:22:06 -0600
commitc4df69a342bd37420b61ebe6df6a0c6af915c877 (patch)
treed00451f654656768c1b24c94f2a99e5eb206a096 /Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp
parenta2ca76ebd9c3300735c438b5ddc7bc726001b41a (diff)
parent95d08db46fd54b37cb375980f97e1c0e11676419 (diff)
Merge branch 'master' into real-wiimote-scanning
Conflicts: Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp
Diffstat (limited to 'Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp')
-rw-r--r--Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp b/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp
index c7c6898ecd..c5ee3af23f 100644
--- a/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp
+++ b/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp
@@ -17,6 +17,15 @@ namespace ciface
{
namespace SDL
{
+
+std::string GetJoystickName(int index)
+{
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+ return SDL_JoystickNameForIndex(index);
+#else
+ return SDL_JoystickName(index);
+#endif
+}
void Init( std::vector<ControllerInterface::Device*>& devices )
{
@@ -32,7 +41,7 @@ void Init( std::vector<ControllerInterface::Device*>& devices )
SDL_Joystick* dev = SDL_JoystickOpen(i);
if (dev)
{
- Joystick* js = new Joystick(dev, i, name_counts[SDL_JoystickName(i)]++);
+ 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 );
@@ -86,8 +95,8 @@ Joystick::Joystick(SDL_Joystick* const joystick, const int sdl_index, const unsi
for (u8 i = 0; i != SDL_JoystickNumAxes(m_joystick); ++i)
{
// each axis gets a negative and a positive input instance associated with it
- AddInput(new Axis(i, m_joystick, -32768));
- AddInput(new Axis(i, m_joystick, 32767));
+ AddAnalogInputs(new Axis(i, m_joystick, -32768),
+ new Axis(i, m_joystick, 32767));
}
#ifdef USE_SDL_HAPTIC
@@ -325,7 +334,7 @@ bool Joystick::UpdateOutput()
std::string Joystick::GetName() const
{
- return StripSpaces(SDL_JoystickName(m_sdl_index));
+ return StripSpaces(GetJoystickName(m_sdl_index));
}
std::string Joystick::GetSource() const