diff options
| -rw-r--r-- | src/hid_core/frontend/emulated_controller.cpp | 12 | ||||
| -rw-r--r-- | src/hid_core/frontend/emulated_controller.h | 3 | ||||
| -rw-r--r-- | src/hid_core/hid_types.h | 9 |
3 files changed, 21 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 | ||
| 1278 | VibrationValue EmulatedController::GetActualVibrationValue(DeviceIndex device_index) const { | 1283 | VibrationValue 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 | ||
| 1282 | bool EmulatedController::IsVibrationEnabled(std::size_t device_index) { | 1290 | bool 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}; |
diff --git a/src/hid_core/hid_types.h b/src/hid_core/hid_types.h index 2c3f02f34..a01292a70 100644 --- a/src/hid_core/hid_types.h +++ b/src/hid_core/hid_types.h | |||
| @@ -639,6 +639,15 @@ struct VibrationValue { | |||
| 639 | f32 low_frequency{}; | 639 | f32 low_frequency{}; |
| 640 | f32 high_amplitude{}; | 640 | f32 high_amplitude{}; |
| 641 | f32 high_frequency{}; | 641 | f32 high_frequency{}; |
| 642 | bool operator==(const VibrationValue& b) { | ||
| 643 | if (low_amplitude != b.low_amplitude || high_amplitude != b.high_amplitude) { | ||
| 644 | return false; | ||
| 645 | } | ||
| 646 | if (low_frequency != b.low_amplitude || high_frequency != b.high_frequency) { | ||
| 647 | return false; | ||
| 648 | } | ||
| 649 | return true; | ||
| 650 | } | ||
| 642 | }; | 651 | }; |
| 643 | static_assert(sizeof(VibrationValue) == 0x10, "VibrationValue has incorrect size."); | 652 | static_assert(sizeof(VibrationValue) == 0x10, "VibrationValue has incorrect size."); |
| 644 | 653 | ||