summaryrefslogtreecommitdiffstats
path: root/src/hid_core/resources/npad
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2024-01-26 15:55:47 +0100
committerGitHub <noreply@github.com>2024-01-26 15:55:47 +0100
commit4d206d849ec0ac2e90226eb67d90b310afd0a269 (patch)
treebb292c61287e988e13dfd5feaecaa6503d932baf /src/hid_core/resources/npad
parentMerge pull request #12801 from german77/vibration-fix (diff)
parentservice: set: Implement more settings functions for Qlaunch (diff)
downloadyuzu-4d206d849ec0ac2e90226eb67d90b310afd0a269.tar
yuzu-4d206d849ec0ac2e90226eb67d90b310afd0a269.tar.gz
yuzu-4d206d849ec0ac2e90226eb67d90b310afd0a269.tar.bz2
yuzu-4d206d849ec0ac2e90226eb67d90b310afd0a269.tar.lz
yuzu-4d206d849ec0ac2e90226eb67d90b310afd0a269.tar.xz
yuzu-4d206d849ec0ac2e90226eb67d90b310afd0a269.tar.zst
yuzu-4d206d849ec0ac2e90226eb67d90b310afd0a269.zip
Diffstat (limited to 'src/hid_core/resources/npad')
-rw-r--r--src/hid_core/resources/npad/npad.cpp5
-rw-r--r--src/hid_core/resources/npad/npad.h7
-rw-r--r--src/hid_core/resources/npad/npad_vibration.cpp36
-rw-r--r--src/hid_core/resources/npad/npad_vibration.h7
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