summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/Src/ControllerInterface
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/InputCommon/Src/ControllerInterface')
-rw-r--r--Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.mm11
-rw-r--r--Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp13
-rw-r--r--Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.h12
3 files changed, 23 insertions, 13 deletions
diff --git a/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.mm b/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.mm
index 60c0cc8c50..0d89c2e393 100644
--- a/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.mm
+++ b/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.mm
@@ -121,7 +121,9 @@ Joystick::Axis::Axis(IOHIDElementRef element, IOHIDDeviceRef device, direction d
// Need to parse the element a bit first
std::string description("unk");
- switch (IOHIDElementGetUsage(m_element)) {
+ int const usage = IOHIDElementGetUsage(m_element);
+ switch (usage)
+ {
case kHIDUsage_GD_X:
description = "X";
break;
@@ -146,6 +148,13 @@ Joystick::Axis::Axis(IOHIDElementRef element, IOHIDDeviceRef device, direction d
case kHIDUsage_Csmr_ACPan:
description = "Pan";
break;
+ default:
+ {
+ std::ostringstream s;
+ s << usage;
+ description = s.str();
+ break;
+ }
}
m_name = std::string("Axis ") + description;
diff --git a/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp b/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp
index 5473f7bcb3..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,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
diff --git a/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.h b/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.h
index 139e9f232d..fa770c403d 100644
--- a/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.h
+++ b/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.h
@@ -5,22 +5,14 @@
#include <list>
-#ifdef _WIN32
- #include <SDL.h>
-#else
- #include <SDL/SDL.h>
-#endif
+#include <SDL.h>
#if SDL_VERSION_ATLEAST(1, 3, 0)
#define USE_SDL_HAPTIC
#endif
#ifdef USE_SDL_HAPTIC
- #ifdef _WIN32
- #include <SDL_haptic.h>
- #else
- #include <SDL/SDL_haptic.h>
- #endif
+ #include <SDL_haptic.h>
#define SDL_INIT_FLAGS SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC
#else
#define SDL_INIT_FLAGS SDL_INIT_JOYSTICK