aboutsummaryrefslogtreecommitdiff
path: root/src/hid_core/frontend/emulated_controller.cpp
diff options
context:
space:
mode:
authorNarr the Reg <juangerman-13@hotmail.com>2024-01-23 11:10:34 -0600
committerNarr the Reg <juangerman-13@hotmail.com>2024-01-23 11:33:08 -0600
commit9d8c4a7802e8a2b96eb40da1b36bd91a263971e4 (patch)
tree48aec311d37a0709c628d4bb0730f12d9dc6b623 /src/hid_core/frontend/emulated_controller.cpp
parentcd792c68c276148fa5ce7b4bbb5825bdc6f0bfbc (diff)
core: hid: Skip duplicated vibrations
Diffstat (limited to 'src/hid_core/frontend/emulated_controller.cpp')
-rw-r--r--src/hid_core/frontend/emulated_controller.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/hid_core/frontend/emulated_controller.cpp b/src/hid_core/frontend/emulated_controller.cpp
index 063f5b15a6..819460eb57 100644
--- a/src/hid_core/frontend/emulated_controller.cpp
+++ b/src/hid_core/frontend/emulated_controller.cpp
@@ -1245,7 +1245,12 @@ bool EmulatedController::SetVibration(DeviceIndex device_index, const VibrationV
return false;
}
- last_vibration_value = vibration;
+ // Skip duplicated vibrations
+ if (last_vibration_value[index] == vibration) {
+ return Settings::values.vibration_enabled.GetValue();
+ }
+
+ last_vibration_value[index] = vibration;
if (!Settings::values.vibration_enabled) {
return false;
@@ -1276,7 +1281,10 @@ bool EmulatedController::SetVibration(DeviceIndex device_index, const VibrationV
}
VibrationValue EmulatedController::GetActualVibrationValue(DeviceIndex device_index) const {
- return last_vibration_value;
+ if (device_index >= DeviceIndex::MaxDeviceIndex) {
+ return Core::HID::DEFAULT_VIBRATION_VALUE;
+ }
+ return last_vibration_value[static_cast<std::size_t>(device_index)];
}
bool EmulatedController::IsVibrationEnabled(std::size_t device_index) {