diff options
| author | 2022-05-28 00:55:53 -0700 | |
|---|---|---|
| committer | 2022-05-28 00:55:53 -0700 | |
| commit | d879741ec6e6396331965dc2683d3de0d8b3880f (patch) | |
| tree | 049fb06784cc394ca40e3981d6286b23eb8f386b /src/core/hid/emulated_controller.cpp | |
| parent | Merge pull request #8372 from german77/touch (diff) | |
| parent | input_common: Make vibration request async (diff) | |
| download | yuzu-d879741ec6e6396331965dc2683d3de0d8b3880f.tar.gz yuzu-d879741ec6e6396331965dc2683d3de0d8b3880f.tar.xz yuzu-d879741ec6e6396331965dc2683d3de0d8b3880f.zip | |
Merge pull request #8374 from german77/asnycvibrations
input_common: Make vibration request async
Diffstat (limited to 'src/core/hid/emulated_controller.cpp')
| -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 | |||
| 884 | } | 884 | } |
| 885 | 885 | ||
| 886 | bool EmulatedController::TestVibration(std::size_t device_index) { | 886 | bool EmulatedController::TestVibration(std::size_t device_index) { |
| 887 | static constexpr VibrationValue test_vibration = { | 887 | if (device_index >= output_devices.size()) { |
| 888 | return false; | ||
| 889 | } | ||
| 890 | if (!output_devices[device_index]) { | ||
| 891 | return false; | ||
| 892 | } | ||
| 893 | |||
| 894 | const auto player_index = NpadIdTypeToIndex(npad_id_type); | ||
| 895 | const auto& player = Settings::values.players.GetValue()[player_index]; | ||
| 896 | |||
| 897 | if (!player.vibration_enabled) { | ||
| 898 | return false; | ||
| 899 | } | ||
| 900 | |||
| 901 | const Common::Input::VibrationStatus test_vibration = { | ||
| 888 | .low_amplitude = 0.001f, | 902 | .low_amplitude = 0.001f, |
| 889 | .low_frequency = 160.0f, | 903 | .low_frequency = DEFAULT_VIBRATION_VALUE.low_frequency, |
| 890 | .high_amplitude = 0.001f, | 904 | .high_amplitude = 0.001f, |
| 891 | .high_frequency = 320.0f, | 905 | .high_frequency = DEFAULT_VIBRATION_VALUE.high_frequency, |
| 906 | .type = Common::Input::VibrationAmplificationType::Test, | ||
| 907 | }; | ||
| 908 | |||
| 909 | const Common::Input::VibrationStatus zero_vibration = { | ||
| 910 | .low_amplitude = DEFAULT_VIBRATION_VALUE.low_amplitude, | ||
| 911 | .low_frequency = DEFAULT_VIBRATION_VALUE.low_frequency, | ||
| 912 | .high_amplitude = DEFAULT_VIBRATION_VALUE.high_amplitude, | ||
| 913 | .high_frequency = DEFAULT_VIBRATION_VALUE.high_frequency, | ||
| 914 | .type = Common::Input::VibrationAmplificationType::Test, | ||
| 892 | }; | 915 | }; |
| 893 | 916 | ||
| 894 | // Send a slight vibration to test for rumble support | 917 | // Send a slight vibration to test for rumble support |
| 895 | SetVibration(device_index, test_vibration); | 918 | output_devices[device_index]->SetVibration(test_vibration); |
| 896 | 919 | ||
| 897 | // Stop any vibration and return the result | 920 | // Stop any vibration and return the result |
| 898 | return SetVibration(device_index, DEFAULT_VIBRATION_VALUE); | 921 | return output_devices[device_index]->SetVibration(zero_vibration) == |
| 922 | Common::Input::VibrationError::None; | ||
| 899 | } | 923 | } |
| 900 | 924 | ||
| 901 | bool EmulatedController::SetPollingMode(Common::Input::PollingMode polling_mode) { | 925 | bool EmulatedController::SetPollingMode(Common::Input::PollingMode polling_mode) { |