summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp')
-rw-r--r--Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp b/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp
index b521032e9c..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 );
@@ -325,13 +334,7 @@ bool Joystick::UpdateOutput()
std::string Joystick::GetName() const
{
- return StripSpaces(
-#if SDL_VERSION_ATLEAST(2, 0, 0)
- SDL_JoystickNameForIndex(m_sdl_index)
-#else
- SDL_JoystickName(m_sdl_index)
-#endif
- );
+ return StripSpaces(GetJoystickName(m_sdl_index));
}
std::string Joystick::GetSource() const