summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/hid/controllers/npad.cpp
diff options
context:
space:
mode:
authorMorph <39850852+Morph1984@users.noreply.github.com>2020-10-27 18:33:25 +0100
committerMorph <39850852+Morph1984@users.noreply.github.com>2020-11-16 05:33:21 +0100
commit97b2220a822548eed83993fceebe0e611dbec84b (patch)
treee4e90772c0ca7cccf3dd95d9cb49a600d0fabfb8 /src/core/hle/service/hid/controllers/npad.cpp
parentsdl_impl: Revert to the "old" method of mapping sticks (diff)
downloadyuzu-97b2220a822548eed83993fceebe0e611dbec84b.tar
yuzu-97b2220a822548eed83993fceebe0e611dbec84b.tar.gz
yuzu-97b2220a822548eed83993fceebe0e611dbec84b.tar.bz2
yuzu-97b2220a822548eed83993fceebe0e611dbec84b.tar.lz
yuzu-97b2220a822548eed83993fceebe0e611dbec84b.tar.xz
yuzu-97b2220a822548eed83993fceebe0e611dbec84b.tar.zst
yuzu-97b2220a822548eed83993fceebe0e611dbec84b.zip
Diffstat (limited to '')
-rw-r--r--src/core/hle/service/hid/controllers/npad.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp
index cfafabbd8..30715267c 100644
--- a/src/core/hle/service/hid/controllers/npad.cpp
+++ b/src/core/hle/service/hid/controllers/npad.cpp
@@ -287,7 +287,7 @@ void Controller_NPad::OnLoadInputDevices() {
void Controller_NPad::OnRelease() {
for (std::size_t npad_idx = 0; npad_idx < vibrations.size(); ++npad_idx) {
for (std::size_t device_idx = 0; device_idx < vibrations[npad_idx].size(); ++device_idx) {
- VibrateControllerAtIndex(npad_idx, device_idx);
+ VibrateControllerAtIndex(npad_idx, device_idx, {});
}
}
}
@@ -720,11 +720,14 @@ bool Controller_NPad::VibrateControllerAtIndex(std::size_t npad_index, std::size
last_vibration_timepoints[npad_index][device_index] = now;
}
- return vibrations[npad_index][device_index]->SetRumblePlay(
- std::min(vibration_value.amp_low * player.vibration_strength / 100.0f, 1.0f),
- vibration_value.freq_low,
- std::min(vibration_value.amp_high * player.vibration_strength / 100.0f, 1.0f),
- vibration_value.freq_high);
+ auto& vibration = vibrations[npad_index][device_index];
+ const auto player_vibration_strength = static_cast<f32>(player.vibration_strength);
+ const auto amp_low =
+ std::min(vibration_value.amp_low * player_vibration_strength / 100.0f, 1.0f);
+ const auto amp_high =
+ std::min(vibration_value.amp_high * player_vibration_strength / 100.0f, 1.0f);
+ return vibration->SetRumblePlay(amp_low, vibration_value.freq_low, amp_high,
+ vibration_value.freq_high);
}
void Controller_NPad::VibrateController(const DeviceHandle& vibration_device_handle,
@@ -855,7 +858,7 @@ void Controller_NPad::DisconnectNpad(u32 npad_id) {
void Controller_NPad::DisconnectNpadAtIndex(std::size_t npad_index) {
for (std::size_t device_idx = 0; device_idx < vibrations[npad_index].size(); ++device_idx) {
// Send an empty vibration to stop any vibrations.
- VibrateControllerAtIndex(npad_index, device_idx);
+ VibrateControllerAtIndex(npad_index, device_idx, {});
vibration_devices_mounted[npad_index][device_idx] = false;
}