summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface
diff options
context:
space:
mode:
authorMichael M <mchtly@gmail.com>2017-11-09 14:04:31 -0800
committerLéo Lam <leo@innovatetechnologi.es>2018-06-04 17:49:21 +0200
commit7062967b5b50cf57bc7f3d11741ff0dd893c4ee0 (patch)
treecfe25d7139b9543972885d90d4089dc387c107ab /Source/Core/InputCommon/ControllerInterface
parent0eb47e1071b2e2e5fb18beddc5c4f16ddbfee609 (diff)
SDLJoystick: store name on creation
Otherwise, Dolphin will crash when the joystick is removed.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp4
-rw-r--r--Source/Core/InputCommon/ControllerInterface/SDL/SDL.h2
2 files changed, 3 insertions, 3 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp b/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp
index 7da8e66fc6..e17c307d1d 100644
--- a/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp
@@ -69,7 +69,7 @@ void PopulateDevices()
}
Joystick::Joystick(SDL_Joystick* const joystick, const int sdl_index)
- : m_joystick(joystick), m_sdl_index(sdl_index)
+ : m_joystick(joystick), m_name(StripSpaces(GetJoystickName(sdl_index)))
{
// really bad HACKS:
// to not use SDL for an XInput device
@@ -284,7 +284,7 @@ void Joystick::UpdateInput()
std::string Joystick::GetName() const
{
- return StripSpaces(GetJoystickName(m_sdl_index));
+ return m_name;
}
std::string Joystick::GetSource() const
diff --git a/Source/Core/InputCommon/ControllerInterface/SDL/SDL.h b/Source/Core/InputCommon/ControllerInterface/SDL/SDL.h
index c41bb57614..1dd0fb685c 100644
--- a/Source/Core/InputCommon/ControllerInterface/SDL/SDL.h
+++ b/Source/Core/InputCommon/ControllerInterface/SDL/SDL.h
@@ -151,7 +151,7 @@ public:
private:
SDL_Joystick* const m_joystick;
- const int m_sdl_index;
+ std::string m_name;
#ifdef USE_SDL_HAPTIC
SDL_Haptic* m_haptic;