summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/hle/service/hid/controllers/npad.cpp4
-rw-r--r--src/input_common/drivers/sdl_driver.cpp10
-rw-r--r--src/input_common/drivers/sdl_driver.h1
3 files changed, 12 insertions, 3 deletions
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp
index c08b0a5dc..7afdbfb96 100644
--- a/src/core/hle/service/hid/controllers/npad.cpp
+++ b/src/core/hle/service/hid/controllers/npad.cpp
@@ -820,11 +820,11 @@ bool Controller_NPad::VibrateControllerAtIndex(Core::HID::NpadIdType npad_id,
820 820
821 const auto now = steady_clock::now(); 821 const auto now = steady_clock::now();
822 822
823 // Filter out non-zero vibrations that are within 10ms of each other. 823 // Filter out non-zero vibrations that are within 15ms of each other.
824 if ((vibration_value.low_amplitude != 0.0f || vibration_value.high_amplitude != 0.0f) && 824 if ((vibration_value.low_amplitude != 0.0f || vibration_value.high_amplitude != 0.0f) &&
825 duration_cast<milliseconds>( 825 duration_cast<milliseconds>(
826 now - controller.vibration[device_index].last_vibration_timepoint) < 826 now - controller.vibration[device_index].last_vibration_timepoint) <
827 milliseconds(10)) { 827 milliseconds(15)) {
828 return false; 828 return false;
829 } 829 }
830 830
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp
index 446c027d3..00474ac77 100644
--- a/src/input_common/drivers/sdl_driver.cpp
+++ b/src/input_common/drivers/sdl_driver.cpp
@@ -438,10 +438,17 @@ SDLDriver::SDLDriver(std::string input_engine_) : InputEngine(std::move(input_en
438 using namespace std::chrono_literals; 438 using namespace std::chrono_literals;
439 while (initialized) { 439 while (initialized) {
440 SDL_PumpEvents(); 440 SDL_PumpEvents();
441 SendVibrations();
442 std::this_thread::sleep_for(1ms); 441 std::this_thread::sleep_for(1ms);
443 } 442 }
444 }); 443 });
444 vibration_thread = std::thread([this] {
445 Common::SetCurrentThreadName("yuzu:input:SDL_Vibration");
446 using namespace std::chrono_literals;
447 while (initialized) {
448 SendVibrations();
449 std::this_thread::sleep_for(10ms);
450 }
451 });
445 } 452 }
446 // Because the events for joystick connection happens before we have our event watcher added, we 453 // Because the events for joystick connection happens before we have our event watcher added, we
447 // can just open all the joysticks right here 454 // can just open all the joysticks right here
@@ -457,6 +464,7 @@ SDLDriver::~SDLDriver() {
457 initialized = false; 464 initialized = false;
458 if (start_thread) { 465 if (start_thread) {
459 poll_thread.join(); 466 poll_thread.join();
467 vibration_thread.join();
460 SDL_QuitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER); 468 SDL_QuitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER);
461 } 469 }
462} 470}
diff --git a/src/input_common/drivers/sdl_driver.h b/src/input_common/drivers/sdl_driver.h
index 0846fbb50..7dc7a93c7 100644
--- a/src/input_common/drivers/sdl_driver.h
+++ b/src/input_common/drivers/sdl_driver.h
@@ -128,5 +128,6 @@ private:
128 std::atomic<bool> initialized = false; 128 std::atomic<bool> initialized = false;
129 129
130 std::thread poll_thread; 130 std::thread poll_thread;
131 std::thread vibration_thread;
131}; 132};
132} // namespace InputCommon 133} // namespace InputCommon