summaryrefslogtreecommitdiff
path: root/src/hid_core/frontend
diff options
context:
space:
mode:
authorGravatar Narr the Reg2024-01-23 11:10:34 -0600
committerGravatar Narr the Reg2024-01-23 11:33:08 -0600
commitad4622da2cad626b1acdbf1c3985d4d5b6e86bb0 (patch)
tree48aec311d37a0709c628d4bb0730f12d9dc6b623 /src/hid_core/frontend
parentcore: hid: Only set polling mode if needed (diff)
downloadyuzu-ad4622da2cad626b1acdbf1c3985d4d5b6e86bb0.tar.gz
yuzu-ad4622da2cad626b1acdbf1c3985d4d5b6e86bb0.tar.xz
yuzu-ad4622da2cad626b1acdbf1c3985d4d5b6e86bb0.zip
core: hid: Skip duplicated vibrations
Diffstat (limited to 'src/hid_core/frontend')
-rw-r--r--src/hid_core/frontend/emulated_controller.cpp12
-rw-r--r--src/hid_core/frontend/emulated_controller.h3
2 files changed, 12 insertions, 3 deletions
diff --git a/src/hid_core/frontend/emulated_controller.cpp b/src/hid_core/frontend/emulated_controller.cpp
index 063f5b15a..819460eb5 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
1245 return false; 1245 return false;
1246 } 1246 }
1247 1247
1248 last_vibration_value = vibration; 1248 // Skip duplicated vibrations
1249 if (last_vibration_value[index] == vibration) {
1250 return Settings::values.vibration_enabled.GetValue();
1251 }
1252
1253 last_vibration_value[index] = vibration;
1249 1254
1250 if (!Settings::values.vibration_enabled) { 1255 if (!Settings::values.vibration_enabled) {
1251 return false; 1256 return false;
@@ -1276,7 +1281,10 @@ bool EmulatedController::SetVibration(DeviceIndex device_index, const VibrationV
1276} 1281}
1277 1282
1278VibrationValue EmulatedController::GetActualVibrationValue(DeviceIndex device_index) const { 1283VibrationValue EmulatedController::GetActualVibrationValue(DeviceIndex device_index) const {
1279 return last_vibration_value; 1284 if (device_index >= DeviceIndex::MaxDeviceIndex) {
1285 return Core::HID::DEFAULT_VIBRATION_VALUE;
1286 }
1287 return last_vibration_value[static_cast<std::size_t>(device_index)];
1280} 1288}
1281 1289
1282bool EmulatedController::IsVibrationEnabled(std::size_t device_index) { 1290bool EmulatedController::IsVibrationEnabled(std::size_t device_index) {
diff --git a/src/hid_core/frontend/emulated_controller.h b/src/hid_core/frontend/emulated_controller.h
index 168abe089..701b38300 100644
--- a/src/hid_core/frontend/emulated_controller.h
+++ b/src/hid_core/frontend/emulated_controller.h
@@ -581,7 +581,8 @@ private:
581 f32 motion_sensitivity{Core::HID::MotionInput::IsAtRestStandard}; 581 f32 motion_sensitivity{Core::HID::MotionInput::IsAtRestStandard};
582 u32 turbo_button_state{0}; 582 u32 turbo_button_state{0};
583 std::size_t nfc_handles{0}; 583 std::size_t nfc_handles{0};
584 VibrationValue last_vibration_value{DEFAULT_VIBRATION_VALUE}; 584 std::array<VibrationValue, 2> last_vibration_value{DEFAULT_VIBRATION_VALUE,
585 DEFAULT_VIBRATION_VALUE};
585 586
586 // Temporary values to avoid doing changes while the controller is in configuring mode 587 // Temporary values to avoid doing changes while the controller is in configuring mode
587 NpadStyleIndex tmp_npad_type{NpadStyleIndex::None}; 588 NpadStyleIndex tmp_npad_type{NpadStyleIndex::None};