summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar liamwhite2024-01-26 09:55:47 -0500
committerGravatar GitHub2024-01-26 09:55:47 -0500
commit4d206d849ec0ac2e90226eb67d90b310afd0a269 (patch)
treebb292c61287e988e13dfd5feaecaa6503d932baf
parentMerge pull request #12801 from german77/vibration-fix (diff)
parentservice: set: Implement more settings functions for Qlaunch (diff)
downloadyuzu-4d206d849ec0ac2e90226eb67d90b310afd0a269.tar.gz
yuzu-4d206d849ec0ac2e90226eb67d90b310afd0a269.tar.xz
yuzu-4d206d849ec0ac2e90226eb67d90b310afd0a269.zip
Merge pull request #12765 from german77/sys-hid
service: set: Implement more settings functions for Qlaunch
-rw-r--r--src/core/hle/service/btm/btm.cpp9
-rw-r--r--src/core/hle/service/hid/hid.cpp2
-rw-r--r--src/core/hle/service/hid/hid_server.cpp4
-rw-r--r--src/core/hle/service/hid/hid_system_server.cpp54
-rw-r--r--src/core/hle/service/hid/hid_system_server.h9
-rw-r--r--src/core/hle/service/set/setting_formats/system_settings.cpp1
-rw-r--r--src/core/hle/service/set/settings_types.h9
-rw-r--r--src/core/hle/service/set/system_settings_server.cpp175
-rw-r--r--src/core/hle/service/set/system_settings_server.h36
-rw-r--r--src/hid_core/resource_manager.cpp8
-rw-r--r--src/hid_core/resources/hid_firmware_settings.cpp12
-rw-r--r--src/hid_core/resources/hid_firmware_settings.h3
-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
16 files changed, 289 insertions, 88 deletions
diff --git a/src/core/hle/service/btm/btm.cpp b/src/core/hle/service/btm/btm.cpp
index c65e32489..2dc23e674 100644
--- a/src/core/hle/service/btm/btm.cpp
+++ b/src/core/hle/service/btm/btm.cpp
@@ -283,7 +283,7 @@ public:
283 {17, &IBtmSystemCore::GetConnectedAudioDevices, "GetConnectedAudioDevices"}, 283 {17, &IBtmSystemCore::GetConnectedAudioDevices, "GetConnectedAudioDevices"},
284 {18, nullptr, "DisconnectAudioDevice"}, 284 {18, nullptr, "DisconnectAudioDevice"},
285 {19, nullptr, "AcquirePairedAudioDeviceInfoChangedEvent"}, 285 {19, nullptr, "AcquirePairedAudioDeviceInfoChangedEvent"},
286 {20, nullptr, "GetPairedAudioDevices"}, 286 {20, &IBtmSystemCore::GetPairedAudioDevices, "GetPairedAudioDevices"},
287 {21, nullptr, "RemoveAudioDevicePairing"}, 287 {21, nullptr, "RemoveAudioDevicePairing"},
288 {22, &IBtmSystemCore::RequestAudioDeviceConnectionRejection, "RequestAudioDeviceConnectionRejection"}, 288 {22, &IBtmSystemCore::RequestAudioDeviceConnectionRejection, "RequestAudioDeviceConnectionRejection"},
289 {23, &IBtmSystemCore::CancelAudioDeviceConnectionRejection, "CancelAudioDeviceConnectionRejection"} 289 {23, &IBtmSystemCore::CancelAudioDeviceConnectionRejection, "CancelAudioDeviceConnectionRejection"}
@@ -327,6 +327,13 @@ private:
327 rb.Push<u32>(0); 327 rb.Push<u32>(0);
328 } 328 }
329 329
330 void GetPairedAudioDevices(HLERequestContext& ctx) {
331 LOG_WARNING(Service_BTM, "(STUBBED) called");
332 IPC::ResponseBuilder rb{ctx, 3};
333 rb.Push(ResultSuccess);
334 rb.Push<u32>(0);
335 }
336
330 void RequestAudioDeviceConnectionRejection(HLERequestContext& ctx) { 337 void RequestAudioDeviceConnectionRejection(HLERequestContext& ctx) {
331 LOG_WARNING(Service_BTM, "(STUBBED) called"); 338 LOG_WARNING(Service_BTM, "(STUBBED) called");
332 IPC::ResponseBuilder rb{ctx, 2}; 339 IPC::ResponseBuilder rb{ctx, 2};
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index 595a3372e..5b28be577 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -33,7 +33,7 @@ void LoopProcess(Core::System& system) {
33 server_manager->RegisterNamedService( 33 server_manager->RegisterNamedService(
34 "hid:dbg", std::make_shared<IHidDebugServer>(system, resource_manager)); 34 "hid:dbg", std::make_shared<IHidDebugServer>(system, resource_manager));
35 server_manager->RegisterNamedService( 35 server_manager->RegisterNamedService(
36 "hid:sys", std::make_shared<IHidSystemServer>(system, resource_manager)); 36 "hid:sys", std::make_shared<IHidSystemServer>(system, resource_manager, firmware_settings));
37 37
38 server_manager->RegisterNamedService("hidbus", std::make_shared<HidBus>(system)); 38 server_manager->RegisterNamedService("hidbus", std::make_shared<HidBus>(system));
39 39
diff --git a/src/core/hle/service/hid/hid_server.cpp b/src/core/hle/service/hid/hid_server.cpp
index 30afed812..09c47b5e3 100644
--- a/src/core/hle/service/hid/hid_server.cpp
+++ b/src/core/hle/service/hid/hid_server.cpp
@@ -1419,8 +1419,8 @@ void IHidServer::EnableUnintendedHomeButtonInputProtection(HLERequestContext& ct
1419 1419
1420 const auto parameters{rp.PopRaw<Parameters>()}; 1420 const auto parameters{rp.PopRaw<Parameters>()};
1421 1421
1422 LOG_INFO(Service_HID, "called, is_enabled={}, npad_id={}, applet_resource_user_id={}", 1422 LOG_DEBUG(Service_HID, "called, is_enabled={}, npad_id={}, applet_resource_user_id={}",
1423 parameters.is_enabled, parameters.npad_id, parameters.applet_resource_user_id); 1423 parameters.is_enabled, parameters.npad_id, parameters.applet_resource_user_id);
1424 1424
1425 if (!IsNpadIdValid(parameters.npad_id)) { 1425 if (!IsNpadIdValid(parameters.npad_id)) {
1426 IPC::ResponseBuilder rb{ctx, 3}; 1426 IPC::ResponseBuilder rb{ctx, 3};
diff --git a/src/core/hle/service/hid/hid_system_server.cpp b/src/core/hle/service/hid/hid_system_server.cpp
index bf27ddfbf..d1ec42edc 100644
--- a/src/core/hle/service/hid/hid_system_server.cpp
+++ b/src/core/hle/service/hid/hid_system_server.cpp
@@ -3,8 +3,10 @@
3 3
4#include "core/hle/service/hid/hid_system_server.h" 4#include "core/hle/service/hid/hid_system_server.h"
5#include "core/hle/service/ipc_helpers.h" 5#include "core/hle/service/ipc_helpers.h"
6#include "core/hle/service/set/settings_types.h"
6#include "hid_core/hid_result.h" 7#include "hid_core/hid_result.h"
7#include "hid_core/resource_manager.h" 8#include "hid_core/resource_manager.h"
9#include "hid_core/resources/hid_firmware_settings.h"
8#include "hid_core/resources/npad/npad.h" 10#include "hid_core/resources/npad/npad.h"
9#include "hid_core/resources/npad/npad_types.h" 11#include "hid_core/resources/npad/npad_types.h"
10#include "hid_core/resources/npad/npad_vibration.h" 12#include "hid_core/resources/npad/npad_vibration.h"
@@ -13,9 +15,10 @@
13 15
14namespace Service::HID { 16namespace Service::HID {
15 17
16IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<ResourceManager> resource) 18IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<ResourceManager> resource,
19 std::shared_ptr<HidFirmwareSettings> settings)
17 : ServiceFramework{system_, "hid:sys"}, service_context{system_, service_name}, 20 : ServiceFramework{system_, "hid:sys"}, service_context{system_, service_name},
18 resource_manager{resource} { 21 resource_manager{resource}, firmware_settings{settings} {
19 // clang-format off 22 // clang-format off
20 static const FunctionInfo functions[] = { 23 static const FunctionInfo functions[] = {
21 {31, nullptr, "SendKeyboardLockKeyEvent"}, 24 {31, nullptr, "SendKeyboardLockKeyEvent"},
@@ -25,7 +28,7 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
25 {131, nullptr, "ActivateSleepButton"}, 28 {131, nullptr, "ActivateSleepButton"},
26 {141, nullptr, "AcquireCaptureButtonEventHandle"}, 29 {141, nullptr, "AcquireCaptureButtonEventHandle"},
27 {151, nullptr, "ActivateCaptureButton"}, 30 {151, nullptr, "ActivateCaptureButton"},
28 {161, nullptr, "GetPlatformConfig"}, 31 {161, &IHidSystemServer::GetPlatformConfig, "GetPlatformConfig"},
29 {210, nullptr, "AcquireNfcDeviceUpdateEventHandle"}, 32 {210, nullptr, "AcquireNfcDeviceUpdateEventHandle"},
30 {211, nullptr, "GetNpadsWithNfc"}, 33 {211, nullptr, "GetNpadsWithNfc"},
31 {212, nullptr, "AcquireNfcActivateEventHandle"}, 34 {212, nullptr, "AcquireNfcActivateEventHandle"},
@@ -80,7 +83,7 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
80 {520, nullptr, "EnableHandheldHids"}, 83 {520, nullptr, "EnableHandheldHids"},
81 {521, nullptr, "DisableHandheldHids"}, 84 {521, nullptr, "DisableHandheldHids"},
82 {522, nullptr, "SetJoyConRailEnabled"}, 85 {522, nullptr, "SetJoyConRailEnabled"},
83 {523, nullptr, "IsJoyConRailEnabled"}, 86 {523, &IHidSystemServer::IsJoyConRailEnabled, "IsJoyConRailEnabled"},
84 {524, nullptr, "IsHandheldHidsEnabled"}, 87 {524, nullptr, "IsHandheldHidsEnabled"},
85 {525, &IHidSystemServer::IsJoyConAttachedOnAllRail, "IsJoyConAttachedOnAllRail"}, 88 {525, &IHidSystemServer::IsJoyConAttachedOnAllRail, "IsJoyConAttachedOnAllRail"},
86 {540, nullptr, "AcquirePlayReportControllerUsageUpdateEvent"}, 89 {540, nullptr, "AcquirePlayReportControllerUsageUpdateEvent"},
@@ -123,7 +126,7 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
123 {831, nullptr, "SetNotificationLedPatternWithTimeout"}, 126 {831, nullptr, "SetNotificationLedPatternWithTimeout"},
124 {832, nullptr, "PrepareHidsForNotificationWake"}, 127 {832, nullptr, "PrepareHidsForNotificationWake"},
125 {850, &IHidSystemServer::IsUsbFullKeyControllerEnabled, "IsUsbFullKeyControllerEnabled"}, 128 {850, &IHidSystemServer::IsUsbFullKeyControllerEnabled, "IsUsbFullKeyControllerEnabled"},
126 {851, nullptr, "EnableUsbFullKeyController"}, 129 {851, &IHidSystemServer::EnableUsbFullKeyController, "EnableUsbFullKeyController"},
127 {852, nullptr, "IsUsbConnected"}, 130 {852, nullptr, "IsUsbConnected"},
128 {870, &IHidSystemServer::IsHandheldButtonPressedOnConsoleMode, "IsHandheldButtonPressedOnConsoleMode"}, 131 {870, &IHidSystemServer::IsHandheldButtonPressedOnConsoleMode, "IsHandheldButtonPressedOnConsoleMode"},
129 {900, nullptr, "ActivateInputDetector"}, 132 {900, nullptr, "ActivateInputDetector"},
@@ -148,7 +151,7 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
148 {1120, &IHidSystemServer::SetFirmwareHotfixUpdateSkipEnabled, "SetFirmwareHotfixUpdateSkipEnabled"}, 151 {1120, &IHidSystemServer::SetFirmwareHotfixUpdateSkipEnabled, "SetFirmwareHotfixUpdateSkipEnabled"},
149 {1130, &IHidSystemServer::InitializeUsbFirmwareUpdate, "InitializeUsbFirmwareUpdate"}, 152 {1130, &IHidSystemServer::InitializeUsbFirmwareUpdate, "InitializeUsbFirmwareUpdate"},
150 {1131, &IHidSystemServer::FinalizeUsbFirmwareUpdate, "FinalizeUsbFirmwareUpdate"}, 153 {1131, &IHidSystemServer::FinalizeUsbFirmwareUpdate, "FinalizeUsbFirmwareUpdate"},
151 {1132, nullptr, "CheckUsbFirmwareUpdateRequired"}, 154 {1132, &IHidSystemServer::CheckUsbFirmwareUpdateRequired, "CheckUsbFirmwareUpdateRequired"},
152 {1133, nullptr, "StartUsbFirmwareUpdate"}, 155 {1133, nullptr, "StartUsbFirmwareUpdate"},
153 {1134, nullptr, "GetUsbFirmwareUpdateState"}, 156 {1134, nullptr, "GetUsbFirmwareUpdateState"},
154 {1135, &IHidSystemServer::InitializeUsbFirmwareUpdateWithoutMemory, "InitializeUsbFirmwareUpdateWithoutMemory"}, 157 {1135, &IHidSystemServer::InitializeUsbFirmwareUpdateWithoutMemory, "InitializeUsbFirmwareUpdateWithoutMemory"},
@@ -239,6 +242,16 @@ IHidSystemServer::~IHidSystemServer() {
239 service_context.CloseEvent(unique_pad_connection_event); 242 service_context.CloseEvent(unique_pad_connection_event);
240}; 243};
241 244
245void IHidSystemServer::GetPlatformConfig(HLERequestContext& ctx) {
246 const auto platform_config = firmware_settings->GetPlatformConfig();
247
248 LOG_INFO(Service_HID, "called, platform_config={}", platform_config.raw);
249
250 IPC::ResponseBuilder rb{ctx, 3};
251 rb.Push(ResultSuccess);
252 rb.PushRaw(platform_config);
253}
254
242void IHidSystemServer::ApplyNpadSystemCommonPolicy(HLERequestContext& ctx) { 255void IHidSystemServer::ApplyNpadSystemCommonPolicy(HLERequestContext& ctx) {
243 IPC::RequestParser rp{ctx}; 256 IPC::RequestParser rp{ctx};
244 const auto applet_resource_user_id{rp.Pop<u64>()}; 257 const auto applet_resource_user_id{rp.Pop<u64>()};
@@ -674,6 +687,16 @@ void IHidSystemServer::EndPermitVibrationSession(HLERequestContext& ctx) {
674 rb.Push(result); 687 rb.Push(result);
675} 688}
676 689
690void IHidSystemServer::IsJoyConRailEnabled(HLERequestContext& ctx) {
691 const bool is_attached = true;
692
693 LOG_WARNING(Service_HID, "(STUBBED) called, is_attached={}", is_attached);
694
695 IPC::ResponseBuilder rb{ctx, 3};
696 rb.Push(ResultSuccess);
697 rb.Push(is_attached);
698}
699
677void IHidSystemServer::IsJoyConAttachedOnAllRail(HLERequestContext& ctx) { 700void IHidSystemServer::IsJoyConAttachedOnAllRail(HLERequestContext& ctx) {
678 const bool is_attached = true; 701 const bool is_attached = true;
679 702
@@ -727,7 +750,7 @@ void IHidSystemServer::AcquireUniquePadConnectionEventHandle(HLERequestContext&
727} 750}
728 751
729void IHidSystemServer::GetUniquePadIds(HLERequestContext& ctx) { 752void IHidSystemServer::GetUniquePadIds(HLERequestContext& ctx) {
730 LOG_WARNING(Service_HID, "(STUBBED) called"); 753 LOG_DEBUG(Service_HID, "(STUBBED) called");
731 754
732 IPC::ResponseBuilder rb{ctx, 4}; 755 IPC::ResponseBuilder rb{ctx, 4};
733 rb.Push(ResultSuccess); 756 rb.Push(ResultSuccess);
@@ -752,6 +775,16 @@ void IHidSystemServer::IsUsbFullKeyControllerEnabled(HLERequestContext& ctx) {
752 rb.Push(is_enabled); 775 rb.Push(is_enabled);
753} 776}
754 777
778void IHidSystemServer::EnableUsbFullKeyController(HLERequestContext& ctx) {
779 IPC::RequestParser rp{ctx};
780 const auto is_enabled{rp.Pop<bool>()};
781
782 LOG_WARNING(Service_HID, "(STUBBED) called, is_enabled={}", is_enabled);
783
784 IPC::ResponseBuilder rb{ctx, 2};
785 rb.Push(ResultSuccess);
786}
787
755void IHidSystemServer::IsHandheldButtonPressedOnConsoleMode(HLERequestContext& ctx) { 788void IHidSystemServer::IsHandheldButtonPressedOnConsoleMode(HLERequestContext& ctx) {
756 const bool button_pressed = false; 789 const bool button_pressed = false;
757 790
@@ -798,6 +831,13 @@ void IHidSystemServer::FinalizeUsbFirmwareUpdate(HLERequestContext& ctx) {
798 rb.Push(ResultSuccess); 831 rb.Push(ResultSuccess);
799} 832}
800 833
834void IHidSystemServer::CheckUsbFirmwareUpdateRequired(HLERequestContext& ctx) {
835 LOG_WARNING(Service_HID, "(STUBBED) called");
836
837 IPC::ResponseBuilder rb{ctx, 2};
838 rb.Push(ResultSuccess);
839}
840
801void IHidSystemServer::InitializeUsbFirmwareUpdateWithoutMemory(HLERequestContext& ctx) { 841void IHidSystemServer::InitializeUsbFirmwareUpdateWithoutMemory(HLERequestContext& ctx) {
802 LOG_WARNING(Service_HID, "(STUBBED) called"); 842 LOG_WARNING(Service_HID, "(STUBBED) called");
803 843
diff --git a/src/core/hle/service/hid/hid_system_server.h b/src/core/hle/service/hid/hid_system_server.h
index 90a719f02..4ab4d3931 100644
--- a/src/core/hle/service/hid/hid_system_server.h
+++ b/src/core/hle/service/hid/hid_system_server.h
@@ -16,13 +16,16 @@ class KEvent;
16 16
17namespace Service::HID { 17namespace Service::HID {
18class ResourceManager; 18class ResourceManager;
19class HidFirmwareSettings;
19 20
20class IHidSystemServer final : public ServiceFramework<IHidSystemServer> { 21class IHidSystemServer final : public ServiceFramework<IHidSystemServer> {
21public: 22public:
22 explicit IHidSystemServer(Core::System& system_, std::shared_ptr<ResourceManager> resource); 23 explicit IHidSystemServer(Core::System& system_, std::shared_ptr<ResourceManager> resource,
24 std::shared_ptr<HidFirmwareSettings> settings);
23 ~IHidSystemServer() override; 25 ~IHidSystemServer() override;
24 26
25private: 27private:
28 void GetPlatformConfig(HLERequestContext& ctx);
26 void ApplyNpadSystemCommonPolicy(HLERequestContext& ctx); 29 void ApplyNpadSystemCommonPolicy(HLERequestContext& ctx);
27 void EnableAssigningSingleOnSlSrPress(HLERequestContext& ctx); 30 void EnableAssigningSingleOnSlSrPress(HLERequestContext& ctx);
28 void DisableAssigningSingleOnSlSrPress(HLERequestContext& ctx); 31 void DisableAssigningSingleOnSlSrPress(HLERequestContext& ctx);
@@ -50,6 +53,7 @@ private:
50 void GetVibrationMasterVolume(HLERequestContext& ctx); 53 void GetVibrationMasterVolume(HLERequestContext& ctx);
51 void BeginPermitVibrationSession(HLERequestContext& ctx); 54 void BeginPermitVibrationSession(HLERequestContext& ctx);
52 void EndPermitVibrationSession(HLERequestContext& ctx); 55 void EndPermitVibrationSession(HLERequestContext& ctx);
56 void IsJoyConRailEnabled(HLERequestContext& ctx);
53 void IsJoyConAttachedOnAllRail(HLERequestContext& ctx); 57 void IsJoyConAttachedOnAllRail(HLERequestContext& ctx);
54 void AcquireConnectionTriggerTimeoutEvent(HLERequestContext& ctx); 58 void AcquireConnectionTriggerTimeoutEvent(HLERequestContext& ctx);
55 void AcquireDeviceRegisteredEventForControllerSupport(HLERequestContext& ctx); 59 void AcquireDeviceRegisteredEventForControllerSupport(HLERequestContext& ctx);
@@ -58,12 +62,14 @@ private:
58 void GetUniquePadIds(HLERequestContext& ctx); 62 void GetUniquePadIds(HLERequestContext& ctx);
59 void AcquireJoyDetachOnBluetoothOffEventHandle(HLERequestContext& ctx); 63 void AcquireJoyDetachOnBluetoothOffEventHandle(HLERequestContext& ctx);
60 void IsUsbFullKeyControllerEnabled(HLERequestContext& ctx); 64 void IsUsbFullKeyControllerEnabled(HLERequestContext& ctx);
65 void EnableUsbFullKeyController(HLERequestContext& ctx);
61 void IsHandheldButtonPressedOnConsoleMode(HLERequestContext& ctx); 66 void IsHandheldButtonPressedOnConsoleMode(HLERequestContext& ctx);
62 void InitializeFirmwareUpdate(HLERequestContext& ctx); 67 void InitializeFirmwareUpdate(HLERequestContext& ctx);
63 void CheckFirmwareUpdateRequired(HLERequestContext& ctx); 68 void CheckFirmwareUpdateRequired(HLERequestContext& ctx);
64 void SetFirmwareHotfixUpdateSkipEnabled(HLERequestContext& ctx); 69 void SetFirmwareHotfixUpdateSkipEnabled(HLERequestContext& ctx);
65 void InitializeUsbFirmwareUpdate(HLERequestContext& ctx); 70 void InitializeUsbFirmwareUpdate(HLERequestContext& ctx);
66 void FinalizeUsbFirmwareUpdate(HLERequestContext& ctx); 71 void FinalizeUsbFirmwareUpdate(HLERequestContext& ctx);
72 void CheckUsbFirmwareUpdateRequired(HLERequestContext& ctx);
67 void InitializeUsbFirmwareUpdateWithoutMemory(HLERequestContext& ctx); 73 void InitializeUsbFirmwareUpdateWithoutMemory(HLERequestContext& ctx);
68 void GetTouchScreenDefaultConfiguration(HLERequestContext& ctx); 74 void GetTouchScreenDefaultConfiguration(HLERequestContext& ctx);
69 void SetForceHandheldStyleVibration(HLERequestContext& ctx); 75 void SetForceHandheldStyleVibration(HLERequestContext& ctx);
@@ -77,6 +83,7 @@ private:
77 Kernel::KEvent* unique_pad_connection_event; 83 Kernel::KEvent* unique_pad_connection_event;
78 KernelHelpers::ServiceContext service_context; 84 KernelHelpers::ServiceContext service_context;
79 std::shared_ptr<ResourceManager> resource_manager; 85 std::shared_ptr<ResourceManager> resource_manager;
86 std::shared_ptr<HidFirmwareSettings> firmware_settings;
80}; 87};
81 88
82} // namespace Service::HID 89} // namespace Service::HID
diff --git a/src/core/hle/service/set/setting_formats/system_settings.cpp b/src/core/hle/service/set/setting_formats/system_settings.cpp
index ec00b90a6..88a305f03 100644
--- a/src/core/hle/service/set/setting_formats/system_settings.cpp
+++ b/src/core/hle/service/set/setting_formats/system_settings.cpp
@@ -50,6 +50,7 @@ SystemSettings DefaultSystemSettings() {
50 settings.primary_album_storage = PrimaryAlbumStorage::SdCard; 50 settings.primary_album_storage = PrimaryAlbumStorage::SdCard;
51 settings.battery_percentage_flag = true; 51 settings.battery_percentage_flag = true;
52 settings.chinese_traditional_input_method = ChineseTraditionalInputMethod::Unknown0; 52 settings.chinese_traditional_input_method = ChineseTraditionalInputMethod::Unknown0;
53 settings.vibration_master_volume = 1.0f;
53 54
54 return settings; 55 return settings;
55} 56}
diff --git a/src/core/hle/service/set/settings_types.h b/src/core/hle/service/set/settings_types.h
index f6f227fde..968425319 100644
--- a/src/core/hle/service/set/settings_types.h
+++ b/src/core/hle/service/set/settings_types.h
@@ -323,6 +323,15 @@ struct NotificationFlag {
323}; 323};
324static_assert(sizeof(NotificationFlag) == 4, "NotificationFlag is an invalid size"); 324static_assert(sizeof(NotificationFlag) == 4, "NotificationFlag is an invalid size");
325 325
326struct PlatformConfig {
327 union {
328 u32 raw{};
329 BitField<0, 1, u32> has_rail_interface;
330 BitField<1, 1, u32> has_sio_mcu;
331 };
332};
333static_assert(sizeof(PlatformConfig) == 0x4, "PlatformConfig is an invalid size");
334
326/// This is nn::settings::system::TvFlag 335/// This is nn::settings::system::TvFlag
327struct TvFlag { 336struct TvFlag {
328 union { 337 union {
diff --git a/src/core/hle/service/set/system_settings_server.cpp b/src/core/hle/service/set/system_settings_server.cpp
index b527c39a9..e907b57b6 100644
--- a/src/core/hle/service/set/system_settings_server.cpp
+++ b/src/core/hle/service/set/system_settings_server.cpp
@@ -123,8 +123,8 @@ ISystemSettingsServer::ISystemSettingsServer(Core::System& system_)
123 {30, &ISystemSettingsServer::SetNotificationSettings, "SetNotificationSettings"}, 123 {30, &ISystemSettingsServer::SetNotificationSettings, "SetNotificationSettings"},
124 {31, &ISystemSettingsServer::GetAccountNotificationSettings, "GetAccountNotificationSettings"}, 124 {31, &ISystemSettingsServer::GetAccountNotificationSettings, "GetAccountNotificationSettings"},
125 {32, &ISystemSettingsServer::SetAccountNotificationSettings, "SetAccountNotificationSettings"}, 125 {32, &ISystemSettingsServer::SetAccountNotificationSettings, "SetAccountNotificationSettings"},
126 {35, nullptr, "GetVibrationMasterVolume"}, 126 {35, &ISystemSettingsServer::GetVibrationMasterVolume, "GetVibrationMasterVolume"},
127 {36, nullptr, "SetVibrationMasterVolume"}, 127 {36, &ISystemSettingsServer::SetVibrationMasterVolume, "SetVibrationMasterVolume"},
128 {37, &ISystemSettingsServer::GetSettingsItemValueSize, "GetSettingsItemValueSize"}, 128 {37, &ISystemSettingsServer::GetSettingsItemValueSize, "GetSettingsItemValueSize"},
129 {38, &ISystemSettingsServer::GetSettingsItemValue, "GetSettingsItemValue"}, 129 {38, &ISystemSettingsServer::GetSettingsItemValue, "GetSettingsItemValue"},
130 {39, &ISystemSettingsServer::GetTvSettings, "GetTvSettings"}, 130 {39, &ISystemSettingsServer::GetTvSettings, "GetTvSettings"},
@@ -133,10 +133,10 @@ ISystemSettingsServer::ISystemSettingsServer(Core::System& system_)
133 {42, nullptr, "SetEdid"}, 133 {42, nullptr, "SetEdid"},
134 {43, nullptr, "GetAudioOutputMode"}, 134 {43, nullptr, "GetAudioOutputMode"},
135 {44, nullptr, "SetAudioOutputMode"}, 135 {44, nullptr, "SetAudioOutputMode"},
136 {45, nullptr, "IsForceMuteOnHeadphoneRemoved"}, 136 {45, &ISystemSettingsServer::IsForceMuteOnHeadphoneRemoved, "IsForceMuteOnHeadphoneRemoved"},
137 {46, nullptr, "SetForceMuteOnHeadphoneRemoved"}, 137 {46, &ISystemSettingsServer::SetForceMuteOnHeadphoneRemoved, "SetForceMuteOnHeadphoneRemoved"},
138 {47, &ISystemSettingsServer::GetQuestFlag, "GetQuestFlag"}, 138 {47, &ISystemSettingsServer::GetQuestFlag, "GetQuestFlag"},
139 {48, nullptr, "SetQuestFlag"}, 139 {48, &ISystemSettingsServer::SetQuestFlag, "SetQuestFlag"},
140 {49, nullptr, "GetDataDeletionSettings"}, 140 {49, nullptr, "GetDataDeletionSettings"},
141 {50, nullptr, "SetDataDeletionSettings"}, 141 {50, nullptr, "SetDataDeletionSettings"},
142 {51, nullptr, "GetInitialSystemAppletProgramId"}, 142 {51, nullptr, "GetInitialSystemAppletProgramId"},
@@ -152,7 +152,7 @@ ISystemSettingsServer::ISystemSettingsServer(Core::System& system_)
152 {61, &ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionEnabled, "SetUserSystemClockAutomaticCorrectionEnabled"}, 152 {61, &ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionEnabled, "SetUserSystemClockAutomaticCorrectionEnabled"},
153 {62, &ISystemSettingsServer::GetDebugModeFlag, "GetDebugModeFlag"}, 153 {62, &ISystemSettingsServer::GetDebugModeFlag, "GetDebugModeFlag"},
154 {63, &ISystemSettingsServer::GetPrimaryAlbumStorage, "GetPrimaryAlbumStorage"}, 154 {63, &ISystemSettingsServer::GetPrimaryAlbumStorage, "GetPrimaryAlbumStorage"},
155 {64, nullptr, "SetPrimaryAlbumStorage"}, 155 {64, &ISystemSettingsServer::SetPrimaryAlbumStorage, "SetPrimaryAlbumStorage"},
156 {65, nullptr, "GetUsb30EnableFlag"}, 156 {65, nullptr, "GetUsb30EnableFlag"},
157 {66, nullptr, "SetUsb30EnableFlag"}, 157 {66, nullptr, "SetUsb30EnableFlag"},
158 {67, nullptr, "GetBatteryLot"}, 158 {67, nullptr, "GetBatteryLot"},
@@ -467,7 +467,7 @@ void ISystemSettingsServer::GetExternalSteadyClockSourceId(HLERequestContext& ct
467 LOG_INFO(Service_SET, "called"); 467 LOG_INFO(Service_SET, "called");
468 468
469 Common::UUID id{}; 469 Common::UUID id{};
470 auto res = GetExternalSteadyClockSourceId(id); 470 const auto res = GetExternalSteadyClockSourceId(id);
471 471
472 IPC::ResponseBuilder rb{ctx, 2 + sizeof(Common::UUID) / sizeof(u32)}; 472 IPC::ResponseBuilder rb{ctx, 2 + sizeof(Common::UUID) / sizeof(u32)};
473 rb.Push(res); 473 rb.Push(res);
@@ -478,9 +478,9 @@ void ISystemSettingsServer::SetExternalSteadyClockSourceId(HLERequestContext& ct
478 LOG_INFO(Service_SET, "called"); 478 LOG_INFO(Service_SET, "called");
479 479
480 IPC::RequestParser rp{ctx}; 480 IPC::RequestParser rp{ctx};
481 auto id{rp.PopRaw<Common::UUID>()}; 481 const auto id{rp.PopRaw<Common::UUID>()};
482 482
483 auto res = SetExternalSteadyClockSourceId(id); 483 const auto res = SetExternalSteadyClockSourceId(id);
484 484
485 IPC::ResponseBuilder rb{ctx, 2}; 485 IPC::ResponseBuilder rb{ctx, 2};
486 rb.Push(res); 486 rb.Push(res);
@@ -490,7 +490,7 @@ void ISystemSettingsServer::GetUserSystemClockContext(HLERequestContext& ctx) {
490 LOG_INFO(Service_SET, "called"); 490 LOG_INFO(Service_SET, "called");
491 491
492 Service::PSC::Time::SystemClockContext context{}; 492 Service::PSC::Time::SystemClockContext context{};
493 auto res = GetUserSystemClockContext(context); 493 const auto res = GetUserSystemClockContext(context);
494 494
495 IPC::ResponseBuilder rb{ctx, 2 + sizeof(Service::PSC::Time::SystemClockContext) / sizeof(u32)}; 495 IPC::ResponseBuilder rb{ctx, 2 + sizeof(Service::PSC::Time::SystemClockContext) / sizeof(u32)};
496 rb.Push(res); 496 rb.Push(res);
@@ -501,9 +501,9 @@ void ISystemSettingsServer::SetUserSystemClockContext(HLERequestContext& ctx) {
501 LOG_INFO(Service_SET, "called"); 501 LOG_INFO(Service_SET, "called");
502 502
503 IPC::RequestParser rp{ctx}; 503 IPC::RequestParser rp{ctx};
504 auto context{rp.PopRaw<Service::PSC::Time::SystemClockContext>()}; 504 const auto context{rp.PopRaw<Service::PSC::Time::SystemClockContext>()};
505 505
506 auto res = SetUserSystemClockContext(context); 506 const auto res = SetUserSystemClockContext(context);
507 507
508 IPC::ResponseBuilder rb{ctx, 2}; 508 IPC::ResponseBuilder rb{ctx, 2};
509 rb.Push(res); 509 rb.Push(res);
@@ -652,6 +652,29 @@ void ISystemSettingsServer::SetAccountNotificationSettings(HLERequestContext& ct
652 rb.Push(ResultSuccess); 652 rb.Push(ResultSuccess);
653} 653}
654 654
655void ISystemSettingsServer::GetVibrationMasterVolume(HLERequestContext& ctx) {
656 f32 vibration_master_volume = {};
657 const auto result = GetVibrationMasterVolume(vibration_master_volume);
658
659 LOG_INFO(Service_SET, "called, master_volume={}", vibration_master_volume);
660
661 IPC::ResponseBuilder rb{ctx, 3};
662 rb.Push(result);
663 rb.Push(vibration_master_volume);
664}
665
666void ISystemSettingsServer::SetVibrationMasterVolume(HLERequestContext& ctx) {
667 IPC::RequestParser rp{ctx};
668 const auto vibration_master_volume = rp.PopRaw<f32>();
669
670 LOG_INFO(Service_SET, "called, elements={}", m_system_settings.vibration_master_volume);
671
672 const auto result = SetVibrationMasterVolume(vibration_master_volume);
673
674 IPC::ResponseBuilder rb{ctx, 2};
675 rb.Push(result);
676}
677
655// FIXME: implement support for the real system_settings.ini 678// FIXME: implement support for the real system_settings.ini
656 679
657template <typename T> 680template <typename T>
@@ -683,6 +706,8 @@ static Settings GetSettings() {
683 ret["time"]["standard_user_clock_initial_year"] = ToBytes(s32{2023}); 706 ret["time"]["standard_user_clock_initial_year"] = ToBytes(s32{2023});
684 707
685 // HID 708 // HID
709 ret["hid"]["has_rail_interface"] = ToBytes(bool{true});
710 ret["hid"]["has_sio_mcu"] = ToBytes(bool{true});
686 ret["hid_debug"]["enables_debugpad"] = ToBytes(bool{true}); 711 ret["hid_debug"]["enables_debugpad"] = ToBytes(bool{true});
687 ret["hid_debug"]["manages_devices"] = ToBytes(bool{true}); 712 ret["hid_debug"]["manages_devices"] = ToBytes(bool{true});
688 ret["hid_debug"]["manages_touch_ic_i2c"] = ToBytes(bool{true}); 713 ret["hid_debug"]["manages_touch_ic_i2c"] = ToBytes(bool{true});
@@ -700,6 +725,9 @@ static Settings GetSettings() {
700 // Settings 725 // Settings
701 ret["settings_debug"]["is_debug_mode_enabled"] = ToBytes(bool{false}); 726 ret["settings_debug"]["is_debug_mode_enabled"] = ToBytes(bool{false});
702 727
728 // Error
729 ret["err"]["applet_auto_close"] = ToBytes(bool{false});
730
703 return ret; 731 return ret;
704} 732}
705 733
@@ -786,15 +814,25 @@ void ISystemSettingsServer::SetTvSettings(HLERequestContext& ctx) {
786 rb.Push(ResultSuccess); 814 rb.Push(ResultSuccess);
787} 815}
788 816
789void ISystemSettingsServer::GetDebugModeFlag(HLERequestContext& ctx) { 817void ISystemSettingsServer::IsForceMuteOnHeadphoneRemoved(HLERequestContext& ctx) {
790 bool is_debug_mode_enabled = false; 818 LOG_INFO(Service_SET, "called, force_mute_on_headphone_removed={}",
791 GetSettingsItemValue<bool>(is_debug_mode_enabled, "settings_debug", "is_debug_mode_enabled"); 819 m_system_settings.force_mute_on_headphone_removed);
792
793 LOG_DEBUG(Service_SET, "called, is_debug_mode_enabled={}", is_debug_mode_enabled);
794 820
795 IPC::ResponseBuilder rb{ctx, 3}; 821 IPC::ResponseBuilder rb{ctx, 3};
796 rb.Push(ResultSuccess); 822 rb.Push(ResultSuccess);
797 rb.Push(is_debug_mode_enabled); 823 rb.PushRaw(m_system_settings.force_mute_on_headphone_removed);
824}
825
826void ISystemSettingsServer::SetForceMuteOnHeadphoneRemoved(HLERequestContext& ctx) {
827 IPC::RequestParser rp{ctx};
828 m_system_settings.force_mute_on_headphone_removed = rp.PopRaw<bool>();
829 SetSaveNeeded();
830
831 LOG_INFO(Service_SET, "called, force_mute_on_headphone_removed={}",
832 m_system_settings.force_mute_on_headphone_removed);
833
834 IPC::ResponseBuilder rb{ctx, 2};
835 rb.Push(ResultSuccess);
798} 836}
799 837
800void ISystemSettingsServer::GetQuestFlag(HLERequestContext& ctx) { 838void ISystemSettingsServer::GetQuestFlag(HLERequestContext& ctx) {
@@ -805,11 +843,22 @@ void ISystemSettingsServer::GetQuestFlag(HLERequestContext& ctx) {
805 rb.PushEnum(m_system_settings.quest_flag); 843 rb.PushEnum(m_system_settings.quest_flag);
806} 844}
807 845
846void ISystemSettingsServer::SetQuestFlag(HLERequestContext& ctx) {
847 IPC::RequestParser rp{ctx};
848 m_system_settings.quest_flag = rp.PopEnum<QuestFlag>();
849 SetSaveNeeded();
850
851 LOG_INFO(Service_SET, "called, quest_flag={}", m_system_settings.quest_flag);
852
853 IPC::ResponseBuilder rb{ctx, 2};
854 rb.Push(ResultSuccess);
855}
856
808void ISystemSettingsServer::GetDeviceTimeZoneLocationName(HLERequestContext& ctx) { 857void ISystemSettingsServer::GetDeviceTimeZoneLocationName(HLERequestContext& ctx) {
809 LOG_INFO(Service_SET, "called"); 858 LOG_INFO(Service_SET, "called");
810 859
811 Service::PSC::Time::LocationName name{}; 860 Service::PSC::Time::LocationName name{};
812 auto res = GetDeviceTimeZoneLocationName(name); 861 const auto res = GetDeviceTimeZoneLocationName(name);
813 862
814 IPC::ResponseBuilder rb{ctx, 2 + sizeof(Service::PSC::Time::LocationName) / sizeof(u32)}; 863 IPC::ResponseBuilder rb{ctx, 2 + sizeof(Service::PSC::Time::LocationName) / sizeof(u32)};
815 rb.Push(res); 864 rb.Push(res);
@@ -822,7 +871,7 @@ void ISystemSettingsServer::SetDeviceTimeZoneLocationName(HLERequestContext& ctx
822 IPC::RequestParser rp{ctx}; 871 IPC::RequestParser rp{ctx};
823 auto name{rp.PopRaw<Service::PSC::Time::LocationName>()}; 872 auto name{rp.PopRaw<Service::PSC::Time::LocationName>()};
824 873
825 auto res = SetDeviceTimeZoneLocationName(name); 874 const auto res = SetDeviceTimeZoneLocationName(name);
826 875
827 IPC::ResponseBuilder rb{ctx, 2}; 876 IPC::ResponseBuilder rb{ctx, 2};
828 rb.Push(res); 877 rb.Push(res);
@@ -843,7 +892,7 @@ void ISystemSettingsServer::GetNetworkSystemClockContext(HLERequestContext& ctx)
843 LOG_INFO(Service_SET, "called"); 892 LOG_INFO(Service_SET, "called");
844 893
845 Service::PSC::Time::SystemClockContext context{}; 894 Service::PSC::Time::SystemClockContext context{};
846 auto res = GetNetworkSystemClockContext(context); 895 const auto res = GetNetworkSystemClockContext(context);
847 896
848 IPC::ResponseBuilder rb{ctx, 2 + sizeof(Service::PSC::Time::SystemClockContext) / sizeof(u32)}; 897 IPC::ResponseBuilder rb{ctx, 2 + sizeof(Service::PSC::Time::SystemClockContext) / sizeof(u32)};
849 rb.Push(res); 898 rb.Push(res);
@@ -854,9 +903,9 @@ void ISystemSettingsServer::SetNetworkSystemClockContext(HLERequestContext& ctx)
854 LOG_INFO(Service_SET, "called"); 903 LOG_INFO(Service_SET, "called");
855 904
856 IPC::RequestParser rp{ctx}; 905 IPC::RequestParser rp{ctx};
857 auto context{rp.PopRaw<Service::PSC::Time::SystemClockContext>()}; 906 const auto context{rp.PopRaw<Service::PSC::Time::SystemClockContext>()};
858 907
859 auto res = SetNetworkSystemClockContext(context); 908 const auto res = SetNetworkSystemClockContext(context);
860 909
861 IPC::ResponseBuilder rb{ctx, 2}; 910 IPC::ResponseBuilder rb{ctx, 2};
862 rb.Push(res); 911 rb.Push(res);
@@ -866,7 +915,7 @@ void ISystemSettingsServer::IsUserSystemClockAutomaticCorrectionEnabled(HLEReque
866 LOG_INFO(Service_SET, "called"); 915 LOG_INFO(Service_SET, "called");
867 916
868 bool enabled{}; 917 bool enabled{};
869 auto res = IsUserSystemClockAutomaticCorrectionEnabled(enabled); 918 const auto res = IsUserSystemClockAutomaticCorrectionEnabled(enabled);
870 919
871 IPC::ResponseBuilder rb{ctx, 3}; 920 IPC::ResponseBuilder rb{ctx, 3};
872 rb.Push(res); 921 rb.Push(res);
@@ -879,12 +928,23 @@ void ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionEnabled(HLERequ
879 IPC::RequestParser rp{ctx}; 928 IPC::RequestParser rp{ctx};
880 auto enabled{rp.Pop<bool>()}; 929 auto enabled{rp.Pop<bool>()};
881 930
882 auto res = SetUserSystemClockAutomaticCorrectionEnabled(enabled); 931 const auto res = SetUserSystemClockAutomaticCorrectionEnabled(enabled);
883 932
884 IPC::ResponseBuilder rb{ctx, 2}; 933 IPC::ResponseBuilder rb{ctx, 2};
885 rb.Push(res); 934 rb.Push(res);
886} 935}
887 936
937void ISystemSettingsServer::GetDebugModeFlag(HLERequestContext& ctx) {
938 bool is_debug_mode_enabled = false;
939 GetSettingsItemValue<bool>(is_debug_mode_enabled, "settings_debug", "is_debug_mode_enabled");
940
941 LOG_DEBUG(Service_SET, "called, is_debug_mode_enabled={}", is_debug_mode_enabled);
942
943 IPC::ResponseBuilder rb{ctx, 3};
944 rb.Push(ResultSuccess);
945 rb.Push(is_debug_mode_enabled);
946}
947
888void ISystemSettingsServer::GetPrimaryAlbumStorage(HLERequestContext& ctx) { 948void ISystemSettingsServer::GetPrimaryAlbumStorage(HLERequestContext& ctx) {
889 LOG_INFO(Service_SET, "called, primary_album_storage={}", 949 LOG_INFO(Service_SET, "called, primary_album_storage={}",
890 m_system_settings.primary_album_storage); 950 m_system_settings.primary_album_storage);
@@ -894,6 +954,18 @@ void ISystemSettingsServer::GetPrimaryAlbumStorage(HLERequestContext& ctx) {
894 rb.PushEnum(m_system_settings.primary_album_storage); 954 rb.PushEnum(m_system_settings.primary_album_storage);
895} 955}
896 956
957void ISystemSettingsServer::SetPrimaryAlbumStorage(HLERequestContext& ctx) {
958 IPC::RequestParser rp{ctx};
959 m_system_settings.primary_album_storage = rp.PopEnum<PrimaryAlbumStorage>();
960 SetSaveNeeded();
961
962 LOG_INFO(Service_SET, "called, primary_album_storage={}",
963 m_system_settings.primary_album_storage);
964
965 IPC::ResponseBuilder rb{ctx, 2};
966 rb.Push(ResultSuccess);
967}
968
897void ISystemSettingsServer::GetNfcEnableFlag(HLERequestContext& ctx) { 969void ISystemSettingsServer::GetNfcEnableFlag(HLERequestContext& ctx) {
898 LOG_INFO(Service_SET, "called, nfc_enable_flag={}", m_system_settings.nfc_enable_flag); 970 LOG_INFO(Service_SET, "called, nfc_enable_flag={}", m_system_settings.nfc_enable_flag);
899 971
@@ -1072,7 +1144,7 @@ void ISystemSettingsServer::SetExternalSteadyClockInternalOffset(HLERequestConte
1072 IPC::RequestParser rp{ctx}; 1144 IPC::RequestParser rp{ctx};
1073 auto offset{rp.Pop<s64>()}; 1145 auto offset{rp.Pop<s64>()};
1074 1146
1075 auto res = SetExternalSteadyClockInternalOffset(offset); 1147 const auto res = SetExternalSteadyClockInternalOffset(offset);
1076 1148
1077 IPC::ResponseBuilder rb{ctx, 2}; 1149 IPC::ResponseBuilder rb{ctx, 2};
1078 rb.Push(res); 1150 rb.Push(res);
@@ -1082,7 +1154,7 @@ void ISystemSettingsServer::GetExternalSteadyClockInternalOffset(HLERequestConte
1082 LOG_DEBUG(Service_SET, "called."); 1154 LOG_DEBUG(Service_SET, "called.");
1083 1155
1084 s64 offset{}; 1156 s64 offset{};
1085 auto res = GetExternalSteadyClockInternalOffset(offset); 1157 const auto res = GetExternalSteadyClockInternalOffset(offset);
1086 1158
1087 IPC::ResponseBuilder rb{ctx, 4}; 1159 IPC::ResponseBuilder rb{ctx, 4};
1088 rb.Push(res); 1160 rb.Push(res);
@@ -1140,7 +1212,7 @@ void ISystemSettingsServer::GetDeviceTimeZoneLocationUpdatedTime(HLERequestConte
1140 LOG_INFO(Service_SET, "called"); 1212 LOG_INFO(Service_SET, "called");
1141 1213
1142 Service::PSC::Time::SteadyClockTimePoint time_point{}; 1214 Service::PSC::Time::SteadyClockTimePoint time_point{};
1143 auto res = GetDeviceTimeZoneLocationUpdatedTime(time_point); 1215 const auto res = GetDeviceTimeZoneLocationUpdatedTime(time_point);
1144 1216
1145 IPC::ResponseBuilder rb{ctx, 4}; 1217 IPC::ResponseBuilder rb{ctx, 4};
1146 rb.Push(res); 1218 rb.Push(res);
@@ -1153,7 +1225,7 @@ void ISystemSettingsServer::SetDeviceTimeZoneLocationUpdatedTime(HLERequestConte
1153 IPC::RequestParser rp{ctx}; 1225 IPC::RequestParser rp{ctx};
1154 auto time_point{rp.PopRaw<Service::PSC::Time::SteadyClockTimePoint>()}; 1226 auto time_point{rp.PopRaw<Service::PSC::Time::SteadyClockTimePoint>()};
1155 1227
1156 auto res = SetDeviceTimeZoneLocationUpdatedTime(time_point); 1228 const auto res = SetDeviceTimeZoneLocationUpdatedTime(time_point);
1157 1229
1158 IPC::ResponseBuilder rb{ctx, 2}; 1230 IPC::ResponseBuilder rb{ctx, 2};
1159 rb.Push(res); 1231 rb.Push(res);
@@ -1164,7 +1236,7 @@ void ISystemSettingsServer::GetUserSystemClockAutomaticCorrectionUpdatedTime(
1164 LOG_INFO(Service_SET, "called"); 1236 LOG_INFO(Service_SET, "called");
1165 1237
1166 Service::PSC::Time::SteadyClockTimePoint time_point{}; 1238 Service::PSC::Time::SteadyClockTimePoint time_point{};
1167 auto res = GetUserSystemClockAutomaticCorrectionUpdatedTime(time_point); 1239 const auto res = GetUserSystemClockAutomaticCorrectionUpdatedTime(time_point);
1168 1240
1169 IPC::ResponseBuilder rb{ctx, 4}; 1241 IPC::ResponseBuilder rb{ctx, 4};
1170 rb.Push(res); 1242 rb.Push(res);
@@ -1176,9 +1248,9 @@ void ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionUpdatedTime(
1176 LOG_INFO(Service_SET, "called"); 1248 LOG_INFO(Service_SET, "called");
1177 1249
1178 IPC::RequestParser rp{ctx}; 1250 IPC::RequestParser rp{ctx};
1179 auto time_point{rp.PopRaw<Service::PSC::Time::SteadyClockTimePoint>()}; 1251 const auto time_point{rp.PopRaw<Service::PSC::Time::SteadyClockTimePoint>()};
1180 1252
1181 auto res = SetUserSystemClockAutomaticCorrectionUpdatedTime(time_point); 1253 const auto res = SetUserSystemClockAutomaticCorrectionUpdatedTime(time_point);
1182 1254
1183 IPC::ResponseBuilder rb{ctx, 2}; 1255 IPC::ResponseBuilder rb{ctx, 2};
1184 rb.Push(res); 1256 rb.Push(res);
@@ -1304,57 +1376,68 @@ Result ISystemSettingsServer::GetSettingsItemValue(std::vector<u8>& out_value,
1304 R_SUCCEED(); 1376 R_SUCCEED();
1305} 1377}
1306 1378
1307Result ISystemSettingsServer::GetExternalSteadyClockSourceId(Common::UUID& out_id) { 1379Result ISystemSettingsServer::GetVibrationMasterVolume(f32& out_volume) const {
1380 out_volume = m_system_settings.vibration_master_volume;
1381 R_SUCCEED();
1382}
1383
1384Result ISystemSettingsServer::SetVibrationMasterVolume(f32 volume) {
1385 m_system_settings.vibration_master_volume = volume;
1386 SetSaveNeeded();
1387 R_SUCCEED();
1388}
1389
1390Result ISystemSettingsServer::GetExternalSteadyClockSourceId(Common::UUID& out_id) const {
1308 out_id = m_private_settings.external_clock_source_id; 1391 out_id = m_private_settings.external_clock_source_id;
1309 R_SUCCEED(); 1392 R_SUCCEED();
1310} 1393}
1311 1394
1312Result ISystemSettingsServer::SetExternalSteadyClockSourceId(Common::UUID id) { 1395Result ISystemSettingsServer::SetExternalSteadyClockSourceId(const Common::UUID& id) {
1313 m_private_settings.external_clock_source_id = id; 1396 m_private_settings.external_clock_source_id = id;
1314 SetSaveNeeded(); 1397 SetSaveNeeded();
1315 R_SUCCEED(); 1398 R_SUCCEED();
1316} 1399}
1317 1400
1318Result ISystemSettingsServer::GetUserSystemClockContext( 1401Result ISystemSettingsServer::GetUserSystemClockContext(
1319 Service::PSC::Time::SystemClockContext& out_context) { 1402 Service::PSC::Time::SystemClockContext& out_context) const {
1320 out_context = m_system_settings.user_system_clock_context; 1403 out_context = m_system_settings.user_system_clock_context;
1321 R_SUCCEED(); 1404 R_SUCCEED();
1322} 1405}
1323 1406
1324Result ISystemSettingsServer::SetUserSystemClockContext( 1407Result ISystemSettingsServer::SetUserSystemClockContext(
1325 Service::PSC::Time::SystemClockContext& context) { 1408 const Service::PSC::Time::SystemClockContext& context) {
1326 m_system_settings.user_system_clock_context = context; 1409 m_system_settings.user_system_clock_context = context;
1327 SetSaveNeeded(); 1410 SetSaveNeeded();
1328 R_SUCCEED(); 1411 R_SUCCEED();
1329} 1412}
1330 1413
1331Result ISystemSettingsServer::GetDeviceTimeZoneLocationName( 1414Result ISystemSettingsServer::GetDeviceTimeZoneLocationName(
1332 Service::PSC::Time::LocationName& out_name) { 1415 Service::PSC::Time::LocationName& out_name) const {
1333 out_name = m_system_settings.device_time_zone_location_name; 1416 out_name = m_system_settings.device_time_zone_location_name;
1334 R_SUCCEED(); 1417 R_SUCCEED();
1335} 1418}
1336 1419
1337Result ISystemSettingsServer::SetDeviceTimeZoneLocationName( 1420Result ISystemSettingsServer::SetDeviceTimeZoneLocationName(
1338 Service::PSC::Time::LocationName& name) { 1421 const Service::PSC::Time::LocationName& name) {
1339 m_system_settings.device_time_zone_location_name = name; 1422 m_system_settings.device_time_zone_location_name = name;
1340 SetSaveNeeded(); 1423 SetSaveNeeded();
1341 R_SUCCEED(); 1424 R_SUCCEED();
1342} 1425}
1343 1426
1344Result ISystemSettingsServer::GetNetworkSystemClockContext( 1427Result ISystemSettingsServer::GetNetworkSystemClockContext(
1345 Service::PSC::Time::SystemClockContext& out_context) { 1428 Service::PSC::Time::SystemClockContext& out_context) const {
1346 out_context = m_system_settings.network_system_clock_context; 1429 out_context = m_system_settings.network_system_clock_context;
1347 R_SUCCEED(); 1430 R_SUCCEED();
1348} 1431}
1349 1432
1350Result ISystemSettingsServer::SetNetworkSystemClockContext( 1433Result ISystemSettingsServer::SetNetworkSystemClockContext(
1351 Service::PSC::Time::SystemClockContext& context) { 1434 const Service::PSC::Time::SystemClockContext& context) {
1352 m_system_settings.network_system_clock_context = context; 1435 m_system_settings.network_system_clock_context = context;
1353 SetSaveNeeded(); 1436 SetSaveNeeded();
1354 R_SUCCEED(); 1437 R_SUCCEED();
1355} 1438}
1356 1439
1357Result ISystemSettingsServer::IsUserSystemClockAutomaticCorrectionEnabled(bool& out_enabled) { 1440Result ISystemSettingsServer::IsUserSystemClockAutomaticCorrectionEnabled(bool& out_enabled) const {
1358 out_enabled = m_system_settings.user_system_clock_automatic_correction_enabled; 1441 out_enabled = m_system_settings.user_system_clock_automatic_correction_enabled;
1359 R_SUCCEED(); 1442 R_SUCCEED();
1360} 1443}
@@ -1371,32 +1454,32 @@ Result ISystemSettingsServer::SetExternalSteadyClockInternalOffset(s64 offset) {
1371 R_SUCCEED(); 1454 R_SUCCEED();
1372} 1455}
1373 1456
1374Result ISystemSettingsServer::GetExternalSteadyClockInternalOffset(s64& out_offset) { 1457Result ISystemSettingsServer::GetExternalSteadyClockInternalOffset(s64& out_offset) const {
1375 out_offset = m_private_settings.external_steady_clock_internal_offset; 1458 out_offset = m_private_settings.external_steady_clock_internal_offset;
1376 R_SUCCEED(); 1459 R_SUCCEED();
1377} 1460}
1378 1461
1379Result ISystemSettingsServer::GetDeviceTimeZoneLocationUpdatedTime( 1462Result ISystemSettingsServer::GetDeviceTimeZoneLocationUpdatedTime(
1380 Service::PSC::Time::SteadyClockTimePoint& out_time_point) { 1463 Service::PSC::Time::SteadyClockTimePoint& out_time_point) const {
1381 out_time_point = m_system_settings.device_time_zone_location_updated_time; 1464 out_time_point = m_system_settings.device_time_zone_location_updated_time;
1382 R_SUCCEED(); 1465 R_SUCCEED();
1383} 1466}
1384 1467
1385Result ISystemSettingsServer::SetDeviceTimeZoneLocationUpdatedTime( 1468Result ISystemSettingsServer::SetDeviceTimeZoneLocationUpdatedTime(
1386 Service::PSC::Time::SteadyClockTimePoint& time_point) { 1469 const Service::PSC::Time::SteadyClockTimePoint& time_point) {
1387 m_system_settings.device_time_zone_location_updated_time = time_point; 1470 m_system_settings.device_time_zone_location_updated_time = time_point;
1388 SetSaveNeeded(); 1471 SetSaveNeeded();
1389 R_SUCCEED(); 1472 R_SUCCEED();
1390} 1473}
1391 1474
1392Result ISystemSettingsServer::GetUserSystemClockAutomaticCorrectionUpdatedTime( 1475Result ISystemSettingsServer::GetUserSystemClockAutomaticCorrectionUpdatedTime(
1393 Service::PSC::Time::SteadyClockTimePoint& out_time_point) { 1476 Service::PSC::Time::SteadyClockTimePoint& out_time_point) const {
1394 out_time_point = m_system_settings.user_system_clock_automatic_correction_updated_time_point; 1477 out_time_point = m_system_settings.user_system_clock_automatic_correction_updated_time_point;
1395 R_SUCCEED(); 1478 R_SUCCEED();
1396} 1479}
1397 1480
1398Result ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionUpdatedTime( 1481Result ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionUpdatedTime(
1399 Service::PSC::Time::SteadyClockTimePoint out_time_point) { 1482 const Service::PSC::Time::SteadyClockTimePoint& out_time_point) {
1400 m_system_settings.user_system_clock_automatic_correction_updated_time_point = out_time_point; 1483 m_system_settings.user_system_clock_automatic_correction_updated_time_point = out_time_point;
1401 SetSaveNeeded(); 1484 SetSaveNeeded();
1402 R_SUCCEED(); 1485 R_SUCCEED();
diff --git a/src/core/hle/service/set/system_settings_server.h b/src/core/hle/service/set/system_settings_server.h
index a2258d16d..acbda8b8c 100644
--- a/src/core/hle/service/set/system_settings_server.h
+++ b/src/core/hle/service/set/system_settings_server.h
@@ -48,26 +48,28 @@ public:
48 return result; 48 return result;
49 } 49 }
50 50
51 Result GetExternalSteadyClockSourceId(Common::UUID& out_id); 51 Result GetVibrationMasterVolume(f32& out_volume) const;
52 Result SetExternalSteadyClockSourceId(Common::UUID id); 52 Result SetVibrationMasterVolume(f32 volume);
53 Result GetUserSystemClockContext(Service::PSC::Time::SystemClockContext& out_context); 53 Result GetExternalSteadyClockSourceId(Common::UUID& out_id) const;
54 Result SetUserSystemClockContext(Service::PSC::Time::SystemClockContext& context); 54 Result SetExternalSteadyClockSourceId(const Common::UUID& id);
55 Result GetDeviceTimeZoneLocationName(Service::PSC::Time::LocationName& out_name); 55 Result GetUserSystemClockContext(Service::PSC::Time::SystemClockContext& out_context) const;
56 Result SetDeviceTimeZoneLocationName(Service::PSC::Time::LocationName& name); 56 Result SetUserSystemClockContext(const Service::PSC::Time::SystemClockContext& context);
57 Result GetNetworkSystemClockContext(Service::PSC::Time::SystemClockContext& out_context); 57 Result GetDeviceTimeZoneLocationName(Service::PSC::Time::LocationName& out_name) const;
58 Result SetNetworkSystemClockContext(Service::PSC::Time::SystemClockContext& context); 58 Result SetDeviceTimeZoneLocationName(const Service::PSC::Time::LocationName& name);
59 Result IsUserSystemClockAutomaticCorrectionEnabled(bool& out_enabled); 59 Result GetNetworkSystemClockContext(Service::PSC::Time::SystemClockContext& out_context) const;
60 Result SetNetworkSystemClockContext(const Service::PSC::Time::SystemClockContext& context);
61 Result IsUserSystemClockAutomaticCorrectionEnabled(bool& out_enabled) const;
60 Result SetUserSystemClockAutomaticCorrectionEnabled(bool enabled); 62 Result SetUserSystemClockAutomaticCorrectionEnabled(bool enabled);
61 Result SetExternalSteadyClockInternalOffset(s64 offset); 63 Result SetExternalSteadyClockInternalOffset(s64 offset);
62 Result GetExternalSteadyClockInternalOffset(s64& out_offset); 64 Result GetExternalSteadyClockInternalOffset(s64& out_offset) const;
63 Result GetDeviceTimeZoneLocationUpdatedTime( 65 Result GetDeviceTimeZoneLocationUpdatedTime(
64 Service::PSC::Time::SteadyClockTimePoint& out_time_point); 66 Service::PSC::Time::SteadyClockTimePoint& out_time_point) const;
65 Result SetDeviceTimeZoneLocationUpdatedTime( 67 Result SetDeviceTimeZoneLocationUpdatedTime(
66 Service::PSC::Time::SteadyClockTimePoint& time_point); 68 const Service::PSC::Time::SteadyClockTimePoint& time_point);
67 Result GetUserSystemClockAutomaticCorrectionUpdatedTime( 69 Result GetUserSystemClockAutomaticCorrectionUpdatedTime(
68 Service::PSC::Time::SteadyClockTimePoint& out_time_point); 70 Service::PSC::Time::SteadyClockTimePoint& out_time_point) const;
69 Result SetUserSystemClockAutomaticCorrectionUpdatedTime( 71 Result SetUserSystemClockAutomaticCorrectionUpdatedTime(
70 Service::PSC::Time::SteadyClockTimePoint time_point); 72 const Service::PSC::Time::SteadyClockTimePoint& time_point);
71 73
72private: 74private:
73 void SetLanguageCode(HLERequestContext& ctx); 75 void SetLanguageCode(HLERequestContext& ctx);
@@ -89,12 +91,17 @@ private:
89 void SetNotificationSettings(HLERequestContext& ctx); 91 void SetNotificationSettings(HLERequestContext& ctx);
90 void GetAccountNotificationSettings(HLERequestContext& ctx); 92 void GetAccountNotificationSettings(HLERequestContext& ctx);
91 void SetAccountNotificationSettings(HLERequestContext& ctx); 93 void SetAccountNotificationSettings(HLERequestContext& ctx);
94 void GetVibrationMasterVolume(HLERequestContext& ctx);
95 void SetVibrationMasterVolume(HLERequestContext& ctx);
92 void GetSettingsItemValueSize(HLERequestContext& ctx); 96 void GetSettingsItemValueSize(HLERequestContext& ctx);
93 void GetSettingsItemValue(HLERequestContext& ctx); 97 void GetSettingsItemValue(HLERequestContext& ctx);
94 void GetTvSettings(HLERequestContext& ctx); 98 void GetTvSettings(HLERequestContext& ctx);
95 void SetTvSettings(HLERequestContext& ctx); 99 void SetTvSettings(HLERequestContext& ctx);
100 void IsForceMuteOnHeadphoneRemoved(HLERequestContext& ctx);
101 void SetForceMuteOnHeadphoneRemoved(HLERequestContext& ctx);
96 void GetDebugModeFlag(HLERequestContext& ctx); 102 void GetDebugModeFlag(HLERequestContext& ctx);
97 void GetQuestFlag(HLERequestContext& ctx); 103 void GetQuestFlag(HLERequestContext& ctx);
104 void SetQuestFlag(HLERequestContext& ctx);
98 void GetDeviceTimeZoneLocationName(HLERequestContext& ctx); 105 void GetDeviceTimeZoneLocationName(HLERequestContext& ctx);
99 void SetDeviceTimeZoneLocationName(HLERequestContext& ctx); 106 void SetDeviceTimeZoneLocationName(HLERequestContext& ctx);
100 void SetRegionCode(HLERequestContext& ctx); 107 void SetRegionCode(HLERequestContext& ctx);
@@ -103,6 +110,7 @@ private:
103 void IsUserSystemClockAutomaticCorrectionEnabled(HLERequestContext& ctx); 110 void IsUserSystemClockAutomaticCorrectionEnabled(HLERequestContext& ctx);
104 void SetUserSystemClockAutomaticCorrectionEnabled(HLERequestContext& ctx); 111 void SetUserSystemClockAutomaticCorrectionEnabled(HLERequestContext& ctx);
105 void GetPrimaryAlbumStorage(HLERequestContext& ctx); 112 void GetPrimaryAlbumStorage(HLERequestContext& ctx);
113 void SetPrimaryAlbumStorage(HLERequestContext& ctx);
106 void GetNfcEnableFlag(HLERequestContext& ctx); 114 void GetNfcEnableFlag(HLERequestContext& ctx);
107 void SetNfcEnableFlag(HLERequestContext& ctx); 115 void SetNfcEnableFlag(HLERequestContext& ctx);
108 void GetSleepSettings(HLERequestContext& ctx); 116 void GetSleepSettings(HLERequestContext& ctx);
diff --git a/src/hid_core/resource_manager.cpp b/src/hid_core/resource_manager.cpp
index 8ef0df020..a2295219a 100644
--- a/src/hid_core/resource_manager.cpp
+++ b/src/hid_core/resource_manager.cpp
@@ -6,6 +6,8 @@
6#include "core/core_timing.h" 6#include "core/core_timing.h"
7#include "core/hle/kernel/k_shared_memory.h" 7#include "core/hle/kernel/k_shared_memory.h"
8#include "core/hle/service/ipc_helpers.h" 8#include "core/hle/service/ipc_helpers.h"
9#include "core/hle/service/set/system_settings_server.h"
10#include "core/hle/service/sm/sm.h"
9#include "hid_core/hid_core.h" 11#include "hid_core/hid_core.h"
10#include "hid_core/hid_util.h" 12#include "hid_core/hid_util.h"
11#include "hid_core/resource_manager.h" 13#include "hid_core/resource_manager.h"
@@ -180,7 +182,11 @@ void ResourceManager::InitializeHidCommonSampler() {
180 debug_pad->SetAppletResource(applet_resource, &shared_mutex); 182 debug_pad->SetAppletResource(applet_resource, &shared_mutex);
181 digitizer->SetAppletResource(applet_resource, &shared_mutex); 183 digitizer->SetAppletResource(applet_resource, &shared_mutex);
182 keyboard->SetAppletResource(applet_resource, &shared_mutex); 184 keyboard->SetAppletResource(applet_resource, &shared_mutex);
183 npad->SetNpadExternals(applet_resource, &shared_mutex, handheld_config); 185
186 const auto settings =
187 system.ServiceManager().GetService<Service::Set::ISystemSettingsServer>("set:sys");
188 npad->SetNpadExternals(applet_resource, &shared_mutex, handheld_config, settings);
189
184 six_axis->SetAppletResource(applet_resource, &shared_mutex); 190 six_axis->SetAppletResource(applet_resource, &shared_mutex);
185 mouse->SetAppletResource(applet_resource, &shared_mutex); 191 mouse->SetAppletResource(applet_resource, &shared_mutex);
186 debug_mouse->SetAppletResource(applet_resource, &shared_mutex); 192 debug_mouse->SetAppletResource(applet_resource, &shared_mutex);
diff --git a/src/hid_core/resources/hid_firmware_settings.cpp b/src/hid_core/resources/hid_firmware_settings.cpp
index 00ceff7e6..9c9019e8f 100644
--- a/src/hid_core/resources/hid_firmware_settings.cpp
+++ b/src/hid_core/resources/hid_firmware_settings.cpp
@@ -40,6 +40,13 @@ void HidFirmwareSettings::LoadSettings(bool reload_config) {
40 m_set_sys->GetSettingsItemValue<bool>(is_touch_firmware_auto_update_disabled, "hid_debug", 40 m_set_sys->GetSettingsItemValue<bool>(is_touch_firmware_auto_update_disabled, "hid_debug",
41 "touch_firmware_auto_update_disabled"); 41 "touch_firmware_auto_update_disabled");
42 42
43 bool has_rail_interface{};
44 bool has_sio_mcu{};
45 m_set_sys->GetSettingsItemValue<bool>(has_rail_interface, "hid", "has_rail_interface");
46 m_set_sys->GetSettingsItemValue<bool>(has_sio_mcu, "hid", "has_sio_mcu");
47 platform_config.has_rail_interface.Assign(has_rail_interface);
48 platform_config.has_sio_mcu.Assign(has_sio_mcu);
49
43 is_initialized = true; 50 is_initialized = true;
44} 51}
45 52
@@ -103,4 +110,9 @@ HidFirmwareSettings::FeaturesPerId HidFirmwareSettings::FeaturesDisabledPerId()
103 return features_per_id_disabled; 110 return features_per_id_disabled;
104} 111}
105 112
113Set::PlatformConfig HidFirmwareSettings::GetPlatformConfig() {
114 LoadSettings(false);
115 return platform_config;
116}
117
106} // namespace Service::HID 118} // namespace Service::HID
diff --git a/src/hid_core/resources/hid_firmware_settings.h b/src/hid_core/resources/hid_firmware_settings.h
index 3694fa9a3..7f146f1e6 100644
--- a/src/hid_core/resources/hid_firmware_settings.h
+++ b/src/hid_core/resources/hid_firmware_settings.h
@@ -4,6 +4,7 @@
4#pragma once 4#pragma once
5 5
6#include "common/common_types.h" 6#include "common/common_types.h"
7#include "core/hle/service/set/settings_types.h"
7 8
8namespace Core { 9namespace Core {
9class System; 10class System;
@@ -39,6 +40,7 @@ public:
39 40
40 FirmwareSetting GetFirmwareUpdateFailure(); 41 FirmwareSetting GetFirmwareUpdateFailure();
41 FeaturesPerId FeaturesDisabledPerId(); 42 FeaturesPerId FeaturesDisabledPerId();
43 Set::PlatformConfig GetPlatformConfig();
42 44
43private: 45private:
44 bool is_initialized{}; 46 bool is_initialized{};
@@ -57,6 +59,7 @@ private:
57 bool is_touch_firmware_auto_update_disabled{}; 59 bool is_touch_firmware_auto_update_disabled{};
58 FirmwareSetting is_firmware_update_failure{}; 60 FirmwareSetting is_firmware_update_failure{};
59 FeaturesPerId features_per_id_disabled{}; 61 FeaturesPerId features_per_id_disabled{};
62 Set::PlatformConfig platform_config{};
60 63
61 std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys; 64 std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys;
62}; 65};
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) {
1080 1080
1081void NPad::SetNpadExternals(std::shared_ptr<AppletResource> resource, 1081void NPad::SetNpadExternals(std::shared_ptr<AppletResource> resource,
1082 std::recursive_mutex* shared_mutex, 1082 std::recursive_mutex* shared_mutex,
1083 std::shared_ptr<HandheldConfig> handheld_config) { 1083 std::shared_ptr<HandheldConfig> handheld_config,
1084 std::shared_ptr<Service::Set::ISystemSettingsServer> settings) {
1084 applet_resource_holder.applet_resource = resource; 1085 applet_resource_holder.applet_resource = resource;
1085 applet_resource_holder.shared_mutex = shared_mutex; 1086 applet_resource_holder.shared_mutex = shared_mutex;
1086 applet_resource_holder.shared_npad_resource = &npad_resource; 1087 applet_resource_holder.shared_npad_resource = &npad_resource;
1087 applet_resource_holder.handheld_config = handheld_config; 1088 applet_resource_holder.handheld_config = handheld_config;
1088 1089
1090 vibration_handler.SetSettingsService(settings);
1091
1089 for (auto& abstract_pad : abstracted_pads) { 1092 for (auto& abstract_pad : abstracted_pads) {
1090 abstract_pad.SetExternals(&applet_resource_holder, nullptr, nullptr, nullptr, nullptr, 1093 abstract_pad.SetExternals(&applet_resource_holder, nullptr, nullptr, nullptr, nullptr,
1091 &vibration_handler, &hid_core); 1094 &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 {
34class ServiceContext; 34class ServiceContext;
35} // namespace Service::KernelHelpers 35} // namespace Service::KernelHelpers
36 36
37namespace Service::Set {
38class ISystemSettingsServer;
39}
40
37union Result; 41union Result;
38 42
39namespace Service::HID { 43namespace Service::HID {
@@ -128,7 +132,8 @@ public:
128 void UnregisterAppletResourceUserId(u64 aruid); 132 void UnregisterAppletResourceUserId(u64 aruid);
129 void SetNpadExternals(std::shared_ptr<AppletResource> resource, 133 void SetNpadExternals(std::shared_ptr<AppletResource> resource,
130 std::recursive_mutex* shared_mutex, 134 std::recursive_mutex* shared_mutex,
131 std::shared_ptr<HandheldConfig> handheld_config); 135 std::shared_ptr<HandheldConfig> handheld_config,
136 std::shared_ptr<Service::Set::ISystemSettingsServer> settings);
132 137
133 AppletDetailedUiType GetAppletDetailedUiType(Core::HID::NpadIdType npad_id); 138 AppletDetailedUiType GetAppletDetailedUiType(Core::HID::NpadIdType npad_id);
134 139
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 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project 1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-3.0-or-later 2// SPDX-License-Identifier: GPL-3.0-or-later
3 3
4#include "core/hle/service/set/system_settings_server.h"
4#include "hid_core/hid_result.h" 5#include "hid_core/hid_result.h"
5#include "hid_core/resources/npad/npad_vibration.h" 6#include "hid_core/resources/npad/npad_vibration.h"
6 7
@@ -13,10 +14,11 @@ NpadVibration::~NpadVibration() = default;
13Result NpadVibration::Activate() { 14Result NpadVibration::Activate() {
14 std::scoped_lock lock{mutex}; 15 std::scoped_lock lock{mutex};
15 16
16 const f32 master_volume = 1.0f; // nn::settings::system::GetVibrationMasterVolume(); 17 f32 master_volume = 1.0f;
17 // if (master_volume < 0.0f || master_volume > 1.0f) { 18 m_set_sys->GetVibrationMasterVolume(master_volume);
18 // return ResultVibrationStrengthOutOfRange; 19 if (master_volume < 0.0f || master_volume > 1.0f) {
19 // } 20 return ResultVibrationStrengthOutOfRange;
21 }
20 22
21 volume = master_volume; 23 volume = master_volume;
22 return ResultSuccess; 24 return ResultSuccess;
@@ -26,6 +28,12 @@ Result NpadVibration::Deactivate() {
26 return ResultSuccess; 28 return ResultSuccess;
27} 29}
28 30
31Result NpadVibration::SetSettingsService(
32 std::shared_ptr<Service::Set::ISystemSettingsServer> settings) {
33 m_set_sys = settings;
34 return ResultSuccess;
35}
36
29Result NpadVibration::SetVibrationMasterVolume(f32 master_volume) { 37Result NpadVibration::SetVibrationMasterVolume(f32 master_volume) {
30 std::scoped_lock lock{mutex}; 38 std::scoped_lock lock{mutex};
31 39
@@ -34,7 +42,7 @@ Result NpadVibration::SetVibrationMasterVolume(f32 master_volume) {
34 } 42 }
35 43
36 volume = master_volume; 44 volume = master_volume;
37 // nn::settings::system::SetVibrationMasterVolume(master_volume); 45 m_set_sys->SetVibrationMasterVolume(master_volume);
38 46
39 return ResultSuccess; 47 return ResultSuccess;
40} 48}
@@ -48,10 +56,11 @@ Result NpadVibration::GetVibrationVolume(f32& out_volume) const {
48Result NpadVibration::GetVibrationMasterVolume(f32& out_volume) const { 56Result NpadVibration::GetVibrationMasterVolume(f32& out_volume) const {
49 std::scoped_lock lock{mutex}; 57 std::scoped_lock lock{mutex};
50 58
51 const f32 master_volume = 1.0f; // nn::settings::system::GetVibrationMasterVolume(); 59 f32 master_volume = 1.0f;
52 // if (master_volume < 0.0f || master_volume > 1.0f) { 60 m_set_sys->GetVibrationMasterVolume(master_volume);
53 // return ResultVibrationStrengthOutOfRange; 61 if (master_volume < 0.0f || master_volume > 1.0f) {
54 // } 62 return ResultVibrationStrengthOutOfRange;
63 }
55 64
56 out_volume = master_volume; 65 out_volume = master_volume;
57 return ResultSuccess; 66 return ResultSuccess;
@@ -67,10 +76,11 @@ Result NpadVibration::BeginPermitVibrationSession(u64 aruid) {
67Result NpadVibration::EndPermitVibrationSession() { 76Result NpadVibration::EndPermitVibrationSession() {
68 std::scoped_lock lock{mutex}; 77 std::scoped_lock lock{mutex};
69 78
70 const f32 master_volume = 1.0f; // nn::settings::system::GetVibrationMasterVolume(); 79 f32 master_volume = 1.0f;
71 // if (master_volume < 0.0f || master_volume > 1.0f) { 80 m_set_sys->GetVibrationMasterVolume(master_volume);
72 // return ResultVibrationStrengthOutOfRange; 81 if (master_volume < 0.0f || master_volume > 1.0f) {
73 // } 82 return ResultVibrationStrengthOutOfRange;
83 }
74 84
75 volume = master_volume; 85 volume = master_volume;
76 session_aruid = 0; 86 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 @@
8#include "common/common_types.h" 8#include "common/common_types.h"
9#include "core/hle/result.h" 9#include "core/hle/result.h"
10 10
11namespace Service::Set {
12class ISystemSettingsServer;
13}
14
11namespace Service::HID { 15namespace Service::HID {
12 16
13class NpadVibration final { 17class NpadVibration final {
@@ -18,6 +22,7 @@ public:
18 Result Activate(); 22 Result Activate();
19 Result Deactivate(); 23 Result Deactivate();
20 24
25 Result SetSettingsService(std::shared_ptr<Service::Set::ISystemSettingsServer> settings);
21 Result SetVibrationMasterVolume(f32 master_volume); 26 Result SetVibrationMasterVolume(f32 master_volume);
22 Result GetVibrationVolume(f32& out_volume) const; 27 Result GetVibrationVolume(f32& out_volume) const;
23 Result GetVibrationMasterVolume(f32& out_volume) const; 28 Result GetVibrationMasterVolume(f32& out_volume) const;
@@ -31,6 +36,8 @@ private:
31 f32 volume{}; 36 f32 volume{};
32 u64 session_aruid{}; 37 u64 session_aruid{};
33 mutable std::mutex mutex; 38 mutable std::mutex mutex;
39
40 std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys;
34}; 41};
35 42
36} // namespace Service::HID 43} // namespace Service::HID