summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorNarr the Reg <juangerman-13@hotmail.com>2022-05-23 18:33:34 +0200
committerNarr the Reg <juangerman-13@hotmail.com>2022-05-23 19:25:02 +0200
commitbf948b57903a55b562287347129ec718154b5f82 (patch)
tree452677f5ec79e8dcef0a9c6f12c8fb928b5bfa0c /src/core
parentMerge pull request #8342 from lat9nq/clang-latest-stdc++ (diff)
downloadyuzu-bf948b57903a55b562287347129ec718154b5f82.tar
yuzu-bf948b57903a55b562287347129ec718154b5f82.tar.gz
yuzu-bf948b57903a55b562287347129ec718154b5f82.tar.bz2
yuzu-bf948b57903a55b562287347129ec718154b5f82.tar.lz
yuzu-bf948b57903a55b562287347129ec718154b5f82.tar.xz
yuzu-bf948b57903a55b562287347129ec718154b5f82.tar.zst
yuzu-bf948b57903a55b562287347129ec718154b5f82.zip
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hid/emulated_controller.cpp34
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) {