diff options
author | liamwhite <liamwhite@users.noreply.github.com> | 2022-11-30 00:45:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-30 00:45:25 +0100 |
commit | cafca891ea7c02a3e298675b070aef86773220b7 (patch) | |
tree | 8a7180b59abdea9ea1ade1b2fdc6b03ae8fcd012 /src/input_common/drivers | |
parent | Merge pull request #9352 from lioncash/vidcast (diff) | |
parent | input_common: Pump sdl events from main thread (diff) | |
download | yuzu-cafca891ea7c02a3e298675b070aef86773220b7.tar yuzu-cafca891ea7c02a3e298675b070aef86773220b7.tar.gz yuzu-cafca891ea7c02a3e298675b070aef86773220b7.tar.bz2 yuzu-cafca891ea7c02a3e298675b070aef86773220b7.tar.lz yuzu-cafca891ea7c02a3e298675b070aef86773220b7.tar.xz yuzu-cafca891ea7c02a3e298675b070aef86773220b7.tar.zst yuzu-cafca891ea7c02a3e298675b070aef86773220b7.zip |
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) { } } +void SDLDriver::PumpEvents() const { + if (initialized) { + SDL_PumpEvents(); + } +} + void SDLDriver::HandleGameControllerEvent(const SDL_Event& event) { switch (event.type) { case SDL_JOYBUTTONUP: { @@ -451,14 +457,6 @@ SDLDriver::SDLDriver(std::string input_engine_) : InputEngine(std::move(input_en initialized = true; if (start_thread) { - poll_thread = std::thread([this] { - Common::SetCurrentThreadName("SDL_MainLoop"); - using namespace std::chrono_literals; - while (initialized) { - SDL_PumpEvents(); - std::this_thread::sleep_for(1ms); - } - }); vibration_thread = std::thread([this] { Common::SetCurrentThreadName("SDL_Vibration"); using namespace std::chrono_literals; @@ -481,7 +479,6 @@ SDLDriver::~SDLDriver() { initialized = false; if (start_thread) { - poll_thread.join(); vibration_thread.join(); SDL_QuitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER); } 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: /// Unregisters SDL device factories and shut them down. ~SDLDriver() override; + void PumpEvents() const; + /// Handle SDL_Events for joysticks from SDL_PollEvent void HandleGameControllerEvent(const SDL_Event& event); @@ -128,7 +130,6 @@ private: bool start_thread = false; std::atomic<bool> initialized = false; - std::thread poll_thread; std::thread vibration_thread; }; } // namespace InputCommon |