diff options
| author | 2022-11-29 18:45:25 -0500 | |
|---|---|---|
| committer | 2022-11-29 18:45:25 -0500 | |
| commit | cafca891ea7c02a3e298675b070aef86773220b7 (patch) | |
| tree | 8a7180b59abdea9ea1ade1b2fdc6b03ae8fcd012 /src/input_common/drivers/sdl_driver.cpp | |
| parent | Merge pull request #9352 from lioncash/vidcast (diff) | |
| parent | input_common: Pump sdl events from main thread (diff) | |
| download | yuzu-cafca891ea7c02a3e298675b070aef86773220b7.tar.gz yuzu-cafca891ea7c02a3e298675b070aef86773220b7.tar.xz yuzu-cafca891ea7c02a3e298675b070aef86773220b7.zip | |
Merge pull request #9322 from german77/pump_events
input_common: Pump SDL events from main thread
Diffstat (limited to 'src/input_common/drivers/sdl_driver.cpp')
| -rw-r--r-- | src/input_common/drivers/sdl_driver.cpp | 15 |
1 files changed, 6 insertions, 9 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 | } |