mirror of
https://github.com/yuzu-mirror/yuzu.git
synced 2024-11-20 10:29:58 +00:00
Merge pull request #7593 from german77/brrr_test
core/hid: Cancel any vibration after the test
This commit is contained in:
commit
8e33cf1c2b
5 changed files with 19 additions and 23 deletions
|
@ -843,23 +843,18 @@ bool EmulatedController::SetVibration(std::size_t device_index, VibrationValue v
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EmulatedController::TestVibration(std::size_t device_index) {
|
bool EmulatedController::TestVibration(std::size_t device_index) {
|
||||||
if (device_index >= output_devices.size()) {
|
static constexpr VibrationValue test_vibration = {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!output_devices[device_index]) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send a slight vibration to test for rumble support
|
|
||||||
constexpr Common::Input::VibrationStatus status = {
|
|
||||||
.low_amplitude = 0.001f,
|
.low_amplitude = 0.001f,
|
||||||
.low_frequency = 160.0f,
|
.low_frequency = 160.0f,
|
||||||
.high_amplitude = 0.001f,
|
.high_amplitude = 0.001f,
|
||||||
.high_frequency = 320.0f,
|
.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() {
|
void EmulatedController::SetLedPattern() {
|
||||||
|
|
|
@ -496,6 +496,13 @@ struct VibrationValue {
|
||||||
};
|
};
|
||||||
static_assert(sizeof(VibrationValue) == 0x10, "VibrationValue has incorrect size.");
|
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
|
// This is nn::hid::VibrationDeviceInfo
|
||||||
struct VibrationDeviceInfo {
|
struct VibrationDeviceInfo {
|
||||||
VibrationDeviceType type{};
|
VibrationDeviceType type{};
|
||||||
|
|
|
@ -66,9 +66,9 @@ Controller_NPad::Controller_NPad(Core::HID::HIDCore& hid_core_,
|
||||||
auto& controller = controller_data[i];
|
auto& controller = controller_data[i];
|
||||||
controller.device = hid_core.GetEmulatedControllerByIndex(i);
|
controller.device = hid_core.GetEmulatedControllerByIndex(i);
|
||||||
controller.vibration[Core::HID::EmulatedDeviceIndex::LeftIndex].latest_vibration_value =
|
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 =
|
controller.vibration[Core::HID::EmulatedDeviceIndex::RightIndex].latest_vibration_value =
|
||||||
DEFAULT_VIBRATION_VALUE;
|
Core::HID::DEFAULT_VIBRATION_VALUE;
|
||||||
Core::HID::ControllerUpdateCallback engine_callback{
|
Core::HID::ControllerUpdateCallback engine_callback{
|
||||||
.on_change = [this,
|
.on_change = [this,
|
||||||
i](Core::HID::ControllerTriggerType type) { ControllerUpdate(type, i); },
|
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};
|
Core::HID::VibrationValue vibration{0.0f, 160.0f, 0.0f, 320.0f};
|
||||||
controller.device->SetVibration(device_index, vibration);
|
controller.device->SetVibration(device_index, vibration);
|
||||||
// Then reset the vibration value to its default value.
|
// 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;
|
return false;
|
||||||
|
|
|
@ -90,13 +90,6 @@ public:
|
||||||
Default = 3,
|
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);
|
void SetSupportedStyleSet(Core::HID::NpadStyleTag style_set);
|
||||||
Core::HID::NpadStyleTag GetSupportedStyleSet() const;
|
Core::HID::NpadStyleTag GetSupportedStyleSet() const;
|
||||||
|
|
||||||
|
|
|
@ -1404,7 +1404,7 @@ void Hid::SendVibrationGcErmCommand(Kernel::HLERequestContext& ctx) {
|
||||||
.high_frequency = 0.0f,
|
.high_frequency = 0.0f,
|
||||||
};
|
};
|
||||||
default:
|
default:
|
||||||
return Controller_NPad::DEFAULT_VIBRATION_VALUE;
|
return Core::HID::DEFAULT_VIBRATION_VALUE;
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue