From 874826b6ddef20f190013f24021d20e0338d5593 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 18 Mar 2019 11:26:13 -0400 Subject: input_common/sdl: Use a type alias to shorten declaration of GetPollers Just makes the definitions a little bit more tidy. --- src/input_common/sdl/sdl.h | 10 +++++----- src/input_common/sdl/sdl_impl.cpp | 5 ++--- src/input_common/sdl/sdl_impl.h | 5 ++--- 3 files changed, 9 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/input_common/sdl/sdl.h b/src/input_common/sdl/sdl.h index 02a8d2e2c..940ca7f1b 100644 --- a/src/input_common/sdl/sdl.h +++ b/src/input_common/sdl/sdl.h @@ -24,17 +24,17 @@ namespace InputCommon::SDL { class State { public: - /// Unresisters SDL device factories and shut them down. + using Pollers = std::vector>; + + /// Unregisters SDL device factories and shut them down. virtual ~State() = default; - virtual std::vector> GetPollers( - InputCommon::Polling::DeviceType type) = 0; + virtual Pollers GetPollers(Polling::DeviceType type) = 0; }; class NullState : public State { public: - std::vector> GetPollers( - InputCommon::Polling::DeviceType type) override {} + Pollers GetPollers(Polling::DeviceType type) override {} }; std::unique_ptr Init(); diff --git a/src/input_common/sdl/sdl_impl.cpp b/src/input_common/sdl/sdl_impl.cpp index 6e8376549..f44a4a332 100644 --- a/src/input_common/sdl/sdl_impl.cpp +++ b/src/input_common/sdl/sdl_impl.cpp @@ -650,9 +650,8 @@ private: }; } // namespace Polling -std::vector> SDLState::GetPollers( - InputCommon::Polling::DeviceType type) { - std::vector> pollers; +SDLState::Pollers SDLState::GetPollers(InputCommon::Polling::DeviceType type) { + Pollers pollers; switch (type) { case InputCommon::Polling::DeviceType::Analog: pollers.emplace_back(std::make_unique(*this)); diff --git a/src/input_common/sdl/sdl_impl.h b/src/input_common/sdl/sdl_impl.h index fec82fbe6..2579741d6 100644 --- a/src/input_common/sdl/sdl_impl.h +++ b/src/input_common/sdl/sdl_impl.h @@ -25,7 +25,7 @@ public: /// Initializes and registers SDL device factories SDLState(); - /// Unresisters SDL device factories and shut them down. + /// Unregisters SDL device factories and shut them down. ~SDLState() override; /// Handle SDL_Events for joysticks from SDL_PollEvent @@ -35,8 +35,7 @@ public: std::shared_ptr GetSDLJoystickByGUID(const std::string& guid, int port); /// Get all DevicePoller that use the SDL backend for a specific device type - std::vector> GetPollers( - InputCommon::Polling::DeviceType type) override; + Pollers GetPollers(Polling::DeviceType type) override; /// Used by the Pollers during config std::atomic polling = false; -- cgit v1.2.3 From eb335f51ca15774330219a9c65778db39cdebac1 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 18 Mar 2019 11:32:49 -0400 Subject: input_common/sdl: Correct return values within implementations of GetPollers() In both cases, we weren't actually returning anything, which is undefined behavior. --- src/input_common/sdl/sdl.h | 4 +++- src/input_common/sdl/sdl_impl.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/input_common/sdl/sdl.h b/src/input_common/sdl/sdl.h index 940ca7f1b..d7f24c68a 100644 --- a/src/input_common/sdl/sdl.h +++ b/src/input_common/sdl/sdl.h @@ -34,7 +34,9 @@ public: class NullState : public State { public: - Pollers GetPollers(Polling::DeviceType type) override {} + Pollers GetPollers(Polling::DeviceType type) override { + return {}; + } }; std::unique_ptr Init(); diff --git a/src/input_common/sdl/sdl_impl.cpp b/src/input_common/sdl/sdl_impl.cpp index f44a4a332..b132d77f5 100644 --- a/src/input_common/sdl/sdl_impl.cpp +++ b/src/input_common/sdl/sdl_impl.cpp @@ -652,6 +652,7 @@ private: SDLState::Pollers SDLState::GetPollers(InputCommon::Polling::DeviceType type) { Pollers pollers; + switch (type) { case InputCommon::Polling::DeviceType::Analog: pollers.emplace_back(std::make_unique(*this)); @@ -659,8 +660,9 @@ SDLState::Pollers SDLState::GetPollers(InputCommon::Polling::DeviceType type) { case InputCommon::Polling::DeviceType::Button: pollers.emplace_back(std::make_unique(*this)); break; - return pollers; } + + return pollers; } } // namespace SDL -- cgit v1.2.3