diff options
| author | flacs <tilkax@gmail.com> | 2015-06-05 19:53:24 +0200 |
|---|---|---|
| committer | flacs <tilkax@gmail.com> | 2015-06-05 19:53:24 +0200 |
| commit | b9821916dcc0368a8ad2bf2b223db1af6d334129 (patch) | |
| tree | 7c9a783ad7a816f6cf42536844f338fe8797d9b0 /Source/Core/InputCommon/ControllerInterface | |
| parent | 175e0d19269955fa8cbd4638ec30a8047a3b8af7 (diff) | |
| parent | 9ec5a4544f207a31678e6c5c7636873e9d9e88a1 (diff) | |
Merge pull request #2530 from Tilka/sdl_quit
SDL: handle SDL_QUIT event
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface')
3 files changed, 20 insertions, 8 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp index 6b8b11fd3a..2c87e77f01 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -134,6 +134,11 @@ void ControllerInterface::Shutdown() // void ControllerInterface::UpdateInput() { +#ifdef CIFACE_USE_SDL + // SDL currently also handles SIGINT and SIGTERM, + // so make sure to update it even if there is no SDL device. + ciface::SDL::UpdateInput(); +#endif for (ciface::Core::Device* d : m_devices) d->UpdateInput(); } diff --git a/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp b/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp index 6cdfa470cd..6e60cf0f7a 100644 --- a/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp +++ b/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp @@ -7,6 +7,7 @@ #include <sstream> #include "Common/StringUtil.h" +#include "Core/Host.h" #include "InputCommon/ControllerInterface/SDL/SDL.h" #ifdef _WIN32 @@ -67,6 +68,19 @@ void Init( std::vector<Core::Device*>& devices ) } } +void UpdateInput() +{ + // Using SDL_INIT_JOYSTICK implies SDL_INIT_EVENT which installs a signal handler for SIGINT and SIGTERM. + // In the future, we will be able to prevent this from happening: + // SDL_SetHint(SDL_HINT_NO_SIGNAL_HANDLERS, "1"); + // but this was added after SDL 2.0.3 and is scheduled to be included in 2.0.4. + // Until then, handle SDL_QUIT events here and tell Dolphin to exit. + if (SDL_QuitRequested()) + Host_Message(WM_USER_QUIT); + + SDL_JoystickUpdate(); +} + Joystick::Joystick(SDL_Joystick* const joystick, const int sdl_index, const unsigned int index) : m_joystick(joystick) , m_sdl_index(sdl_index) @@ -283,12 +297,6 @@ void Joystick::LeftRightEffect::SetSDLHapticEffect(ControlState state) } #endif -void Joystick::UpdateInput() -{ - // each joystick is doin this, o well - SDL_JoystickUpdate(); -} - std::string Joystick::GetName() const { return StripSpaces(GetJoystickName(m_sdl_index)); diff --git a/Source/Core/InputCommon/ControllerInterface/SDL/SDL.h b/Source/Core/InputCommon/ControllerInterface/SDL/SDL.h index 751f40e9f4..65082847a2 100644 --- a/Source/Core/InputCommon/ControllerInterface/SDL/SDL.h +++ b/Source/Core/InputCommon/ControllerInterface/SDL/SDL.h @@ -25,6 +25,7 @@ namespace SDL { void Init( std::vector<Core::Device*>& devices ); +void UpdateInput(); class Joystick : public Core::Device { @@ -130,8 +131,6 @@ private: #endif public: - void UpdateInput() override; - Joystick(SDL_Joystick* const joystick, const int sdl_index, const unsigned int index); ~Joystick(); |
