diff options
author | Narr the Reg <juangerman-13@hotmail.com> | 2024-01-23 06:30:34 +0100 |
---|---|---|
committer | Narr the Reg <juangerman-13@hotmail.com> | 2024-01-26 00:14:18 +0100 |
commit | 53b321c945d7e6782a6011b7ee55035da8f54dbc (patch) | |
tree | ab538a4d934f71453bd4b16a929599ae5f525668 /src/hid_core/resources/npad | |
parent | Merge pull request #12759 from liamwhite/mp-misc (diff) | |
download | yuzu-53b321c945d7e6782a6011b7ee55035da8f54dbc.tar yuzu-53b321c945d7e6782a6011b7ee55035da8f54dbc.tar.gz yuzu-53b321c945d7e6782a6011b7ee55035da8f54dbc.tar.bz2 yuzu-53b321c945d7e6782a6011b7ee55035da8f54dbc.tar.lz yuzu-53b321c945d7e6782a6011b7ee55035da8f54dbc.tar.xz yuzu-53b321c945d7e6782a6011b7ee55035da8f54dbc.tar.zst yuzu-53b321c945d7e6782a6011b7ee55035da8f54dbc.zip |
Diffstat (limited to '')
-rw-r--r-- | src/hid_core/resources/npad/npad.cpp | 5 | ||||
-rw-r--r-- | src/hid_core/resources/npad/npad.h | 7 | ||||
-rw-r--r-- | src/hid_core/resources/npad/npad_vibration.cpp | 36 | ||||
-rw-r--r-- | src/hid_core/resources/npad/npad_vibration.h | 7 |
4 files changed, 40 insertions, 15 deletions
diff --git a/src/hid_core/resources/npad/npad.cpp b/src/hid_core/resources/npad/npad.cpp index d13a489c9..cde84b1bb 100644 --- a/src/hid_core/resources/npad/npad.cpp +++ b/src/hid_core/resources/npad/npad.cpp @@ -1080,12 +1080,15 @@ void NPad::UnregisterAppletResourceUserId(u64 aruid) { void NPad::SetNpadExternals(std::shared_ptr<AppletResource> resource, std::recursive_mutex* shared_mutex, - std::shared_ptr<HandheldConfig> handheld_config) { + std::shared_ptr<HandheldConfig> handheld_config, + std::shared_ptr<Service::Set::ISystemSettingsServer> settings) { applet_resource_holder.applet_resource = resource; applet_resource_holder.shared_mutex = shared_mutex; applet_resource_holder.shared_npad_resource = &npad_resource; applet_resource_holder.handheld_config = handheld_config; + vibration_handler.SetSettingsService(settings); + for (auto& abstract_pad : abstracted_pads) { abstract_pad.SetExternals(&applet_resource_holder, nullptr, nullptr, nullptr, nullptr, &vibration_handler, &hid_core); diff --git a/src/hid_core/resources/npad/npad.h b/src/hid_core/resources/npad/npad.h index 88289fa2b..502cb9b55 100644 --- a/src/hid_core/resources/npad/npad.h +++ b/src/hid_core/resources/npad/npad.h @@ -34,6 +34,10 @@ namespace Service::KernelHelpers { class ServiceContext; } // namespace Service::KernelHelpers +namespace Service::Set { +class ISystemSettingsServer; +} + union Result; namespace Service::HID { @@ -128,7 +132,8 @@ public: void UnregisterAppletResourceUserId(u64 aruid); void SetNpadExternals(std::shared_ptr<AppletResource> resource, std::recursive_mutex* shared_mutex, - std::shared_ptr<HandheldConfig> handheld_config); + std::shared_ptr<HandheldConfig> handheld_config, + std::shared_ptr<Service::Set::ISystemSettingsServer> settings); AppletDetailedUiType GetAppletDetailedUiType(Core::HID::NpadIdType npad_id); diff --git a/src/hid_core/resources/npad/npad_vibration.cpp b/src/hid_core/resources/npad/npad_vibration.cpp index 05aad4c54..02b1f0290 100644 --- a/src/hid_core/resources/npad/npad_vibration.cpp +++ b/src/hid_core/resources/npad/npad_vibration.cpp @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later +#include "core/hle/service/set/system_settings_server.h" #include "hid_core/hid_result.h" #include "hid_core/resources/npad/npad_vibration.h" @@ -13,10 +14,11 @@ NpadVibration::~NpadVibration() = default; Result NpadVibration::Activate() { std::scoped_lock lock{mutex}; - const f32 master_volume = 1.0f; // nn::settings::system::GetVibrationMasterVolume(); - // if (master_volume < 0.0f || master_volume > 1.0f) { - // return ResultVibrationStrengthOutOfRange; - // } + f32 master_volume = 1.0f; + m_set_sys->GetVibrationMasterVolume(master_volume); + if (master_volume < 0.0f || master_volume > 1.0f) { + return ResultVibrationStrengthOutOfRange; + } volume = master_volume; return ResultSuccess; @@ -26,6 +28,12 @@ Result NpadVibration::Deactivate() { return ResultSuccess; } +Result NpadVibration::SetSettingsService( + std::shared_ptr<Service::Set::ISystemSettingsServer> settings) { + m_set_sys = settings; + return ResultSuccess; +} + Result NpadVibration::SetVibrationMasterVolume(f32 master_volume) { std::scoped_lock lock{mutex}; @@ -34,7 +42,7 @@ Result NpadVibration::SetVibrationMasterVolume(f32 master_volume) { } volume = master_volume; - // nn::settings::system::SetVibrationMasterVolume(master_volume); + m_set_sys->SetVibrationMasterVolume(master_volume); return ResultSuccess; } @@ -48,10 +56,11 @@ Result NpadVibration::GetVibrationVolume(f32& out_volume) const { Result NpadVibration::GetVibrationMasterVolume(f32& out_volume) const { std::scoped_lock lock{mutex}; - const f32 master_volume = 1.0f; // nn::settings::system::GetVibrationMasterVolume(); - // if (master_volume < 0.0f || master_volume > 1.0f) { - // return ResultVibrationStrengthOutOfRange; - // } + f32 master_volume = 1.0f; + m_set_sys->GetVibrationMasterVolume(master_volume); + if (master_volume < 0.0f || master_volume > 1.0f) { + return ResultVibrationStrengthOutOfRange; + } out_volume = master_volume; return ResultSuccess; @@ -67,10 +76,11 @@ Result NpadVibration::BeginPermitVibrationSession(u64 aruid) { Result NpadVibration::EndPermitVibrationSession() { std::scoped_lock lock{mutex}; - const f32 master_volume = 1.0f; // nn::settings::system::GetVibrationMasterVolume(); - // if (master_volume < 0.0f || master_volume > 1.0f) { - // return ResultVibrationStrengthOutOfRange; - // } + f32 master_volume = 1.0f; + m_set_sys->GetVibrationMasterVolume(master_volume); + if (master_volume < 0.0f || master_volume > 1.0f) { + return ResultVibrationStrengthOutOfRange; + } volume = master_volume; session_aruid = 0; diff --git a/src/hid_core/resources/npad/npad_vibration.h b/src/hid_core/resources/npad/npad_vibration.h index d5a95f2a0..6412ca4ab 100644 --- a/src/hid_core/resources/npad/npad_vibration.h +++ b/src/hid_core/resources/npad/npad_vibration.h @@ -8,6 +8,10 @@ #include "common/common_types.h" #include "core/hle/result.h" +namespace Service::Set { +class ISystemSettingsServer; +} + namespace Service::HID { class NpadVibration final { @@ -18,6 +22,7 @@ public: Result Activate(); Result Deactivate(); + Result SetSettingsService(std::shared_ptr<Service::Set::ISystemSettingsServer> settings); Result SetVibrationMasterVolume(f32 master_volume); Result GetVibrationVolume(f32& out_volume) const; Result GetVibrationMasterVolume(f32& out_volume) const; @@ -31,6 +36,8 @@ private: f32 volume{}; u64 session_aruid{}; mutable std::mutex mutex; + + std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys; }; } // namespace Service::HID |