diff options
Diffstat (limited to 'src/core/hid')
-rw-r--r-- | src/core/hid/emulated_controller.cpp | 19 | ||||
-rw-r--r-- | src/core/hid/hid_types.h | 7 |
2 files changed, 14 insertions, 12 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index 93372445b..ff9d7a7e3 100644 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp @@ -843,23 +843,18 @@ bool EmulatedController::SetVibration(std::size_t device_index, VibrationValue v } bool EmulatedController::TestVibration(std::size_t device_index) { - if (device_index >= output_devices.size()) { - return false; - } - if (!output_devices[device_index]) { - return false; - } - - // Send a slight vibration to test for rumble support - constexpr Common::Input::VibrationStatus status = { + static constexpr VibrationValue test_vibration = { .low_amplitude = 0.001f, .low_frequency = 160.0f, .high_amplitude = 0.001f, .high_frequency = 320.0f, - .type = Common::Input::VibrationAmplificationType::Linear, }; - return output_devices[device_index]->SetVibration(status) == - Common::Input::VibrationError::None; + + // Send a slight vibration to test for rumble support + SetVibration(device_index, test_vibration); + + // Stop any vibration and return the result + return SetVibration(device_index, DEFAULT_VIBRATION_VALUE); } void EmulatedController::SetLedPattern() { diff --git a/src/core/hid/hid_types.h b/src/core/hid/hid_types.h index 7c12f01fc..4eca68533 100644 --- a/src/core/hid/hid_types.h +++ b/src/core/hid/hid_types.h @@ -496,6 +496,13 @@ struct VibrationValue { }; static_assert(sizeof(VibrationValue) == 0x10, "VibrationValue has incorrect size."); +constexpr VibrationValue DEFAULT_VIBRATION_VALUE{ + .low_amplitude = 0.0f, + .low_frequency = 160.0f, + .high_amplitude = 0.0f, + .high_frequency = 320.0f, +}; + // This is nn::hid::VibrationDeviceInfo struct VibrationDeviceInfo { VibrationDeviceType type{}; |