summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Morph2020-11-10 12:09:44 -0500
committerGravatar Morph2020-11-15 23:33:21 -0500
commitad502093835868d5d3ae43caa9faa28c8cb621f2 (patch)
tree7ca07f49137e7962396ceffa55b973d567c438f0
parentcontrollers/npad: Load input devices on init (diff)
downloadyuzu-ad502093835868d5d3ae43caa9faa28c8cb621f2.tar.gz
yuzu-ad502093835868d5d3ae43caa9faa28c8cb621f2.tar.xz
yuzu-ad502093835868d5d3ae43caa9faa28c8cb621f2.zip
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.
Diffstat (limited to '')
-rw-r--r--src/core/hle/service/hid/controllers/npad.cpp8
-rw-r--r--src/core/hle/service/hid/controllers/npad.h3
-rw-r--r--src/core/hle/service/hid/hid.cpp11
3 files changed, 17 insertions, 5 deletions
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp
index a606ceeec..e2539ded8 100644
--- a/src/core/hle/service/hid/controllers/npad.cpp
+++ b/src/core/hle/service/hid/controllers/npad.cpp
@@ -734,7 +734,7 @@ bool Controller_NPad::VibrateControllerAtIndex(std::size_t npad_index, std::size
734 734
735void Controller_NPad::VibrateController(const DeviceHandle& vibration_device_handle, 735void Controller_NPad::VibrateController(const DeviceHandle& vibration_device_handle,
736 const VibrationValue& vibration_value) { 736 const VibrationValue& vibration_value) {
737 if (!Settings::values.vibration_enabled.GetValue()) { 737 if (!Settings::values.vibration_enabled.GetValue() && !permit_vibration_session_enabled) {
738 return; 738 return;
739 } 739 }
740 740
@@ -774,7 +774,7 @@ void Controller_NPad::VibrateController(const DeviceHandle& vibration_device_han
774 774
775void Controller_NPad::VibrateControllers(const std::vector<DeviceHandle>& vibration_device_handles, 775void Controller_NPad::VibrateControllers(const std::vector<DeviceHandle>& vibration_device_handles,
776 const std::vector<VibrationValue>& vibration_values) { 776 const std::vector<VibrationValue>& vibration_values) {
777 if (!Settings::values.vibration_enabled.GetValue()) { 777 if (!Settings::values.vibration_enabled.GetValue() && !permit_vibration_session_enabled) {
778 return; 778 return;
779 } 779 }
780 780
@@ -811,6 +811,10 @@ void Controller_NPad::InitializeVibrationDeviceAtIndex(std::size_t npad_index,
811 } 811 }
812} 812}
813 813
814void Controller_NPad::SetPermitVibrationSession(bool permit_vibration_session) {
815 permit_vibration_session_enabled = permit_vibration_session;
816}
817
814bool Controller_NPad::IsVibrationDeviceMounted(const DeviceHandle& vibration_device_handle) const { 818bool Controller_NPad::IsVibrationDeviceMounted(const DeviceHandle& vibration_device_handle) const {
815 const auto npad_index = NPadIdToIndex(vibration_device_handle.npad_id); 819 const auto npad_index = NPadIdToIndex(vibration_device_handle.npad_id);
816 const auto device_index = static_cast<std::size_t>(vibration_device_handle.device_index); 820 const auto device_index = static_cast<std::size_t>(vibration_device_handle.device_index);
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h
index 99384524b..160dcbbe3 100644
--- a/src/core/hle/service/hid/controllers/npad.h
+++ b/src/core/hle/service/hid/controllers/npad.h
@@ -163,6 +163,8 @@ public:
163 163
164 void InitializeVibrationDeviceAtIndex(std::size_t npad_index, std::size_t device_index); 164 void InitializeVibrationDeviceAtIndex(std::size_t npad_index, std::size_t device_index);
165 165
166 void SetPermitVibrationSession(bool permit_vibration_session);
167
166 bool IsVibrationDeviceMounted(const DeviceHandle& vibration_device_handle) const; 168 bool IsVibrationDeviceMounted(const DeviceHandle& vibration_device_handle) const;
167 169
168 std::shared_ptr<Kernel::ReadableEvent> GetStyleSetChangedEvent(u32 npad_id) const; 170 std::shared_ptr<Kernel::ReadableEvent> GetStyleSetChangedEvent(u32 npad_id) const;
@@ -426,6 +428,7 @@ private:
426 std::array<Kernel::EventPair, 10> styleset_changed_events; 428 std::array<Kernel::EventPair, 10> styleset_changed_events;
427 std::array<std::array<std::chrono::steady_clock::time_point, 2>, 10> last_vibration_timepoints; 429 std::array<std::array<std::chrono::steady_clock::time_point, 2>, 10> last_vibration_timepoints;
428 std::array<std::array<VibrationValue, 2>, 10> latest_vibration_values{}; 430 std::array<std::array<VibrationValue, 2>, 10> latest_vibration_values{};
431 bool permit_vibration_session_enabled{false};
429 std::array<std::array<bool, 2>, 10> vibration_devices_mounted{}; 432 std::array<std::array<bool, 2>, 10> vibration_devices_mounted{};
430 std::array<ControllerHolder, 10> connected_controllers{}; 433 std::array<ControllerHolder, 10> connected_controllers{};
431 std::array<bool, 10> unintended_home_button_input_protection{}; 434 std::array<bool, 10> unintended_home_button_input_protection{};
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index 2e9682bed..902516b29 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -1119,15 +1119,20 @@ void Hid::BeginPermitVibrationSession(Kernel::HLERequestContext& ctx) {
1119 IPC::RequestParser rp{ctx}; 1119 IPC::RequestParser rp{ctx};
1120 const auto applet_resource_user_id{rp.Pop<u64>()}; 1120 const auto applet_resource_user_id{rp.Pop<u64>()};
1121 1121
1122 LOG_WARNING(Service_HID, "(STUBBED) called, applet_resource_user_id={}", 1122 applet_resource->GetController<Controller_NPad>(HidController::NPad)
1123 applet_resource_user_id); 1123 .SetPermitVibrationSession(true);
1124
1125 LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id);
1124 1126
1125 IPC::ResponseBuilder rb{ctx, 2}; 1127 IPC::ResponseBuilder rb{ctx, 2};
1126 rb.Push(RESULT_SUCCESS); 1128 rb.Push(RESULT_SUCCESS);
1127} 1129}
1128 1130
1129void Hid::EndPermitVibrationSession(Kernel::HLERequestContext& ctx) { 1131void Hid::EndPermitVibrationSession(Kernel::HLERequestContext& ctx) {
1130 LOG_WARNING(Service_HID, "(STUBBED) called"); 1132 applet_resource->GetController<Controller_NPad>(HidController::NPad)
1133 .SetPermitVibrationSession(false);
1134
1135 LOG_DEBUG(Service_HID, "called");
1131 1136
1132 IPC::ResponseBuilder rb{ctx, 2}; 1137 IPC::ResponseBuilder rb{ctx, 2};
1133 rb.Push(RESULT_SUCCESS); 1138 rb.Push(RESULT_SUCCESS);