summaryrefslogtreecommitdiff
path: root/src/input_common/drivers/sdl_driver.cpp
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2022-11-29 18:45:25 -0500
committerGitHub <noreply@github.com>2022-11-29 18:45:25 -0500
commitcafca891ea7c02a3e298675b070aef86773220b7 (patch)
tree8a7180b59abdea9ea1ade1b2fdc6b03ae8fcd012 /src/input_common/drivers/sdl_driver.cpp
parentc845d8a9e8b212308e729ffcd9ddf2e09884638e (diff)
parent7d8095d944f4d3234b67fded9dba0a0ff61f6056 (diff)
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.cpp15
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) {
}
}
+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);
}