summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/input_common/drivers/sdl_driver.cpp15
-rw-r--r--src/input_common/drivers/sdl_driver.h3
-rw-r--r--src/input_common/main.cpp10
-rw-r--r--src/input_common/main.h3
-rw-r--r--src/yuzu/main.cpp12
-rw-r--r--src/yuzu/main.h2
6 files changed, 35 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
364void SDLDriver::PumpEvents() const {
365 if (initialized) {
366 SDL_PumpEvents();
367 }
368}
369
364void SDLDriver::HandleGameControllerEvent(const SDL_Event& event) { 370void 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
diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp
index baeed2e02..942a13535 100644
--- a/src/input_common/main.cpp
+++ b/src/input_common/main.cpp
@@ -318,6 +318,12 @@ struct InputSubsystem::Impl {
318#endif 318#endif
319 } 319 }
320 320
321 void PumpEvents() const {
322#ifdef HAVE_SDL2
323 sdl->PumpEvents();
324#endif
325 }
326
321 void RegisterInput(const MappingData& data) { 327 void RegisterInput(const MappingData& data) {
322 mapping_factory->RegisterInput(data); 328 mapping_factory->RegisterInput(data);
323 } 329 }
@@ -466,6 +472,10 @@ void InputSubsystem::StopMapping() const {
466 impl->mapping_factory->StopMapping(); 472 impl->mapping_factory->StopMapping();
467} 473}
468 474
475void InputSubsystem::PumpEvents() const {
476 impl->PumpEvents();
477}
478
469std::string GenerateKeyboardParam(int key_code) { 479std::string GenerateKeyboardParam(int key_code) {
470 Common::ParamPackage param; 480 Common::ParamPackage param;
471 param.Set("engine", "keyboard"); 481 param.Set("engine", "keyboard");
diff --git a/src/input_common/main.h b/src/input_common/main.h
index ced252383..6218c37f6 100644
--- a/src/input_common/main.h
+++ b/src/input_common/main.h
@@ -147,6 +147,9 @@ public:
147 /// Stop polling from all backends. 147 /// Stop polling from all backends.
148 void StopMapping() const; 148 void StopMapping() const;
149 149
150 /// Signals SDL driver for new input events
151 void PumpEvents() const;
152
150private: 153private:
151 struct Impl; 154 struct Impl;
152 std::unique_ptr<Impl> impl; 155 std::unique_ptr<Impl> impl;
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 346d14252..c21153560 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -167,6 +167,7 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
167 167
168constexpr int default_mouse_hide_timeout = 2500; 168constexpr int default_mouse_hide_timeout = 2500;
169constexpr int default_mouse_center_timeout = 10; 169constexpr int default_mouse_center_timeout = 10;
170constexpr int default_input_update_timeout = 1;
170 171
171/** 172/**
172 * "Callouts" are one-time instructional messages shown to the user. In the config settings, there 173 * "Callouts" are one-time instructional messages shown to the user. In the config settings, there
@@ -405,6 +406,10 @@ GMainWindow::GMainWindow(std::unique_ptr<Config> config_, bool has_broken_vulkan
405 mouse_center_timer.setInterval(default_mouse_center_timeout); 406 mouse_center_timer.setInterval(default_mouse_center_timeout);
406 connect(&mouse_center_timer, &QTimer::timeout, this, &GMainWindow::CenterMouseCursor); 407 connect(&mouse_center_timer, &QTimer::timeout, this, &GMainWindow::CenterMouseCursor);
407 408
409 update_input_timer.setInterval(default_input_update_timeout);
410 connect(&update_input_timer, &QTimer::timeout, this, &GMainWindow::UpdateInputDrivers);
411 update_input_timer.start();
412
408 MigrateConfigFiles(); 413 MigrateConfigFiles();
409 414
410 if (has_broken_vulkan) { 415 if (has_broken_vulkan) {
@@ -3637,6 +3642,13 @@ void GMainWindow::UpdateUISettings() {
3637 UISettings::values.first_start = false; 3642 UISettings::values.first_start = false;
3638} 3643}
3639 3644
3645void GMainWindow::UpdateInputDrivers() {
3646 if (!input_subsystem) {
3647 return;
3648 }
3649 input_subsystem->PumpEvents();
3650}
3651
3640void GMainWindow::HideMouseCursor() { 3652void GMainWindow::HideMouseCursor() {
3641 if (emu_thread == nullptr && UISettings::values.hide_mouse) { 3653 if (emu_thread == nullptr && UISettings::values.hide_mouse) {
3642 mouse_hide_timer.stop(); 3654 mouse_hide_timer.stop();
diff --git a/src/yuzu/main.h b/src/yuzu/main.h
index 6a9992d05..4f9c3b450 100644
--- a/src/yuzu/main.h
+++ b/src/yuzu/main.h
@@ -353,6 +353,7 @@ private:
353 void UpdateGPUAccuracyButton(); 353 void UpdateGPUAccuracyButton();
354 void UpdateStatusButtons(); 354 void UpdateStatusButtons();
355 void UpdateUISettings(); 355 void UpdateUISettings();
356 void UpdateInputDrivers();
356 void HideMouseCursor(); 357 void HideMouseCursor();
357 void ShowMouseCursor(); 358 void ShowMouseCursor();
358 void CenterMouseCursor(); 359 void CenterMouseCursor();
@@ -404,6 +405,7 @@ private:
404 bool auto_muted = false; 405 bool auto_muted = false;
405 QTimer mouse_hide_timer; 406 QTimer mouse_hide_timer;
406 QTimer mouse_center_timer; 407 QTimer mouse_center_timer;
408 QTimer update_input_timer;
407 409
408 QString startup_icon_theme; 410 QString startup_icon_theme;
409 bool os_dark_mode = false; 411 bool os_dark_mode = false;