diff options
Diffstat (limited to 'src/input_common/drivers')
| -rw-r--r-- | src/input_common/drivers/sdl_driver.cpp | 15 | ||||
| -rw-r--r-- | src/input_common/drivers/sdl_driver.h | 3 |
2 files changed, 8 insertions, 10 deletions
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp index 45ce588f0..8de86b61e 100644 --- a/src/input_common/drivers/sdl_driver.cpp +++ b/src/input_common/drivers/sdl_driver.cpp | |||
| @@ -361,6 +361,12 @@ void SDLDriver::CloseJoystick(SDL_Joystick* sdl_joystick) { | |||
| 361 | } | 361 | } |
| 362 | } | 362 | } |
| 363 | 363 | ||
| 364 | void SDLDriver::PumpEvents() const { | ||
| 365 | if (initialized) { | ||
| 366 | SDL_PumpEvents(); | ||
| 367 | } | ||
| 368 | } | ||
| 369 | |||
| 364 | void SDLDriver::HandleGameControllerEvent(const SDL_Event& event) { | 370 | void SDLDriver::HandleGameControllerEvent(const SDL_Event& event) { |
| 365 | switch (event.type) { | 371 | switch (event.type) { |
| 366 | case SDL_JOYBUTTONUP: { | 372 | case SDL_JOYBUTTONUP: { |
| @@ -451,14 +457,6 @@ SDLDriver::SDLDriver(std::string input_engine_) : InputEngine(std::move(input_en | |||
| 451 | 457 | ||
| 452 | initialized = true; | 458 | initialized = true; |
| 453 | if (start_thread) { | 459 | if (start_thread) { |
| 454 | poll_thread = std::thread([this] { | ||
| 455 | Common::SetCurrentThreadName("SDL_MainLoop"); | ||
| 456 | using namespace std::chrono_literals; | ||
| 457 | while (initialized) { | ||
| 458 | SDL_PumpEvents(); | ||
| 459 | std::this_thread::sleep_for(1ms); | ||
| 460 | } | ||
| 461 | }); | ||
| 462 | vibration_thread = std::thread([this] { | 460 | vibration_thread = std::thread([this] { |
| 463 | Common::SetCurrentThreadName("SDL_Vibration"); | 461 | Common::SetCurrentThreadName("SDL_Vibration"); |
| 464 | using namespace std::chrono_literals; | 462 | using namespace std::chrono_literals; |
| @@ -481,7 +479,6 @@ SDLDriver::~SDLDriver() { | |||
| 481 | 479 | ||
| 482 | initialized = false; | 480 | initialized = false; |
| 483 | if (start_thread) { | 481 | if (start_thread) { |
| 484 | poll_thread.join(); | ||
| 485 | vibration_thread.join(); | 482 | vibration_thread.join(); |
| 486 | SDL_QuitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER); | 483 | SDL_QuitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER); |
| 487 | } | 484 | } |
diff --git a/src/input_common/drivers/sdl_driver.h b/src/input_common/drivers/sdl_driver.h index d1b4471cf..366bcc496 100644 --- a/src/input_common/drivers/sdl_driver.h +++ b/src/input_common/drivers/sdl_driver.h | |||
| @@ -36,6 +36,8 @@ public: | |||
| 36 | /// Unregisters SDL device factories and shut them down. | 36 | /// Unregisters SDL device factories and shut them down. |
| 37 | ~SDLDriver() override; | 37 | ~SDLDriver() override; |
| 38 | 38 | ||
| 39 | void PumpEvents() const; | ||
| 40 | |||
| 39 | /// Handle SDL_Events for joysticks from SDL_PollEvent | 41 | /// Handle SDL_Events for joysticks from SDL_PollEvent |
| 40 | void HandleGameControllerEvent(const SDL_Event& event); | 42 | void HandleGameControllerEvent(const SDL_Event& event); |
| 41 | 43 | ||
| @@ -128,7 +130,6 @@ private: | |||
| 128 | bool start_thread = false; | 130 | bool start_thread = false; |
| 129 | std::atomic<bool> initialized = false; | 131 | std::atomic<bool> initialized = false; |
| 130 | 132 | ||
| 131 | std::thread poll_thread; | ||
| 132 | std::thread vibration_thread; | 133 | std::thread vibration_thread; |
| 133 | }; | 134 | }; |
| 134 | } // namespace InputCommon | 135 | } // namespace InputCommon |