summaryrefslogtreecommitdiff
path: root/src/input_common/sdl
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common/sdl')
-rw-r--r--src/input_common/sdl/sdl.h12
-rw-r--r--src/input_common/sdl/sdl_impl.cpp14
-rw-r--r--src/input_common/sdl/sdl_impl.h5
3 files changed, 16 insertions, 15 deletions
diff --git a/src/input_common/sdl/sdl.h b/src/input_common/sdl/sdl.h
index 02a8d2e2c..d7f24c68a 100644
--- a/src/input_common/sdl/sdl.h
+++ b/src/input_common/sdl/sdl.h
@@ -24,17 +24,19 @@ namespace InputCommon::SDL {
24 24
25class State { 25class State {
26public: 26public:
27 /// Unresisters SDL device factories and shut them down. 27 using Pollers = std::vector<std::unique_ptr<Polling::DevicePoller>>;
28
29 /// Unregisters SDL device factories and shut them down.
28 virtual ~State() = default; 30 virtual ~State() = default;
29 31
30 virtual std::vector<std::unique_ptr<InputCommon::Polling::DevicePoller>> GetPollers( 32 virtual Pollers GetPollers(Polling::DeviceType type) = 0;
31 InputCommon::Polling::DeviceType type) = 0;
32}; 33};
33 34
34class NullState : public State { 35class NullState : public State {
35public: 36public:
36 std::vector<std::unique_ptr<InputCommon::Polling::DevicePoller>> GetPollers( 37 Pollers GetPollers(Polling::DeviceType type) override {
37 InputCommon::Polling::DeviceType type) override {} 38 return {};
39 }
38}; 40};
39 41
40std::unique_ptr<State> Init(); 42std::unique_ptr<State> Init();
diff --git a/src/input_common/sdl/sdl_impl.cpp b/src/input_common/sdl/sdl_impl.cpp
index 934339d3b..b132d77f5 100644
--- a/src/input_common/sdl/sdl_impl.cpp
+++ b/src/input_common/sdl/sdl_impl.cpp
@@ -475,12 +475,11 @@ SDLState::SDLState() {
475 475
476 initialized = true; 476 initialized = true;
477 if (start_thread) { 477 if (start_thread) {
478 poll_thread = std::thread([&] { 478 poll_thread = std::thread([this] {
479 using namespace std::chrono_literals; 479 using namespace std::chrono_literals;
480 SDL_Event event;
481 while (initialized) { 480 while (initialized) {
482 SDL_PumpEvents(); 481 SDL_PumpEvents();
483 std::this_thread::sleep_for(std::chrono::duration(10ms)); 482 std::this_thread::sleep_for(10ms);
484 } 483 }
485 }); 484 });
486 } 485 }
@@ -651,9 +650,9 @@ private:
651}; 650};
652} // namespace Polling 651} // namespace Polling
653 652
654std::vector<std::unique_ptr<InputCommon::Polling::DevicePoller>> SDLState::GetPollers( 653SDLState::Pollers SDLState::GetPollers(InputCommon::Polling::DeviceType type) {
655 InputCommon::Polling::DeviceType type) { 654 Pollers pollers;
656 std::vector<std::unique_ptr<InputCommon::Polling::DevicePoller>> pollers; 655
657 switch (type) { 656 switch (type) {
658 case InputCommon::Polling::DeviceType::Analog: 657 case InputCommon::Polling::DeviceType::Analog:
659 pollers.emplace_back(std::make_unique<Polling::SDLAnalogPoller>(*this)); 658 pollers.emplace_back(std::make_unique<Polling::SDLAnalogPoller>(*this));
@@ -661,8 +660,9 @@ std::vector<std::unique_ptr<InputCommon::Polling::DevicePoller>> SDLState::GetPo
661 case InputCommon::Polling::DeviceType::Button: 660 case InputCommon::Polling::DeviceType::Button:
662 pollers.emplace_back(std::make_unique<Polling::SDLButtonPoller>(*this)); 661 pollers.emplace_back(std::make_unique<Polling::SDLButtonPoller>(*this));
663 break; 662 break;
664 return pollers;
665 } 663 }
664
665 return pollers;
666} 666}
667 667
668} // namespace SDL 668} // namespace SDL
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:
25 /// Initializes and registers SDL device factories 25 /// Initializes and registers SDL device factories
26 SDLState(); 26 SDLState();
27 27
28 /// Unresisters SDL device factories and shut them down. 28 /// Unregisters SDL device factories and shut them down.
29 ~SDLState() override; 29 ~SDLState() override;
30 30
31 /// Handle SDL_Events for joysticks from SDL_PollEvent 31 /// Handle SDL_Events for joysticks from SDL_PollEvent
@@ -35,8 +35,7 @@ public:
35 std::shared_ptr<SDLJoystick> GetSDLJoystickByGUID(const std::string& guid, int port); 35 std::shared_ptr<SDLJoystick> GetSDLJoystickByGUID(const std::string& guid, int port);
36 36
37 /// Get all DevicePoller that use the SDL backend for a specific device type 37 /// Get all DevicePoller that use the SDL backend for a specific device type
38 std::vector<std::unique_ptr<InputCommon::Polling::DevicePoller>> GetPollers( 38 Pollers GetPollers(Polling::DeviceType type) override;
39 InputCommon::Polling::DeviceType type) override;
40 39
41 /// Used by the Pollers during config 40 /// Used by the Pollers during config
42 std::atomic<bool> polling = false; 41 std::atomic<bool> polling = false;