mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-15 22:30:05 +00:00
hid: Reimplement Begin/EndPermitVibrationSession
Upon further investigation, these commands allow temporary vibrations even when the "Controller Vibration" system setting is disabled. As a result, vibrations are allowed when either the system setting or this flag is set to true. Therefore, we can only block vibrations when both flags are set to false.
This commit is contained in:
parent
d8ad2f3484
commit
ad50209383
@ -734,7 +734,7 @@ bool Controller_NPad::VibrateControllerAtIndex(std::size_t npad_index, std::size
|
|||||||
|
|
||||||
void Controller_NPad::VibrateController(const DeviceHandle& vibration_device_handle,
|
void Controller_NPad::VibrateController(const DeviceHandle& vibration_device_handle,
|
||||||
const VibrationValue& vibration_value) {
|
const VibrationValue& vibration_value) {
|
||||||
if (!Settings::values.vibration_enabled.GetValue()) {
|
if (!Settings::values.vibration_enabled.GetValue() && !permit_vibration_session_enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -774,7 +774,7 @@ void Controller_NPad::VibrateController(const DeviceHandle& vibration_device_han
|
|||||||
|
|
||||||
void Controller_NPad::VibrateControllers(const std::vector<DeviceHandle>& vibration_device_handles,
|
void Controller_NPad::VibrateControllers(const std::vector<DeviceHandle>& vibration_device_handles,
|
||||||
const std::vector<VibrationValue>& vibration_values) {
|
const std::vector<VibrationValue>& vibration_values) {
|
||||||
if (!Settings::values.vibration_enabled.GetValue()) {
|
if (!Settings::values.vibration_enabled.GetValue() && !permit_vibration_session_enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -811,6 +811,10 @@ void Controller_NPad::InitializeVibrationDeviceAtIndex(std::size_t npad_index,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Controller_NPad::SetPermitVibrationSession(bool permit_vibration_session) {
|
||||||
|
permit_vibration_session_enabled = permit_vibration_session;
|
||||||
|
}
|
||||||
|
|
||||||
bool Controller_NPad::IsVibrationDeviceMounted(const DeviceHandle& vibration_device_handle) const {
|
bool Controller_NPad::IsVibrationDeviceMounted(const DeviceHandle& vibration_device_handle) const {
|
||||||
const auto npad_index = NPadIdToIndex(vibration_device_handle.npad_id);
|
const auto npad_index = NPadIdToIndex(vibration_device_handle.npad_id);
|
||||||
const auto device_index = static_cast<std::size_t>(vibration_device_handle.device_index);
|
const auto device_index = static_cast<std::size_t>(vibration_device_handle.device_index);
|
||||||
|
@ -163,6 +163,8 @@ public:
|
|||||||
|
|
||||||
void InitializeVibrationDeviceAtIndex(std::size_t npad_index, std::size_t device_index);
|
void InitializeVibrationDeviceAtIndex(std::size_t npad_index, std::size_t device_index);
|
||||||
|
|
||||||
|
void SetPermitVibrationSession(bool permit_vibration_session);
|
||||||
|
|
||||||
bool IsVibrationDeviceMounted(const DeviceHandle& vibration_device_handle) const;
|
bool IsVibrationDeviceMounted(const DeviceHandle& vibration_device_handle) const;
|
||||||
|
|
||||||
std::shared_ptr<Kernel::ReadableEvent> GetStyleSetChangedEvent(u32 npad_id) const;
|
std::shared_ptr<Kernel::ReadableEvent> GetStyleSetChangedEvent(u32 npad_id) const;
|
||||||
@ -426,6 +428,7 @@ private:
|
|||||||
std::array<Kernel::EventPair, 10> styleset_changed_events;
|
std::array<Kernel::EventPair, 10> styleset_changed_events;
|
||||||
std::array<std::array<std::chrono::steady_clock::time_point, 2>, 10> last_vibration_timepoints;
|
std::array<std::array<std::chrono::steady_clock::time_point, 2>, 10> last_vibration_timepoints;
|
||||||
std::array<std::array<VibrationValue, 2>, 10> latest_vibration_values{};
|
std::array<std::array<VibrationValue, 2>, 10> latest_vibration_values{};
|
||||||
|
bool permit_vibration_session_enabled{false};
|
||||||
std::array<std::array<bool, 2>, 10> vibration_devices_mounted{};
|
std::array<std::array<bool, 2>, 10> vibration_devices_mounted{};
|
||||||
std::array<ControllerHolder, 10> connected_controllers{};
|
std::array<ControllerHolder, 10> connected_controllers{};
|
||||||
std::array<bool, 10> unintended_home_button_input_protection{};
|
std::array<bool, 10> unintended_home_button_input_protection{};
|
||||||
|
@ -1119,15 +1119,20 @@ void Hid::BeginPermitVibrationSession(Kernel::HLERequestContext& ctx) {
|
|||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
const auto applet_resource_user_id{rp.Pop<u64>()};
|
const auto applet_resource_user_id{rp.Pop<u64>()};
|
||||||
|
|
||||||
LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}",
|
applet_resource->GetController<Controller_NPad>(HidController::NPad)
|
||||||
applet_resource_user_id);
|
.SetPermitVibrationSession(true);
|
||||||
|
|
||||||
|
LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hid::EndPermitVibrationSession(Kernel::HLERequestContext& ctx) {
|
void Hid::EndPermitVibrationSession(Kernel::HLERequestContext& ctx) {
|
||||||
LOG_WARNING(Service_HID, "(STUBBED) called");
|
applet_resource->GetController<Controller_NPad>(HidController::NPad)
|
||||||
|
.SetPermitVibrationSession(false);
|
||||||
|
|
||||||
|
LOG_DEBUG(Service_HID, "called");
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
Loading…
Reference in New Issue
Block a user