summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-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 b2064ef95..cd42344aa 100644
--- a/src/input_common/main.cpp
+++ b/src/input_common/main.cpp
@@ -324,6 +324,12 @@ struct InputSubsystem::Impl {
324#endif 324#endif
325 } 325 }
326 326
327 void PumpEvents() const {
328#ifdef HAVE_SDL2
329 sdl->PumpEvents();
330#endif
331 }
332
327 void RegisterInput(const MappingData& data) { 333 void RegisterInput(const MappingData& data) {
328 mapping_factory->RegisterInput(data); 334 mapping_factory->RegisterInput(data);
329 } 335 }
@@ -472,6 +478,10 @@ void InputSubsystem::StopMapping() const {
472 impl->mapping_factory->StopMapping(); 478 impl->mapping_factory->StopMapping();
473} 479}
474 480
481void InputSubsystem::PumpEvents() const {
482 impl->PumpEvents();
483}
484
475std::string GenerateKeyboardParam(int key_code) { 485std::string GenerateKeyboardParam(int key_code) {
476 Common::ParamPackage param; 486 Common::ParamPackage param;
477 param.Set("engine", "keyboard"); 487 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 4081af391..7c225cccc 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
@@ -404,6 +405,10 @@ GMainWindow::GMainWindow(std::unique_ptr<Config> config_, bool has_broken_vulkan
404 mouse_center_timer.setInterval(default_mouse_center_timeout); 405 mouse_center_timer.setInterval(default_mouse_center_timeout);
405 connect(&mouse_center_timer, &QTimer::timeout, this, &GMainWindow::CenterMouseCursor); 406 connect(&mouse_center_timer, &QTimer::timeout, this, &GMainWindow::CenterMouseCursor);
406 407
408 update_input_timer.setInterval(default_input_update_timeout);
409 connect(&update_input_timer, &QTimer::timeout, this, &GMainWindow::UpdateInputDrivers);
410 update_input_timer.start();
411
407 MigrateConfigFiles(); 412 MigrateConfigFiles();
408 413
409 if (has_broken_vulkan) { 414 if (has_broken_vulkan) {
@@ -3636,6 +3641,13 @@ void GMainWindow::UpdateUISettings() {
3636 UISettings::values.first_start = false; 3641 UISettings::values.first_start = false;
3637} 3642}
3638 3643
3644void GMainWindow::UpdateInputDrivers() {
3645 if (!input_subsystem) {
3646 return;
3647 }
3648 input_subsystem->PumpEvents();
3649}
3650
3639void GMainWindow::HideMouseCursor() { 3651void GMainWindow::HideMouseCursor() {
3640 if (emu_thread == nullptr && UISettings::values.hide_mouse) { 3652 if (emu_thread == nullptr && UISettings::values.hide_mouse) {
3641 mouse_hide_timer.stop(); 3653 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;