summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorNarr the Reg <juangerman-13@hotmail.com>2021-12-16 03:00:24 +0100
committerNarr the Reg <juangerman-13@hotmail.com>2021-12-16 20:35:15 +0100
commitc82e6dc81048352475cd64968f8733040a35d944 (patch)
tree1fd6749536362bfafc8ff33de7c1b27105ebea61 /src/core
parentMerge pull request #7588 from Wunkolo/gibibibi-bytes (diff)
downloadyuzu-c82e6dc81048352475cd64968f8733040a35d944.tar
yuzu-c82e6dc81048352475cd64968f8733040a35d944.tar.gz
yuzu-c82e6dc81048352475cd64968f8733040a35d944.tar.bz2
yuzu-c82e6dc81048352475cd64968f8733040a35d944.tar.lz
yuzu-c82e6dc81048352475cd64968f8733040a35d944.tar.xz
yuzu-c82e6dc81048352475cd64968f8733040a35d944.tar.zst
yuzu-c82e6dc81048352475cd64968f8733040a35d944.zip
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hid/emulated_controller.cpp19
-rw-r--r--src/core/hid/hid_types.h7
-rw-r--r--src/core/hle/service/hid/controllers/npad.cpp7
-rw-r--r--src/core/hle/service/hid/controllers/npad.h7
-rw-r--r--src/core/hle/service/hid/hid.cpp2
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
}
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{};
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_,
auto& controller = controller_data[i];
controller.device = hid_core.GetEmulatedControllerByIndex(i);
controller.vibration[Core::HID::EmulatedDeviceIndex::LeftIndex].latest_vibration_value =
- DEFAULT_VIBRATION_VALUE;
+ Core::HID::DEFAULT_VIBRATION_VALUE;
controller.vibration[Core::HID::EmulatedDeviceIndex::RightIndex].latest_vibration_value =
- DEFAULT_VIBRATION_VALUE;
+ Core::HID::DEFAULT_VIBRATION_VALUE;
Core::HID::ControllerUpdateCallback engine_callback{
.on_change = [this,
i](Core::HID::ControllerTriggerType type) { ControllerUpdate(type, i); },
@@ -781,7 +781,8 @@ bool Controller_NPad::VibrateControllerAtIndex(Core::HID::NpadIdType npad_id,
Core::HID::VibrationValue vibration{0.0f, 160.0f, 0.0f, 320.0f};
controller.device->SetVibration(device_index, vibration);
// Then reset the vibration value to its default value.
- controller.vibration[device_index].latest_vibration_value = DEFAULT_VIBRATION_VALUE;
+ controller.vibration[device_index].latest_vibration_value =
+ Core::HID::DEFAULT_VIBRATION_VALUE;
}
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:
Default = 3,
};
- static constexpr Core::HID::VibrationValue DEFAULT_VIBRATION_VALUE{
- .low_amplitude = 0.0f,
- .low_frequency = 160.0f,
- .high_amplitude = 0.0f,
- .high_frequency = 320.0f,
- };
-
void SetSupportedStyleSet(Core::HID::NpadStyleTag style_set);
Core::HID::NpadStyleTag GetSupportedStyleSet() const;
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) {
.high_frequency = 0.0f,
};
default:
- return Controller_NPad::DEFAULT_VIBRATION_VALUE;
+ return Core::HID::DEFAULT_VIBRATION_VALUE;
}
}();