From f506783c37b2bd7b50bf86015a030d7e0a74ff29 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Tue, 5 Feb 2013 13:51:08 -0600 Subject: Number "unknown" axes in OSX rather than call them all "unk". --- .../InputCommon/Src/ControllerInterface/OSX/OSXJoystick.mm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'Source/Core/InputCommon/Src/ControllerInterface') 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; -- cgit v1.2.3 From 708fed92c851ada9dbe191b20eafa14c378ca664 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Tue, 5 Feb 2013 15:32:13 -0600 Subject: Clean up SDL includes a bit. Maybe fix an SDL2 problem. --- Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp | 8 +++++++- Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.h | 12 ++---------- 2 files changed, 9 insertions(+), 11 deletions(-) (limited to 'Source/Core/InputCommon/Src/ControllerInterface') diff --git a/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp b/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp index 5473f7bcb3..b521032e9c 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp +++ b/Source/Core/InputCommon/Src/ControllerInterface/SDL/SDL.cpp @@ -325,7 +325,13 @@ bool Joystick::UpdateOutput() std::string Joystick::GetName() const { - return StripSpaces(SDL_JoystickName(m_sdl_index)); + return StripSpaces( +#if SDL_VERSION_ATLEAST(2, 0, 0) + SDL_JoystickNameForIndex(m_sdl_index) +#else + SDL_JoystickName(m_sdl_index) +#endif + ); } 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 -#ifdef _WIN32 - #include -#else - #include -#endif +#include #if SDL_VERSION_ATLEAST(1, 3, 0) #define USE_SDL_HAPTIC #endif #ifdef USE_SDL_HAPTIC - #ifdef _WIN32 - #include - #else - #include - #endif + #include #define SDL_INIT_FLAGS SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC #else #define SDL_INIT_FLAGS SDL_INIT_JOYSTICK -- cgit v1.2.3 From ef9d7fb789ec88b249c33a9119fb40069e68619e Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Tue, 5 Feb 2013 21:07:09 -0600 Subject: Fix compilation with SDL2. (based on a patch from matthewharveys) Fixes issue 5971. --- .../InputCommon/Src/ControllerInterface/SDL/SDL.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'Source/Core/InputCommon/Src/ControllerInterface') 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& devices ) { @@ -32,7 +41,7 @@ void Init( std::vector& 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 -- cgit v1.2.3