diff options
author | bunnei <bunneidev@gmail.com> | 2022-05-28 09:55:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-28 09:55:53 +0200 |
commit | d879741ec6e6396331965dc2683d3de0d8b3880f (patch) | |
tree | 049fb06784cc394ca40e3981d6286b23eb8f386b /src/core | |
parent | Merge pull request #8372 from german77/touch (diff) | |
parent | input_common: Make vibration request async (diff) | |
download | yuzu-d879741ec6e6396331965dc2683d3de0d8b3880f.tar yuzu-d879741ec6e6396331965dc2683d3de0d8b3880f.tar.gz yuzu-d879741ec6e6396331965dc2683d3de0d8b3880f.tar.bz2 yuzu-d879741ec6e6396331965dc2683d3de0d8b3880f.tar.lz yuzu-d879741ec6e6396331965dc2683d3de0d8b3880f.tar.xz yuzu-d879741ec6e6396331965dc2683d3de0d8b3880f.tar.zst yuzu-d879741ec6e6396331965dc2683d3de0d8b3880f.zip |
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/hid/emulated_controller.cpp | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index ba1dcd171..bd2384515 100644 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp @@ -884,18 +884,42 @@ bool EmulatedController::SetVibration(std::size_t device_index, VibrationValue v } bool EmulatedController::TestVibration(std::size_t device_index) { - static constexpr VibrationValue test_vibration = { + if (device_index >= output_devices.size()) { + return false; + } + if (!output_devices[device_index]) { + return false; + } + + const auto player_index = NpadIdTypeToIndex(npad_id_type); + const auto& player = Settings::values.players.GetValue()[player_index]; + + if (!player.vibration_enabled) { + return false; + } + + const Common::Input::VibrationStatus test_vibration = { .low_amplitude = 0.001f, - .low_frequency = 160.0f, + .low_frequency = DEFAULT_VIBRATION_VALUE.low_frequency, .high_amplitude = 0.001f, - .high_frequency = 320.0f, + .high_frequency = DEFAULT_VIBRATION_VALUE.high_frequency, + .type = Common::Input::VibrationAmplificationType::Test, + }; + + const Common::Input::VibrationStatus zero_vibration = { + .low_amplitude = DEFAULT_VIBRATION_VALUE.low_amplitude, + .low_frequency = DEFAULT_VIBRATION_VALUE.low_frequency, + .high_amplitude = DEFAULT_VIBRATION_VALUE.high_amplitude, + .high_frequency = DEFAULT_VIBRATION_VALUE.high_frequency, + .type = Common::Input::VibrationAmplificationType::Test, }; // Send a slight vibration to test for rumble support - SetVibration(device_index, test_vibration); + output_devices[device_index]->SetVibration(test_vibration); // Stop any vibration and return the result - return SetVibration(device_index, DEFAULT_VIBRATION_VALUE); + return output_devices[device_index]->SetVibration(zero_vibration) == + Common::Input::VibrationError::None; } bool EmulatedController::SetPollingMode(Common::Input::PollingMode polling_mode) { |