diff options
| -rw-r--r-- | src/core/hid/emulated_controller.cpp | 19 | ||||
| -rw-r--r-- | src/core/hid/hid_types.h | 7 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.cpp | 7 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.h | 7 | ||||
| -rw-r--r-- | src/core/hle/service/hid/hid.cpp | 2 |
5 files changed, 19 insertions, 23 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 | |||
| 843 | } | 843 | } |
| 844 | 844 | ||
| 845 | bool EmulatedController::TestVibration(std::size_t device_index) { | 845 | bool EmulatedController::TestVibration(std::size_t device_index) { |
| 846 | if (device_index >= output_devices.size()) { | 846 | static constexpr VibrationValue test_vibration = { |
| 847 | return false; | ||
| 848 | } | ||
| 849 | if (!output_devices[device_index]) { | ||
| 850 | return false; | ||
| 851 | } | ||
| 852 | |||
| 853 | // Send a slight vibration to test for rumble support | ||
| 854 | constexpr Common::Input::VibrationStatus status = { | ||
| 855 | .low_amplitude = 0.001f, | 847 | .low_amplitude = 0.001f, |
| 856 | .low_frequency = 160.0f, | 848 | .low_frequency = 160.0f, |
| 857 | .high_amplitude = 0.001f, | 849 | .high_amplitude = 0.001f, |
| 858 | .high_frequency = 320.0f, | 850 | .high_frequency = 320.0f, |
| 859 | .type = Common::Input::VibrationAmplificationType::Linear, | ||
| 860 | }; | 851 | }; |
| 861 | return output_devices[device_index]->SetVibration(status) == | 852 | |
| 862 | Common::Input::VibrationError::None; | 853 | // Send a slight vibration to test for rumble support |
| 854 | SetVibration(device_index, test_vibration); | ||
| 855 | |||
| 856 | // Stop any vibration and return the result | ||
| 857 | return SetVibration(device_index, DEFAULT_VIBRATION_VALUE); | ||
| 863 | } | 858 | } |
| 864 | 859 | ||
| 865 | void EmulatedController::SetLedPattern() { | 860 | 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 { | |||
| 496 | }; | 496 | }; |
| 497 | static_assert(sizeof(VibrationValue) == 0x10, "VibrationValue has incorrect size."); | 497 | static_assert(sizeof(VibrationValue) == 0x10, "VibrationValue has incorrect size."); |
| 498 | 498 | ||
| 499 | constexpr VibrationValue DEFAULT_VIBRATION_VALUE{ | ||
| 500 | .low_amplitude = 0.0f, | ||
| 501 | .low_frequency = 160.0f, | ||
| 502 | .high_amplitude = 0.0f, | ||
| 503 | .high_frequency = 320.0f, | ||
| 504 | }; | ||
| 505 | |||
| 499 | // This is nn::hid::VibrationDeviceInfo | 506 | // This is nn::hid::VibrationDeviceInfo |
| 500 | struct VibrationDeviceInfo { | 507 | struct VibrationDeviceInfo { |
| 501 | VibrationDeviceType type{}; | 508 | VibrationDeviceType type{}; |
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index 2705e9dcb..e5c951e06 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp | |||
| @@ -66,9 +66,9 @@ Controller_NPad::Controller_NPad(Core::HID::HIDCore& hid_core_, | |||
| 66 | auto& controller = controller_data[i]; | 66 | auto& controller = controller_data[i]; |
| 67 | controller.device = hid_core.GetEmulatedControllerByIndex(i); | 67 | controller.device = hid_core.GetEmulatedControllerByIndex(i); |
| 68 | controller.vibration[Core::HID::EmulatedDeviceIndex::LeftIndex].latest_vibration_value = | 68 | controller.vibration[Core::HID::EmulatedDeviceIndex::LeftIndex].latest_vibration_value = |
| 69 | DEFAULT_VIBRATION_VALUE; | 69 | Core::HID::DEFAULT_VIBRATION_VALUE; |
| 70 | controller.vibration[Core::HID::EmulatedDeviceIndex::RightIndex].latest_vibration_value = | 70 | controller.vibration[Core::HID::EmulatedDeviceIndex::RightIndex].latest_vibration_value = |
| 71 | DEFAULT_VIBRATION_VALUE; | 71 | Core::HID::DEFAULT_VIBRATION_VALUE; |
| 72 | Core::HID::ControllerUpdateCallback engine_callback{ | 72 | Core::HID::ControllerUpdateCallback engine_callback{ |
| 73 | .on_change = [this, | 73 | .on_change = [this, |
| 74 | i](Core::HID::ControllerTriggerType type) { ControllerUpdate(type, i); }, | 74 | i](Core::HID::ControllerTriggerType type) { ControllerUpdate(type, i); }, |
| @@ -781,7 +781,8 @@ bool Controller_NPad::VibrateControllerAtIndex(Core::HID::NpadIdType npad_id, | |||
| 781 | Core::HID::VibrationValue vibration{0.0f, 160.0f, 0.0f, 320.0f}; | 781 | Core::HID::VibrationValue vibration{0.0f, 160.0f, 0.0f, 320.0f}; |
| 782 | controller.device->SetVibration(device_index, vibration); | 782 | controller.device->SetVibration(device_index, vibration); |
| 783 | // Then reset the vibration value to its default value. | 783 | // Then reset the vibration value to its default value. |
| 784 | controller.vibration[device_index].latest_vibration_value = DEFAULT_VIBRATION_VALUE; | 784 | controller.vibration[device_index].latest_vibration_value = |
| 785 | Core::HID::DEFAULT_VIBRATION_VALUE; | ||
| 785 | } | 786 | } |
| 786 | 787 | ||
| 787 | return false; | 788 | return false; |
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index 63281cb35..6b2872bad 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h | |||
| @@ -90,13 +90,6 @@ public: | |||
| 90 | Default = 3, | 90 | Default = 3, |
| 91 | }; | 91 | }; |
| 92 | 92 | ||
| 93 | static constexpr Core::HID::VibrationValue DEFAULT_VIBRATION_VALUE{ | ||
| 94 | .low_amplitude = 0.0f, | ||
| 95 | .low_frequency = 160.0f, | ||
| 96 | .high_amplitude = 0.0f, | ||
| 97 | .high_frequency = 320.0f, | ||
| 98 | }; | ||
| 99 | |||
| 100 | void SetSupportedStyleSet(Core::HID::NpadStyleTag style_set); | 93 | void SetSupportedStyleSet(Core::HID::NpadStyleTag style_set); |
| 101 | Core::HID::NpadStyleTag GetSupportedStyleSet() const; | 94 | Core::HID::NpadStyleTag GetSupportedStyleSet() const; |
| 102 | 95 | ||
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 7163e1a4e..6e12381fb 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp | |||
| @@ -1404,7 +1404,7 @@ void Hid::SendVibrationGcErmCommand(Kernel::HLERequestContext& ctx) { | |||
| 1404 | .high_frequency = 0.0f, | 1404 | .high_frequency = 0.0f, |
| 1405 | }; | 1405 | }; |
| 1406 | default: | 1406 | default: |
| 1407 | return Controller_NPad::DEFAULT_VIBRATION_VALUE; | 1407 | return Core::HID::DEFAULT_VIBRATION_VALUE; |
| 1408 | } | 1408 | } |
| 1409 | }(); | 1409 | }(); |
| 1410 | 1410 | ||