aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpineappleEA <pineaea@gmail.com>2023-12-09 21:52:00 +0100
committerpineappleEA <pineaea@gmail.com>2023-12-09 21:52:00 +0100
commit8a158730e726c347d152b86dcd92fbcac2fc9374 (patch)
tree2e88686c090f359e576d829e2a5a555a1df5b439
parentec2356b0cc22071da025deb08733c26818503049 (diff)
early-access version 4013EA-4013
-rwxr-xr-xREADME.md2
-rwxr-xr-xsrc/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AddGameFolderDialogFragment.kt3
-rwxr-xr-xsrc/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SetupFragment.kt28
-rwxr-xr-xsrc/android/app/src/main/java/org/yuzu/yuzu_emu/model/GamesViewModel.kt2
-rwxr-xr-xsrc/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeViewModel.kt8
-rwxr-xr-xsrc/common/common_funcs.h6
-rwxr-xr-xsrc/common/settings.h14
-rwxr-xr-xsrc/core/CMakeLists.txt8
-rwxr-xr-xsrc/core/arm/debug.cpp5
-rwxr-xr-xsrc/core/hle/kernel/physical_core.cpp2
-rwxr-xr-xsrc/core/hle/service/set/appln_settings.cpp12
-rwxr-xr-xsrc/core/hle/service/set/appln_settings.h35
-rwxr-xr-xsrc/core/hle/service/set/device_settings.cpp12
-rwxr-xr-xsrc/core/hle/service/set/device_settings.h53
-rwxr-xr-xsrc/core/hle/service/set/private_settings.cpp12
-rwxr-xr-xsrc/core/hle/service/set/private_settings.h72
-rwxr-xr-xsrc/core/hle/service/set/set.h24
-rwxr-xr-xsrc/core/hle/service/set/set_sys.cpp683
-rwxr-xr-xsrc/core/hle/service/set/set_sys.h372
-rwxr-xr-xsrc/core/hle/service/set/system_settings.cpp51
-rwxr-xr-xsrc/core/hle/service/set/system_settings.h689
21 files changed, 1651 insertions, 442 deletions
diff --git a/README.md b/README.md
index a9d2f70be..562ee09dc 100755
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
1yuzu emulator early access 1yuzu emulator early access
2============= 2=============
3 3
4This is the source code for early-access 4012. 4This is the source code for early-access 4013.
5 5
6## Legal Notice 6## Legal Notice
7 7
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AddGameFolderDialogFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AddGameFolderDialogFragment.kt
index dec2b7cf1..9fab88248 100755
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AddGameFolderDialogFragment.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/AddGameFolderDialogFragment.kt
@@ -14,8 +14,10 @@ import org.yuzu.yuzu_emu.R
14import org.yuzu.yuzu_emu.databinding.DialogAddFolderBinding 14import org.yuzu.yuzu_emu.databinding.DialogAddFolderBinding
15import org.yuzu.yuzu_emu.model.GameDir 15import org.yuzu.yuzu_emu.model.GameDir
16import org.yuzu.yuzu_emu.model.GamesViewModel 16import org.yuzu.yuzu_emu.model.GamesViewModel
17import org.yuzu.yuzu_emu.model.HomeViewModel
17 18
18class AddGameFolderDialogFragment : DialogFragment() { 19class AddGameFolderDialogFragment : DialogFragment() {
20 private val homeViewModel: HomeViewModel by activityViewModels()
19 private val gamesViewModel: GamesViewModel by activityViewModels() 21 private val gamesViewModel: GamesViewModel by activityViewModels()
20 22
21 override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { 23 override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
@@ -30,6 +32,7 @@ class AddGameFolderDialogFragment : DialogFragment() {
30 .setTitle(R.string.add_game_folder) 32 .setTitle(R.string.add_game_folder)
31 .setPositiveButton(android.R.string.ok) { _: DialogInterface, _: Int -> 33 .setPositiveButton(android.R.string.ok) { _: DialogInterface, _: Int ->
32 val newGameDir = GameDir(folderUriString!!, binding.deepScanSwitch.isChecked) 34 val newGameDir = GameDir(folderUriString!!, binding.deepScanSwitch.isChecked)
35 homeViewModel.setGamesDirSelected(true)
33 gamesViewModel.addFolder(newGameDir) 36 gamesViewModel.addFolder(newGameDir)
34 } 37 }
35 .setNegativeButton(android.R.string.cancel, null) 38 .setNegativeButton(android.R.string.cancel, null)
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SetupFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SetupFragment.kt
index c4277735d..eb5edaa10 100755
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SetupFragment.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SetupFragment.kt
@@ -4,6 +4,7 @@
4package org.yuzu.yuzu_emu.fragments 4package org.yuzu.yuzu_emu.fragments
5 5
6import android.Manifest 6import android.Manifest
7import android.annotation.SuppressLint
7import android.content.Intent 8import android.content.Intent
8import android.os.Build 9import android.os.Build
9import android.os.Bundle 10import android.os.Bundle
@@ -75,6 +76,8 @@ class SetupFragment : Fragment() {
75 return binding.root 76 return binding.root
76 } 77 }
77 78
79 // This is using the correct scope, lint is just acting up
80 @SuppressLint("UnsafeRepeatOnLifecycleDetector")
78 override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 81 override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
79 mainActivity = requireActivity() as MainActivity 82 mainActivity = requireActivity() as MainActivity
80 83
@@ -206,12 +209,24 @@ class SetupFragment : Fragment() {
206 ) 209 )
207 } 210 }
208 211
209 viewLifecycleOwner.lifecycleScope.launch { 212 viewLifecycleOwner.lifecycleScope.apply {
210 repeatOnLifecycle(Lifecycle.State.CREATED) { 213 launch {
211 homeViewModel.shouldPageForward.collect { 214 repeatOnLifecycle(Lifecycle.State.CREATED) {
212 if (it) { 215 homeViewModel.shouldPageForward.collect {
213 pageForward() 216 if (it) {
214 homeViewModel.setShouldPageForward(false) 217 pageForward()
218 homeViewModel.setShouldPageForward(false)
219 }
220 }
221 }
222 }
223 launch {
224 repeatOnLifecycle(Lifecycle.State.CREATED) {
225 homeViewModel.gamesDirSelected.collect {
226 if (it) {
227 gamesDirCallback.onStepCompleted()
228 homeViewModel.setGamesDirSelected(false)
229 }
215 } 230 }
216 } 231 }
217 } 232 }
@@ -339,7 +354,6 @@ class SetupFragment : Fragment() {
339 registerForActivityResult(ActivityResultContracts.OpenDocumentTree()) { result -> 354 registerForActivityResult(ActivityResultContracts.OpenDocumentTree()) { result ->
340 if (result != null) { 355 if (result != null) {
341 mainActivity.processGamesDir(result) 356 mainActivity.processGamesDir(result)
342 gamesDirCallback.onStepCompleted()
343 } 357 }
344 } 358 }
345 359
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/GamesViewModel.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/GamesViewModel.kt
index 752d98c10..fd925235b 100755
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/GamesViewModel.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/GamesViewModel.kt
@@ -133,7 +133,7 @@ class GamesViewModel : ViewModel() {
133 viewModelScope.launch { 133 viewModelScope.launch {
134 withContext(Dispatchers.IO) { 134 withContext(Dispatchers.IO) {
135 NativeConfig.addGameDir(gameDir) 135 NativeConfig.addGameDir(gameDir)
136 getGameDirs() 136 getGameDirs(true)
137 } 137 }
138 } 138 }
139 139
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeViewModel.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeViewModel.kt
index 251b5a667..07e65b028 100755
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeViewModel.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeViewModel.kt
@@ -6,6 +6,7 @@ package org.yuzu.yuzu_emu.model
6import androidx.lifecycle.ViewModel 6import androidx.lifecycle.ViewModel
7import kotlinx.coroutines.flow.MutableStateFlow 7import kotlinx.coroutines.flow.MutableStateFlow
8import kotlinx.coroutines.flow.StateFlow 8import kotlinx.coroutines.flow.StateFlow
9import kotlinx.coroutines.flow.asStateFlow
9 10
10class HomeViewModel : ViewModel() { 11class HomeViewModel : ViewModel() {
11 val navigationVisible: StateFlow<Pair<Boolean, Boolean>> get() = _navigationVisible 12 val navigationVisible: StateFlow<Pair<Boolean, Boolean>> get() = _navigationVisible
@@ -17,6 +18,9 @@ class HomeViewModel : ViewModel() {
17 val shouldPageForward: StateFlow<Boolean> get() = _shouldPageForward 18 val shouldPageForward: StateFlow<Boolean> get() = _shouldPageForward
18 private val _shouldPageForward = MutableStateFlow(false) 19 private val _shouldPageForward = MutableStateFlow(false)
19 20
21 private val _gamesDirSelected = MutableStateFlow(false)
22 val gamesDirSelected get() = _gamesDirSelected.asStateFlow()
23
20 var navigatedToSetup = false 24 var navigatedToSetup = false
21 25
22 fun setNavigationVisibility(visible: Boolean, animated: Boolean) { 26 fun setNavigationVisibility(visible: Boolean, animated: Boolean) {
@@ -36,4 +40,8 @@ class HomeViewModel : ViewModel() {
36 fun setShouldPageForward(pageForward: Boolean) { 40 fun setShouldPageForward(pageForward: Boolean) {
37 _shouldPageForward.value = pageForward 41 _shouldPageForward.value = pageForward
38 } 42 }
43
44 fun setGamesDirSelected(selected: Boolean) {
45 _gamesDirSelected.value = selected
46 }
39} 47}
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h
index 141f805e3..68545c3f8 100755
--- a/src/common/common_funcs.h
+++ b/src/common/common_funcs.h
@@ -123,6 +123,12 @@ namespace Common {
123 return u32(a) | u32(b) << 8 | u32(c) << 16 | u32(d) << 24; 123 return u32(a) | u32(b) << 8 | u32(c) << 16 | u32(d) << 24;
124} 124}
125 125
126[[nodiscard]] constexpr u64 MakeMagic(char a, char b, char c, char d, char e, char f, char g,
127 char h) {
128 return u64(a) << 0 | u64(b) << 8 | u64(c) << 16 | u64(d) << 24 | u64(e) << 32 | u64(f) << 40 |
129 u64(g) << 48 | u64(h) << 56;
130}
131
126// std::size() does not support zero-size C arrays. We're fixing that. 132// std::size() does not support zero-size C arrays. We're fixing that.
127template <class C> 133template <class C>
128constexpr auto Size(const C& c) -> decltype(c.size()) { 134constexpr auto Size(const C& c) -> decltype(c.size()) {
diff --git a/src/common/settings.h b/src/common/settings.h
index 4d231673b..ed6bbb50e 100755
--- a/src/common/settings.h
+++ b/src/common/settings.h
@@ -180,14 +180,20 @@ struct Values {
180 &use_speed_limit}; 180 &use_speed_limit};
181 181
182 // Cpu 182 // Cpu
183 SwitchableSetting<CpuBackend, true> cpu_backend{ 183 SwitchableSetting<CpuBackend, true> cpu_backend{linkage,
184 linkage, CpuBackend::Dynarmic, CpuBackend::Dynarmic,
185#ifdef HAS_NCE 184#ifdef HAS_NCE
186 CpuBackend::Nce, 185 CpuBackend::Nce,
187#else 186#else
188 CpuBackend::Dynarmic, 187 CpuBackend::Dynarmic,
189#endif 188#endif
190 "cpu_backend", Category::Cpu}; 189 CpuBackend::Dynarmic,
190#ifdef HAS_NCE
191 CpuBackend::Nce,
192#else
193 CpuBackend::Dynarmic,
194#endif
195 "cpu_backend",
196 Category::Cpu};
191 SwitchableSetting<CpuAccuracy, true> cpu_accuracy{linkage, CpuAccuracy::Auto, 197 SwitchableSetting<CpuAccuracy, true> cpu_accuracy{linkage, CpuAccuracy::Auto,
192 CpuAccuracy::Auto, CpuAccuracy::Paranoid, 198 CpuAccuracy::Auto, CpuAccuracy::Paranoid,
193 "cpu_accuracy", Category::Cpu}; 199 "cpu_accuracy", Category::Cpu};
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index ce4ab5b38..dc12aecbe 100755
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -778,6 +778,12 @@ add_library(core STATIC
778 hle/service/service.h 778 hle/service/service.h
779 hle/service/set/set.cpp 779 hle/service/set/set.cpp
780 hle/service/set/set.h 780 hle/service/set/set.h
781 hle/service/set/appln_settings.cpp
782 hle/service/set/appln_settings.h
783 hle/service/set/device_settings.cpp
784 hle/service/set/device_settings.h
785 hle/service/set/private_settings.cpp
786 hle/service/set/private_settings.h
781 hle/service/set/set_cal.cpp 787 hle/service/set/set_cal.cpp
782 hle/service/set/set_cal.h 788 hle/service/set/set_cal.h
783 hle/service/set/set_fd.cpp 789 hle/service/set/set_fd.cpp
@@ -786,6 +792,8 @@ add_library(core STATIC
786 hle/service/set/set_sys.h 792 hle/service/set/set_sys.h
787 hle/service/set/settings.cpp 793 hle/service/set/settings.cpp
788 hle/service/set/settings.h 794 hle/service/set/settings.h
795 hle/service/set/system_settings.cpp
796 hle/service/set/system_settings.h
789 hle/service/sm/sm.cpp 797 hle/service/sm/sm.cpp
790 hle/service/sm/sm.h 798 hle/service/sm/sm.h
791 hle/service/sm/sm_controller.cpp 799 hle/service/sm/sm_controller.cpp
diff --git a/src/core/arm/debug.cpp b/src/core/arm/debug.cpp
index 1fe37b8ee..af1c34bc3 100755
--- a/src/core/arm/debug.cpp
+++ b/src/core/arm/debug.cpp
@@ -282,6 +282,8 @@ Loader::AppLoader::Modules FindModules(const Kernel::KProcess* process) {
282 282
283 // Ignore leading directories. 283 // Ignore leading directories.
284 char* path_pointer = module_path.path.data(); 284 char* path_pointer = module_path.path.data();
285 char* path_end =
286 path_pointer + std::min(PathLengthMax, module_path.path_length);
285 287
286 for (s32 i = 0; i < std::min(PathLengthMax, module_path.path_length) && 288 for (s32 i = 0; i < std::min(PathLengthMax, module_path.path_length) &&
287 module_path.path[i] != '\0'; 289 module_path.path[i] != '\0';
@@ -292,7 +294,8 @@ Loader::AppLoader::Modules FindModules(const Kernel::KProcess* process) {
292 } 294 }
293 295
294 // Insert output. 296 // Insert output.
295 modules.emplace(svc_mem_info.base_address, path_pointer); 297 modules.emplace(svc_mem_info.base_address,
298 std::string_view(path_pointer, path_end));
296 } 299 }
297 } 300 }
298 } 301 }
diff --git a/src/core/hle/kernel/physical_core.cpp b/src/core/hle/kernel/physical_core.cpp
index adb575df5..59de32623 100755
--- a/src/core/hle/kernel/physical_core.cpp
+++ b/src/core/hle/kernel/physical_core.cpp
@@ -139,7 +139,7 @@ void PhysicalCore::RunThread(Kernel::KThread* thread) {
139 } 139 }
140 140
141 // Handle external interrupt sources. 141 // Handle external interrupt sources.
142 if (interrupt || !m_is_single_core) { 142 if (interrupt || m_is_single_core) {
143 return; 143 return;
144 } 144 }
145 } 145 }
diff --git a/src/core/hle/service/set/appln_settings.cpp b/src/core/hle/service/set/appln_settings.cpp
new file mode 100755
index 000000000..a5d802757
--- /dev/null
+++ b/src/core/hle/service/set/appln_settings.cpp
@@ -0,0 +1,12 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/service/set/appln_settings.h"
5
6namespace Service::Set {
7
8ApplnSettings DefaultApplnSettings() {
9 return {};
10}
11
12} // namespace Service::Set
diff --git a/src/core/hle/service/set/appln_settings.h b/src/core/hle/service/set/appln_settings.h
new file mode 100755
index 000000000..b07df0ee7
--- /dev/null
+++ b/src/core/hle/service/set/appln_settings.h
@@ -0,0 +1,35 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include <array>
7
8#include "common/common_types.h"
9
10namespace Service::Set {
11struct ApplnSettings {
12 std::array<u8, 0x10> reserved_000;
13
14 // nn::util::Uuid MiiAuthorId, copied from system settings 0x94B0
15 std::array<u8, 0x10> mii_author_id;
16
17 std::array<u8, 0x30> reserved_020;
18
19 // nn::settings::system::ServiceDiscoveryControlSettings
20 std::array<u8, 0x4> service_discovery_control_settings;
21
22 std::array<u8, 0x20> reserved_054;
23
24 bool in_repair_process_enable_flag;
25
26 std::array<u8, 0x3> pad_075;
27};
28static_assert(offsetof(ApplnSettings, mii_author_id) == 0x10);
29static_assert(offsetof(ApplnSettings, service_discovery_control_settings) == 0x50);
30static_assert(offsetof(ApplnSettings, in_repair_process_enable_flag) == 0x74);
31static_assert(sizeof(ApplnSettings) == 0x78, "ApplnSettings has the wrong size!");
32
33ApplnSettings DefaultApplnSettings();
34
35} // namespace Service::Set
diff --git a/src/core/hle/service/set/device_settings.cpp b/src/core/hle/service/set/device_settings.cpp
new file mode 100755
index 000000000..e423ce38a
--- /dev/null
+++ b/src/core/hle/service/set/device_settings.cpp
@@ -0,0 +1,12 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/service/set/device_settings.h"
5
6namespace Service::Set {
7
8DeviceSettings DefaultDeviceSettings() {
9 return {};
10}
11
12} // namespace Service::Set
diff --git a/src/core/hle/service/set/device_settings.h b/src/core/hle/service/set/device_settings.h
new file mode 100755
index 000000000..b6cfe04f2
--- /dev/null
+++ b/src/core/hle/service/set/device_settings.h
@@ -0,0 +1,53 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include <array>
7
8#include "common/common_types.h"
9
10namespace Service::Set {
11struct DeviceSettings {
12 std::array<u8, 0x10> reserved_000;
13
14 // nn::settings::BatteryLot
15 std::array<u8, 0x18> ptm_battery_lot;
16 // nn::settings::system::PtmFuelGaugeParameter
17 std::array<u8, 0x18> ptm_fuel_gauge_parameter;
18 u8 ptm_battery_version;
19 // nn::settings::system::PtmCycleCountReliability
20 u32 ptm_cycle_count_reliability;
21
22 std::array<u8, 0x48> reserved_048;
23
24 // nn::settings::system::AnalogStickUserCalibration L
25 std::array<u8, 0x10> analog_user_stick_calibration_l;
26 // nn::settings::system::AnalogStickUserCalibration R
27 std::array<u8, 0x10> analog_user_stick_calibration_r;
28
29 std::array<u8, 0x20> reserved_0B0;
30
31 // nn::settings::system::ConsoleSixAxisSensorAccelerationBias
32 std::array<u8, 0xC> console_six_axis_sensor_acceleration_bias;
33 // nn::settings::system::ConsoleSixAxisSensorAngularVelocityBias
34 std::array<u8, 0xC> console_six_axis_sensor_angular_velocity_bias;
35 // nn::settings::system::ConsoleSixAxisSensorAccelerationGain
36 std::array<u8, 0x24> console_six_axis_sensor_acceleration_gain;
37 // nn::settings::system::ConsoleSixAxisSensorAngularVelocityGain
38 std::array<u8, 0x24> console_six_axis_sensor_angular_velocity_gain;
39 // nn::settings::system::ConsoleSixAxisSensorAngularVelocityTimeBias
40 std::array<u8, 0xC> console_six_axis_sensor_angular_velocity_time_bias;
41 // nn::settings::system::ConsoleSixAxisSensorAngularAcceleration
42 std::array<u8, 0x24> console_six_axis_sensor_angular_acceleration;
43};
44static_assert(offsetof(DeviceSettings, ptm_battery_lot) == 0x10);
45static_assert(offsetof(DeviceSettings, ptm_cycle_count_reliability) == 0x44);
46static_assert(offsetof(DeviceSettings, analog_user_stick_calibration_l) == 0x90);
47static_assert(offsetof(DeviceSettings, console_six_axis_sensor_acceleration_bias) == 0xD0);
48static_assert(offsetof(DeviceSettings, console_six_axis_sensor_angular_acceleration) == 0x13C);
49static_assert(sizeof(DeviceSettings) == 0x160, "DeviceSettings has the wrong size!");
50
51DeviceSettings DefaultDeviceSettings();
52
53} // namespace Service::Set
diff --git a/src/core/hle/service/set/private_settings.cpp b/src/core/hle/service/set/private_settings.cpp
new file mode 100755
index 000000000..70bf65727
--- /dev/null
+++ b/src/core/hle/service/set/private_settings.cpp
@@ -0,0 +1,12 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/service/set/private_settings.h"
5
6namespace Service::Set {
7
8PrivateSettings DefaultPrivateSettings() {
9 return {};
10}
11
12} // namespace Service::Set
diff --git a/src/core/hle/service/set/private_settings.h b/src/core/hle/service/set/private_settings.h
new file mode 100755
index 000000000..b63eaf45c
--- /dev/null
+++ b/src/core/hle/service/set/private_settings.h
@@ -0,0 +1,72 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include <array>
7
8#include "common/bit_field.h"
9#include "common/common_funcs.h"
10#include "common/common_types.h"
11#include "common/uuid.h"
12#include "core/hle/service/time/clock_types.h"
13
14namespace Service::Set {
15
16/// This is nn::settings::system::InitialLaunchFlag
17struct InitialLaunchFlag {
18 union {
19 u32 raw{};
20
21 BitField<0, 1, u32> InitialLaunchCompletionFlag;
22 BitField<8, 1, u32> InitialLaunchUserAdditionFlag;
23 BitField<16, 1, u32> InitialLaunchTimestampFlag;
24 };
25};
26static_assert(sizeof(InitialLaunchFlag) == 4, "InitialLaunchFlag is an invalid size");
27
28/// This is nn::settings::system::InitialLaunchSettings
29struct InitialLaunchSettings {
30 InitialLaunchFlag flags;
31 INSERT_PADDING_BYTES(0x4);
32 Service::Time::Clock::SteadyClockTimePoint timestamp;
33};
34static_assert(sizeof(InitialLaunchSettings) == 0x20, "InitialLaunchSettings is incorrect size");
35
36#pragma pack(push, 4)
37struct InitialLaunchSettingsPacked {
38 InitialLaunchFlag flags;
39 Service::Time::Clock::SteadyClockTimePoint timestamp;
40};
41#pragma pack(pop)
42static_assert(sizeof(InitialLaunchSettingsPacked) == 0x1C,
43 "InitialLaunchSettingsPacked is incorrect size");
44
45struct PrivateSettings {
46 std::array<u8, 0x10> reserved_00;
47
48 // nn::settings::system::InitialLaunchSettings
49 InitialLaunchSettings initial_launch_settings;
50
51 std::array<u8, 0x20> reserved_30;
52
53 Common::UUID external_clock_source_id;
54 s64 shutdown_rtc_value;
55 s64 external_steady_clock_internal_offset;
56
57 std::array<u8, 0x60> reserved_70;
58
59 // nn::settings::system::PlatformRegion
60 std::array<u8, 0x4> platform_region;
61
62 std::array<u8, 0x4> reserved_D4;
63};
64static_assert(offsetof(PrivateSettings, initial_launch_settings) == 0x10);
65static_assert(offsetof(PrivateSettings, external_clock_source_id) == 0x50);
66static_assert(offsetof(PrivateSettings, reserved_70) == 0x70);
67static_assert(offsetof(PrivateSettings, platform_region) == 0xD0);
68static_assert(sizeof(PrivateSettings) == 0xD8, "PrivateSettings has the wrong size!");
69
70PrivateSettings DefaultPrivateSettings();
71
72} // namespace Service::Set
diff --git a/src/core/hle/service/set/set.h b/src/core/hle/service/set/set.h
index 1d2aa8caa..ebbf807ac 100755
--- a/src/core/hle/service/set/set.h
+++ b/src/core/hle/service/set/set.h
@@ -4,35 +4,13 @@
4#pragma once 4#pragma once
5 5
6#include "core/hle/service/service.h" 6#include "core/hle/service/service.h"
7#include "core/hle/service/set/system_settings.h"
7 8
8namespace Core { 9namespace Core {
9class System; 10class System;
10} 11}
11 12
12namespace Service::Set { 13namespace Service::Set {
13
14/// This is "nn::settings::LanguageCode", which is a NUL-terminated string stored in a u64.
15enum class LanguageCode : u64 {
16 JA = 0x000000000000616A,
17 EN_US = 0x00000053552D6E65,
18 FR = 0x0000000000007266,
19 DE = 0x0000000000006564,
20 IT = 0x0000000000007469,
21 ES = 0x0000000000007365,
22 ZH_CN = 0x0000004E432D687A,
23 KO = 0x0000000000006F6B,
24 NL = 0x0000000000006C6E,
25 PT = 0x0000000000007470,
26 RU = 0x0000000000007572,
27 ZH_TW = 0x00000057542D687A,
28 EN_GB = 0x00000042472D6E65,
29 FR_CA = 0x00000041432D7266,
30 ES_419 = 0x00003931342D7365,
31 ZH_HANS = 0x00736E61482D687A,
32 ZH_HANT = 0x00746E61482D687A,
33 PT_BR = 0x00000052422D7470,
34};
35
36enum class KeyboardLayout : u64 { 14enum class KeyboardLayout : u64 {
37 Japanese = 0, 15 Japanese = 0,
38 EnglishUs = 1, 16 EnglishUs = 1,
diff --git a/src/core/hle/service/set/set_sys.cpp b/src/core/hle/service/set/set_sys.cpp
index d0527ad07..53328a5e0 100755
--- a/src/core/hle/service/set/set_sys.cpp
+++ b/src/core/hle/service/set/set_sys.cpp
@@ -1,8 +1,14 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project 1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later 2// SPDX-License-Identifier: GPL-2.0-or-later
3 3
4#include <fstream>
5
4#include "common/assert.h" 6#include "common/assert.h"
7#include "common/fs/file.h"
8#include "common/fs/fs.h"
9#include "common/fs/path_util.h"
5#include "common/logging/log.h" 10#include "common/logging/log.h"
11#include "common/polyfill_thread.h"
6#include "common/settings.h" 12#include "common/settings.h"
7#include "common/string_util.h" 13#include "common/string_util.h"
8#include "core/core.h" 14#include "core/core.h"
@@ -19,6 +25,16 @@
19 25
20namespace Service::Set { 26namespace Service::Set {
21 27
28namespace {
29constexpr u32 SETTINGS_VERSION{1u};
30constexpr auto SETTINGS_MAGIC = Common::MakeMagic('y', 'u', 'z', 'u', '_', 's', 'e', 't');
31struct SettingsHeader {
32 u64 magic;
33 u32 version;
34 u32 reserved;
35};
36} // Anonymous namespace
37
22Result GetFirmwareVersionImpl(FirmwareVersionFormat& out_firmware, Core::System& system, 38Result GetFirmwareVersionImpl(FirmwareVersionFormat& out_firmware, Core::System& system,
23 GetFirmwareVersionType type) { 39 GetFirmwareVersionType type) {
24 constexpr u64 FirmwareVersionSystemDataId = 0x0100000000000809; 40 constexpr u64 FirmwareVersionSystemDataId = 0x0100000000000809;
@@ -72,11 +88,120 @@ Result GetFirmwareVersionImpl(FirmwareVersionFormat& out_firmware, Core::System&
72 return ResultSuccess; 88 return ResultSuccess;
73} 89}
74 90
91bool SET_SYS::LoadSettingsFile(std::filesystem::path& path, auto&& default_func) {
92 using settings_type = decltype(default_func());
93
94 if (!Common::FS::CreateDirs(path)) {
95 return false;
96 }
97
98 auto settings_file = path / "settings.dat";
99 auto exists = std::filesystem::exists(settings_file);
100 auto file_size_ok = exists && std::filesystem::file_size(settings_file) ==
101 sizeof(SettingsHeader) + sizeof(settings_type);
102
103 auto ResetToDefault = [&]() {
104 auto default_settings{default_func()};
105
106 SettingsHeader hdr{
107 .magic = SETTINGS_MAGIC,
108 .version = SETTINGS_VERSION,
109 .reserved = 0u,
110 };
111
112 std::ofstream out_settings_file(settings_file, std::ios::out | std::ios::binary);
113 out_settings_file.write(reinterpret_cast<const char*>(&hdr), sizeof(hdr));
114 out_settings_file.write(reinterpret_cast<const char*>(&default_settings),
115 sizeof(settings_type));
116 out_settings_file.flush();
117 out_settings_file.close();
118 };
119
120 constexpr auto IsHeaderValid = [](std::ifstream& file) -> bool {
121 if (!file.is_open()) {
122 return false;
123 }
124 SettingsHeader hdr{};
125 file.read(reinterpret_cast<char*>(&hdr), sizeof(hdr));
126 return hdr.magic == SETTINGS_MAGIC && hdr.version == SETTINGS_VERSION;
127 };
128
129 if (!exists || !file_size_ok) {
130 ResetToDefault();
131 }
132
133 std::ifstream file(settings_file, std::ios::binary | std::ios::in);
134 if (!IsHeaderValid(file)) {
135 file.close();
136 ResetToDefault();
137 file = std::ifstream(settings_file, std::ios::binary | std::ios::in);
138 if (!IsHeaderValid(file)) {
139 return false;
140 }
141 }
142
143 if constexpr (std::is_same_v<settings_type, PrivateSettings>) {
144 file.read(reinterpret_cast<char*>(&m_private_settings), sizeof(settings_type));
145 } else if constexpr (std::is_same_v<settings_type, DeviceSettings>) {
146 file.read(reinterpret_cast<char*>(&m_device_settings), sizeof(settings_type));
147 } else if constexpr (std::is_same_v<settings_type, ApplnSettings>) {
148 file.read(reinterpret_cast<char*>(&m_appln_settings), sizeof(settings_type));
149 } else if constexpr (std::is_same_v<settings_type, SystemSettings>) {
150 file.read(reinterpret_cast<char*>(&m_system_settings), sizeof(settings_type));
151 } else {
152 UNREACHABLE();
153 }
154 file.close();
155
156 return true;
157}
158
159bool SET_SYS::StoreSettingsFile(std::filesystem::path& path, auto& settings) {
160 using settings_type = std::decay_t<decltype(settings)>;
161
162 if (!Common::FS::IsDir(path)) {
163 return false;
164 }
165
166 auto settings_base = path / "settings";
167 auto settings_tmp_file = settings_base;
168 settings_tmp_file = settings_tmp_file.replace_extension("tmp");
169 std::ofstream file(settings_tmp_file, std::ios::binary | std::ios::out);
170 if (!file.is_open()) {
171 return false;
172 }
173
174 SettingsHeader hdr{
175 .magic = SETTINGS_MAGIC,
176 .version = SETTINGS_VERSION,
177 .reserved = 0u,
178 };
179 file.write(reinterpret_cast<const char*>(&hdr), sizeof(hdr));
180
181 if constexpr (std::is_same_v<settings_type, PrivateSettings>) {
182 file.write(reinterpret_cast<const char*>(&m_private_settings), sizeof(settings_type));
183 } else if constexpr (std::is_same_v<settings_type, DeviceSettings>) {
184 file.write(reinterpret_cast<const char*>(&m_device_settings), sizeof(settings_type));
185 } else if constexpr (std::is_same_v<settings_type, ApplnSettings>) {
186 file.write(reinterpret_cast<const char*>(&m_appln_settings), sizeof(settings_type));
187 } else if constexpr (std::is_same_v<settings_type, SystemSettings>) {
188 file.write(reinterpret_cast<const char*>(&m_system_settings), sizeof(settings_type));
189 } else {
190 UNREACHABLE();
191 }
192 file.close();
193
194 std::filesystem::rename(settings_tmp_file, settings_base.replace_extension("dat"));
195
196 return true;
197}
198
75void SET_SYS::SetLanguageCode(HLERequestContext& ctx) { 199void SET_SYS::SetLanguageCode(HLERequestContext& ctx) {
76 IPC::RequestParser rp{ctx}; 200 IPC::RequestParser rp{ctx};
77 language_code_setting = rp.PopEnum<LanguageCode>(); 201 m_system_settings.language_code = rp.PopEnum<LanguageCode>();
202 SetSaveNeeded();
78 203
79 LOG_INFO(Service_SET, "called, language_code={}", language_code_setting); 204 LOG_INFO(Service_SET, "called, language_code={}", m_system_settings.language_code);
80 205
81 IPC::ResponseBuilder rb{ctx, 2}; 206 IPC::ResponseBuilder rb{ctx, 2};
82 rb.Push(ResultSuccess); 207 rb.Push(ResultSuccess);
@@ -112,19 +237,68 @@ void SET_SYS::GetFirmwareVersion2(HLERequestContext& ctx) {
112 rb.Push(result); 237 rb.Push(result);
113} 238}
114 239
240void SET_SYS::GetExternalSteadyClockSourceId(HLERequestContext& ctx) {
241 LOG_INFO(Service_SET, "called");
242
243 Common::UUID id{};
244 auto res = GetExternalSteadyClockSourceId(id);
245
246 IPC::ResponseBuilder rb{ctx, 2 + sizeof(Common::UUID) / sizeof(u32)};
247 rb.Push(res);
248 rb.PushRaw(id);
249}
250
251void SET_SYS::SetExternalSteadyClockSourceId(HLERequestContext& ctx) {
252 LOG_INFO(Service_SET, "called");
253
254 IPC::RequestParser rp{ctx};
255 auto id{rp.PopRaw<Common::UUID>()};
256
257 auto res = SetExternalSteadyClockSourceId(id);
258
259 IPC::ResponseBuilder rb{ctx, 2};
260 rb.Push(res);
261}
262
263void SET_SYS::GetUserSystemClockContext(HLERequestContext& ctx) {
264 LOG_INFO(Service_SET, "called");
265
266 Service::Time::Clock::SystemClockContext context{};
267 auto res = GetUserSystemClockContext(context);
268
269 IPC::ResponseBuilder rb{ctx,
270 2 + sizeof(Service::Time::Clock::SystemClockContext) / sizeof(u32)};
271 rb.Push(res);
272 rb.PushRaw(context);
273}
274
275void SET_SYS::SetUserSystemClockContext(HLERequestContext& ctx) {
276 LOG_INFO(Service_SET, "called");
277
278 IPC::RequestParser rp{ctx};
279 auto context{rp.PopRaw<Service::Time::Clock::SystemClockContext>()};
280
281 auto res = SetUserSystemClockContext(context);
282
283 IPC::ResponseBuilder rb{ctx, 2};
284 rb.Push(res);
285}
286
115void SET_SYS::GetAccountSettings(HLERequestContext& ctx) { 287void SET_SYS::GetAccountSettings(HLERequestContext& ctx) {
116 LOG_INFO(Service_SET, "called"); 288 LOG_INFO(Service_SET, "called");
117 289
118 IPC::ResponseBuilder rb{ctx, 3}; 290 IPC::ResponseBuilder rb{ctx, 3};
119 rb.Push(ResultSuccess); 291 rb.Push(ResultSuccess);
120 rb.PushRaw(account_settings); 292 rb.PushRaw(m_system_settings.account_settings);
121} 293}
122 294
123void SET_SYS::SetAccountSettings(HLERequestContext& ctx) { 295void SET_SYS::SetAccountSettings(HLERequestContext& ctx) {
124 IPC::RequestParser rp{ctx}; 296 IPC::RequestParser rp{ctx};
125 account_settings = rp.PopRaw<AccountSettings>(); 297 m_system_settings.account_settings = rp.PopRaw<AccountSettings>();
298 SetSaveNeeded();
126 299
127 LOG_INFO(Service_SET, "called, account_settings_flags={}", account_settings.flags); 300 LOG_INFO(Service_SET, "called, account_settings_flags={}",
301 m_system_settings.account_settings.flags);
128 302
129 IPC::ResponseBuilder rb{ctx, 2}; 303 IPC::ResponseBuilder rb{ctx, 2};
130 rb.Push(ResultSuccess); 304 rb.Push(ResultSuccess);
@@ -133,11 +307,11 @@ void SET_SYS::SetAccountSettings(HLERequestContext& ctx) {
133void SET_SYS::GetEulaVersions(HLERequestContext& ctx) { 307void SET_SYS::GetEulaVersions(HLERequestContext& ctx) {
134 LOG_INFO(Service_SET, "called"); 308 LOG_INFO(Service_SET, "called");
135 309
136 ctx.WriteBuffer(eula_versions); 310 ctx.WriteBuffer(m_system_settings.eula_versions);
137 311
138 IPC::ResponseBuilder rb{ctx, 3}; 312 IPC::ResponseBuilder rb{ctx, 3};
139 rb.Push(ResultSuccess); 313 rb.Push(ResultSuccess);
140 rb.Push(static_cast<u32>(eula_versions.size())); 314 rb.Push(m_system_settings.eula_version_count);
141} 315}
142 316
143void SET_SYS::SetEulaVersions(HLERequestContext& ctx) { 317void SET_SYS::SetEulaVersions(HLERequestContext& ctx) {
@@ -145,13 +319,12 @@ void SET_SYS::SetEulaVersions(HLERequestContext& ctx) {
145 const auto buffer_data = ctx.ReadBuffer(); 319 const auto buffer_data = ctx.ReadBuffer();
146 320
147 LOG_INFO(Service_SET, "called, elements={}", elements); 321 LOG_INFO(Service_SET, "called, elements={}", elements);
322 ASSERT(elements <= m_system_settings.eula_versions.size());
148 323
149 eula_versions.resize(elements); 324 m_system_settings.eula_version_count = static_cast<u32>(elements);
150 for (std::size_t index = 0; index < elements; index++) { 325 std::memcpy(&m_system_settings.eula_versions, buffer_data.data(),
151 const std::size_t start_index = index * sizeof(EulaVersion); 326 sizeof(EulaVersion) * elements);
152 memcpy(eula_versions.data() + start_index, buffer_data.data() + start_index, 327 SetSaveNeeded();
153 sizeof(EulaVersion));
154 }
155 328
156 IPC::ResponseBuilder rb{ctx, 2}; 329 IPC::ResponseBuilder rb{ctx, 2};
157 rb.Push(ResultSuccess); 330 rb.Push(ResultSuccess);
@@ -162,14 +335,15 @@ void SET_SYS::GetColorSetId(HLERequestContext& ctx) {
162 335
163 IPC::ResponseBuilder rb{ctx, 3}; 336 IPC::ResponseBuilder rb{ctx, 3};
164 rb.Push(ResultSuccess); 337 rb.Push(ResultSuccess);
165 rb.PushEnum(color_set); 338 rb.PushEnum(m_system_settings.color_set_id);
166} 339}
167 340
168void SET_SYS::SetColorSetId(HLERequestContext& ctx) { 341void SET_SYS::SetColorSetId(HLERequestContext& ctx) {
169 IPC::RequestParser rp{ctx}; 342 IPC::RequestParser rp{ctx};
170 color_set = rp.PopEnum<ColorSet>(); 343 m_system_settings.color_set_id = rp.PopEnum<ColorSet>();
344 SetSaveNeeded();
171 345
172 LOG_DEBUG(Service_SET, "called, color_set={}", color_set); 346 LOG_DEBUG(Service_SET, "called, color_set={}", m_system_settings.color_set_id);
173 347
174 IPC::ResponseBuilder rb{ctx, 2}; 348 IPC::ResponseBuilder rb{ctx, 2};
175 rb.Push(ResultSuccess); 349 rb.Push(ResultSuccess);
@@ -180,17 +354,21 @@ void SET_SYS::GetNotificationSettings(HLERequestContext& ctx) {
180 354
181 IPC::ResponseBuilder rb{ctx, 8}; 355 IPC::ResponseBuilder rb{ctx, 8};
182 rb.Push(ResultSuccess); 356 rb.Push(ResultSuccess);
183 rb.PushRaw(notification_settings); 357 rb.PushRaw(m_system_settings.notification_settings);
184} 358}
185 359
186void SET_SYS::SetNotificationSettings(HLERequestContext& ctx) { 360void SET_SYS::SetNotificationSettings(HLERequestContext& ctx) {
187 IPC::RequestParser rp{ctx}; 361 IPC::RequestParser rp{ctx};
188 notification_settings = rp.PopRaw<NotificationSettings>(); 362 m_system_settings.notification_settings = rp.PopRaw<NotificationSettings>();
363 SetSaveNeeded();
189 364
190 LOG_INFO(Service_SET, "called, flags={}, volume={}, head_time={}:{}, tailt_time={}:{}", 365 LOG_INFO(Service_SET, "called, flags={}, volume={}, head_time={}:{}, tailt_time={}:{}",
191 notification_settings.flags.raw, notification_settings.volume, 366 m_system_settings.notification_settings.flags.raw,
192 notification_settings.start_time.hour, notification_settings.start_time.minute, 367 m_system_settings.notification_settings.volume,
193 notification_settings.stop_time.hour, notification_settings.stop_time.minute); 368 m_system_settings.notification_settings.start_time.hour,
369 m_system_settings.notification_settings.start_time.minute,
370 m_system_settings.notification_settings.stop_time.hour,
371 m_system_settings.notification_settings.stop_time.minute);
194 372
195 IPC::ResponseBuilder rb{ctx, 2}; 373 IPC::ResponseBuilder rb{ctx, 2};
196 rb.Push(ResultSuccess); 374 rb.Push(ResultSuccess);
@@ -199,11 +377,11 @@ void SET_SYS::SetNotificationSettings(HLERequestContext& ctx) {
199void SET_SYS::GetAccountNotificationSettings(HLERequestContext& ctx) { 377void SET_SYS::GetAccountNotificationSettings(HLERequestContext& ctx) {
200 LOG_INFO(Service_SET, "called"); 378 LOG_INFO(Service_SET, "called");
201 379
202 ctx.WriteBuffer(account_notifications); 380 ctx.WriteBuffer(m_system_settings.account_notification_settings);
203 381
204 IPC::ResponseBuilder rb{ctx, 3}; 382 IPC::ResponseBuilder rb{ctx, 3};
205 rb.Push(ResultSuccess); 383 rb.Push(ResultSuccess);
206 rb.Push(static_cast<u32>(account_notifications.size())); 384 rb.Push(m_system_settings.account_notification_settings_count);
207} 385}
208 386
209void SET_SYS::SetAccountNotificationSettings(HLERequestContext& ctx) { 387void SET_SYS::SetAccountNotificationSettings(HLERequestContext& ctx) {
@@ -212,12 +390,12 @@ void SET_SYS::SetAccountNotificationSettings(HLERequestContext& ctx) {
212 390
213 LOG_INFO(Service_SET, "called, elements={}", elements); 391 LOG_INFO(Service_SET, "called, elements={}", elements);
214 392
215 account_notifications.resize(elements); 393 ASSERT(elements <= m_system_settings.account_notification_settings.size());
216 for (std::size_t index = 0; index < elements; index++) { 394
217 const std::size_t start_index = index * sizeof(AccountNotificationSettings); 395 m_system_settings.account_notification_settings_count = static_cast<u32>(elements);
218 memcpy(account_notifications.data() + start_index, buffer_data.data() + start_index, 396 std::memcpy(&m_system_settings.account_notification_settings, buffer_data.data(),
219 sizeof(AccountNotificationSettings)); 397 elements * sizeof(AccountNotificationSettings));
220 } 398 SetSaveNeeded();
221 399
222 IPC::ResponseBuilder rb{ctx, 2}; 400 IPC::ResponseBuilder rb{ctx, 2};
223 rb.Push(ResultSuccess); 401 rb.Push(ResultSuccess);
@@ -244,6 +422,14 @@ static Settings GetSettings() {
244 ret["hbloader"]["applet_heap_size"] = ToBytes(u64{0x0}); 422 ret["hbloader"]["applet_heap_size"] = ToBytes(u64{0x0});
245 ret["hbloader"]["applet_heap_reservation_size"] = ToBytes(u64{0x8600000}); 423 ret["hbloader"]["applet_heap_reservation_size"] = ToBytes(u64{0x8600000});
246 424
425 // Time
426 ret["time"]["notify_time_to_fs_interval_seconds"] = ToBytes(s32{600});
427 ret["time"]["standard_network_clock_sufficient_accuracy_minutes"] =
428 ToBytes(s32{43200}); // 30 days
429 ret["time"]["standard_steady_clock_rtc_update_interval_minutes"] = ToBytes(s32{5});
430 ret["time"]["standard_steady_clock_test_offset_minutes"] = ToBytes(s32{0});
431 ret["time"]["standard_user_clock_initial_year"] = ToBytes(s32{2023});
432
247 return ret; 433 return ret;
248} 434}
249 435
@@ -273,8 +459,6 @@ void SET_SYS::GetSettingsItemValueSize(HLERequestContext& ctx) {
273} 459}
274 460
275void SET_SYS::GetSettingsItemValue(HLERequestContext& ctx) { 461void SET_SYS::GetSettingsItemValue(HLERequestContext& ctx) {
276 LOG_DEBUG(Service_SET, "called");
277
278 // The category of the setting. This corresponds to the top-level keys of 462 // The category of the setting. This corresponds to the top-level keys of
279 // system_settings.ini. 463 // system_settings.ini.
280 const auto setting_category_buf{ctx.ReadBuffer(0)}; 464 const auto setting_category_buf{ctx.ReadBuffer(0)};
@@ -285,14 +469,13 @@ void SET_SYS::GetSettingsItemValue(HLERequestContext& ctx) {
285 const auto setting_name_buf{ctx.ReadBuffer(1)}; 469 const auto setting_name_buf{ctx.ReadBuffer(1)};
286 const std::string setting_name{setting_name_buf.begin(), setting_name_buf.end()}; 470 const std::string setting_name{setting_name_buf.begin(), setting_name_buf.end()};
287 471
288 auto settings{GetSettings()}; 472 std::vector<u8> value;
289 Result response{ResultUnknown}; 473 auto response = GetSettingsItemValue(value, setting_category, setting_name);
290 474
291 if (settings.contains(setting_category) && settings[setting_category].contains(setting_name)) { 475 LOG_INFO(Service_SET, "called. category={}, name={} -- res=0x{:X}", setting_category,
292 auto setting_value = settings[setting_category][setting_name]; 476 setting_name, response.raw);
293 ctx.WriteBuffer(setting_value.data(), setting_value.size()); 477
294 response = ResultSuccess; 478 ctx.WriteBuffer(value.data(), value.size());
295 }
296 479
297 IPC::ResponseBuilder rb{ctx, 2}; 480 IPC::ResponseBuilder rb{ctx, 2};
298 rb.Push(response); 481 rb.Push(response);
@@ -303,19 +486,23 @@ void SET_SYS::GetTvSettings(HLERequestContext& ctx) {
303 486
304 IPC::ResponseBuilder rb{ctx, 10}; 487 IPC::ResponseBuilder rb{ctx, 10};
305 rb.Push(ResultSuccess); 488 rb.Push(ResultSuccess);
306 rb.PushRaw(tv_settings); 489 rb.PushRaw(m_system_settings.tv_settings);
307} 490}
308 491
309void SET_SYS::SetTvSettings(HLERequestContext& ctx) { 492void SET_SYS::SetTvSettings(HLERequestContext& ctx) {
310 IPC::RequestParser rp{ctx}; 493 IPC::RequestParser rp{ctx};
311 tv_settings = rp.PopRaw<TvSettings>(); 494 m_system_settings.tv_settings = rp.PopRaw<TvSettings>();
495 SetSaveNeeded();
312 496
313 LOG_INFO(Service_SET, 497 LOG_INFO(Service_SET,
314 "called, flags={}, cmu_mode={}, constrast_ratio={}, hdmi_content_type={}, " 498 "called, flags={}, cmu_mode={}, constrast_ratio={}, hdmi_content_type={}, "
315 "rgb_range={}, tv_gama={}, tv_resolution={}, tv_underscan={}", 499 "rgb_range={}, tv_gama={}, tv_resolution={}, tv_underscan={}",
316 tv_settings.flags.raw, tv_settings.cmu_mode, tv_settings.constrast_ratio, 500 m_system_settings.tv_settings.flags.raw, m_system_settings.tv_settings.cmu_mode,
317 tv_settings.hdmi_content_type, tv_settings.rgb_range, tv_settings.tv_gama, 501 m_system_settings.tv_settings.constrast_ratio,
318 tv_settings.tv_resolution, tv_settings.tv_underscan); 502 m_system_settings.tv_settings.hdmi_content_type,
503 m_system_settings.tv_settings.rgb_range, m_system_settings.tv_settings.tv_gama,
504 m_system_settings.tv_settings.tv_resolution,
505 m_system_settings.tv_settings.tv_underscan);
319 506
320 IPC::ResponseBuilder rb{ctx, 2}; 507 IPC::ResponseBuilder rb{ctx, 2};
321 rb.Push(ResultSuccess); 508 rb.Push(ResultSuccess);
@@ -329,16 +516,87 @@ void SET_SYS::GetQuestFlag(HLERequestContext& ctx) {
329 rb.PushEnum(QuestFlag::Retail); 516 rb.PushEnum(QuestFlag::Retail);
330} 517}
331 518
519void SET_SYS::GetDeviceTimeZoneLocationName(HLERequestContext& ctx) {
520 LOG_WARNING(Service_SET, "called");
521
522 Service::Time::TimeZone::LocationName name{};
523 auto res = GetDeviceTimeZoneLocationName(name);
524
525 IPC::ResponseBuilder rb{ctx, 2 + sizeof(Service::Time::TimeZone::LocationName) / sizeof(u32)};
526 rb.Push(res);
527 rb.PushRaw<Service::Time::TimeZone::LocationName>(name);
528}
529
530void SET_SYS::SetDeviceTimeZoneLocationName(HLERequestContext& ctx) {
531 LOG_WARNING(Service_SET, "called");
532
533 IPC::RequestParser rp{ctx};
534 auto name{rp.PopRaw<Service::Time::TimeZone::LocationName>()};
535
536 auto res = SetDeviceTimeZoneLocationName(name);
537
538 IPC::ResponseBuilder rb{ctx, 2};
539 rb.Push(res);
540}
541
332void SET_SYS::SetRegionCode(HLERequestContext& ctx) { 542void SET_SYS::SetRegionCode(HLERequestContext& ctx) {
333 IPC::RequestParser rp{ctx}; 543 IPC::RequestParser rp{ctx};
334 region_code = rp.PopEnum<RegionCode>(); 544 m_system_settings.region_code = rp.PopEnum<RegionCode>();
545 SetSaveNeeded();
335 546
336 LOG_INFO(Service_SET, "called, region_code={}", region_code); 547 LOG_INFO(Service_SET, "called, region_code={}", m_system_settings.region_code);
337 548
338 IPC::ResponseBuilder rb{ctx, 2}; 549 IPC::ResponseBuilder rb{ctx, 2};
339 rb.Push(ResultSuccess); 550 rb.Push(ResultSuccess);
340} 551}
341 552
553void SET_SYS::GetNetworkSystemClockContext(HLERequestContext& ctx) {
554 LOG_INFO(Service_SET, "called");
555
556 Service::Time::Clock::SystemClockContext context{};
557 auto res = GetNetworkSystemClockContext(context);
558
559 IPC::ResponseBuilder rb{ctx,
560 2 + sizeof(Service::Time::Clock::SystemClockContext) / sizeof(u32)};
561 rb.Push(res);
562 rb.PushRaw(context);
563}
564
565void SET_SYS::SetNetworkSystemClockContext(HLERequestContext& ctx) {
566 LOG_INFO(Service_SET, "called");
567
568 IPC::RequestParser rp{ctx};
569 auto context{rp.PopRaw<Service::Time::Clock::SystemClockContext>()};
570
571 auto res = SetNetworkSystemClockContext(context);
572
573 IPC::ResponseBuilder rb{ctx, 2};
574 rb.Push(res);
575}
576
577void SET_SYS::IsUserSystemClockAutomaticCorrectionEnabled(HLERequestContext& ctx) {
578 LOG_INFO(Service_SET, "called");
579
580 bool enabled{};
581 auto res = IsUserSystemClockAutomaticCorrectionEnabled(enabled);
582
583 IPC::ResponseBuilder rb{ctx, 3};
584 rb.Push(res);
585 rb.PushRaw(enabled);
586}
587
588void SET_SYS::SetUserSystemClockAutomaticCorrectionEnabled(HLERequestContext& ctx) {
589 LOG_INFO(Service_SET, "called");
590
591 IPC::RequestParser rp{ctx};
592 auto enabled{rp.Pop<bool>()};
593
594 auto res = SetUserSystemClockAutomaticCorrectionEnabled(enabled);
595
596 IPC::ResponseBuilder rb{ctx, 2};
597 rb.Push(res);
598}
599
342void SET_SYS::GetPrimaryAlbumStorage(HLERequestContext& ctx) { 600void SET_SYS::GetPrimaryAlbumStorage(HLERequestContext& ctx) {
343 LOG_WARNING(Service_SET, "(STUBBED) called"); 601 LOG_WARNING(Service_SET, "(STUBBED) called");
344 602
@@ -352,16 +610,18 @@ void SET_SYS::GetSleepSettings(HLERequestContext& ctx) {
352 610
353 IPC::ResponseBuilder rb{ctx, 5}; 611 IPC::ResponseBuilder rb{ctx, 5};
354 rb.Push(ResultSuccess); 612 rb.Push(ResultSuccess);
355 rb.PushRaw(sleep_settings); 613 rb.PushRaw(m_system_settings.sleep_settings);
356} 614}
357 615
358void SET_SYS::SetSleepSettings(HLERequestContext& ctx) { 616void SET_SYS::SetSleepSettings(HLERequestContext& ctx) {
359 IPC::RequestParser rp{ctx}; 617 IPC::RequestParser rp{ctx};
360 sleep_settings = rp.PopRaw<SleepSettings>(); 618 m_system_settings.sleep_settings = rp.PopRaw<SleepSettings>();
619 SetSaveNeeded();
361 620
362 LOG_INFO(Service_SET, "called, flags={}, handheld_sleep_plan={}, console_sleep_plan={}", 621 LOG_INFO(Service_SET, "called, flags={}, handheld_sleep_plan={}, console_sleep_plan={}",
363 sleep_settings.flags.raw, sleep_settings.handheld_sleep_plan, 622 m_system_settings.sleep_settings.flags.raw,
364 sleep_settings.console_sleep_plan); 623 m_system_settings.sleep_settings.handheld_sleep_plan,
624 m_system_settings.sleep_settings.console_sleep_plan);
365 625
366 IPC::ResponseBuilder rb{ctx, 2}; 626 IPC::ResponseBuilder rb{ctx, 2};
367 rb.Push(ResultSuccess); 627 rb.Push(ResultSuccess);
@@ -371,15 +631,20 @@ void SET_SYS::GetInitialLaunchSettings(HLERequestContext& ctx) {
371 LOG_INFO(Service_SET, "called"); 631 LOG_INFO(Service_SET, "called");
372 IPC::ResponseBuilder rb{ctx, 10}; 632 IPC::ResponseBuilder rb{ctx, 10};
373 rb.Push(ResultSuccess); 633 rb.Push(ResultSuccess);
374 rb.PushRaw(launch_settings); 634 rb.PushRaw(m_system_settings.initial_launch_settings_packed);
375} 635}
376 636
377void SET_SYS::SetInitialLaunchSettings(HLERequestContext& ctx) { 637void SET_SYS::SetInitialLaunchSettings(HLERequestContext& ctx) {
378 IPC::RequestParser rp{ctx}; 638 IPC::RequestParser rp{ctx};
379 launch_settings = rp.PopRaw<InitialLaunchSettings>(); 639 auto inital_launch_settings = rp.PopRaw<InitialLaunchSettings>();
640
641 m_system_settings.initial_launch_settings_packed.flags = inital_launch_settings.flags;
642 m_system_settings.initial_launch_settings_packed.timestamp = inital_launch_settings.timestamp;
643 SetSaveNeeded();
380 644
381 LOG_INFO(Service_SET, "called, flags={}, timestamp={}", launch_settings.flags.raw, 645 LOG_INFO(Service_SET, "called, flags={}, timestamp={}",
382 launch_settings.timestamp.time_point); 646 m_system_settings.initial_launch_settings_packed.flags.raw,
647 m_system_settings.initial_launch_settings_packed.timestamp.time_point);
383 648
384 IPC::ResponseBuilder rb{ctx, 2}; 649 IPC::ResponseBuilder rb{ctx, 2};
385 rb.Push(ResultSuccess); 650 rb.Push(ResultSuccess);
@@ -437,13 +702,37 @@ void SET_SYS::GetAutoUpdateEnableFlag(HLERequestContext& ctx) {
437void SET_SYS::GetBatteryPercentageFlag(HLERequestContext& ctx) { 702void SET_SYS::GetBatteryPercentageFlag(HLERequestContext& ctx) {
438 u8 battery_percentage_flag{1}; 703 u8 battery_percentage_flag{1};
439 704
440 LOG_DEBUG(Service_SET, "(STUBBED) called, battery_percentage_flag={}", battery_percentage_flag); 705 LOG_WARNING(Service_SET, "(STUBBED) called, battery_percentage_flag={}",
706 battery_percentage_flag);
441 707
442 IPC::ResponseBuilder rb{ctx, 3}; 708 IPC::ResponseBuilder rb{ctx, 3};
443 rb.Push(ResultSuccess); 709 rb.Push(ResultSuccess);
444 rb.Push(battery_percentage_flag); 710 rb.Push(battery_percentage_flag);
445} 711}
446 712
713void SET_SYS::SetExternalSteadyClockInternalOffset(HLERequestContext& ctx) {
714 LOG_DEBUG(Service_SET, "called.");
715
716 IPC::RequestParser rp{ctx};
717 auto offset{rp.Pop<s64>()};
718
719 auto res = SetExternalSteadyClockInternalOffset(offset);
720
721 IPC::ResponseBuilder rb{ctx, 2};
722 rb.Push(res);
723}
724
725void SET_SYS::GetExternalSteadyClockInternalOffset(HLERequestContext& ctx) {
726 LOG_DEBUG(Service_SET, "called.");
727
728 s64 offset{};
729 auto res = GetExternalSteadyClockInternalOffset(offset);
730
731 IPC::ResponseBuilder rb{ctx, 4};
732 rb.Push(res);
733 rb.Push(offset);
734}
735
447void SET_SYS::GetErrorReportSharePermission(HLERequestContext& ctx) { 736void SET_SYS::GetErrorReportSharePermission(HLERequestContext& ctx) {
448 LOG_WARNING(Service_SET, "(STUBBED) called"); 737 LOG_WARNING(Service_SET, "(STUBBED) called");
449 738
@@ -453,18 +742,19 @@ void SET_SYS::GetErrorReportSharePermission(HLERequestContext& ctx) {
453} 742}
454 743
455void SET_SYS::GetAppletLaunchFlags(HLERequestContext& ctx) { 744void SET_SYS::GetAppletLaunchFlags(HLERequestContext& ctx) {
456 LOG_INFO(Service_SET, "called, applet_launch_flag={}", applet_launch_flag); 745 LOG_INFO(Service_SET, "called, applet_launch_flag={}", m_system_settings.applet_launch_flag);
457 746
458 IPC::ResponseBuilder rb{ctx, 3}; 747 IPC::ResponseBuilder rb{ctx, 3};
459 rb.Push(ResultSuccess); 748 rb.Push(ResultSuccess);
460 rb.Push(applet_launch_flag); 749 rb.Push(m_system_settings.applet_launch_flag);
461} 750}
462 751
463void SET_SYS::SetAppletLaunchFlags(HLERequestContext& ctx) { 752void SET_SYS::SetAppletLaunchFlags(HLERequestContext& ctx) {
464 IPC::RequestParser rp{ctx}; 753 IPC::RequestParser rp{ctx};
465 applet_launch_flag = rp.Pop<u32>(); 754 m_system_settings.applet_launch_flag = rp.Pop<u32>();
755 SetSaveNeeded();
466 756
467 LOG_INFO(Service_SET, "called, applet_launch_flag={}", applet_launch_flag); 757 LOG_INFO(Service_SET, "called, applet_launch_flag={}", m_system_settings.applet_launch_flag);
468 758
469 IPC::ResponseBuilder rb{ctx, 2}; 759 IPC::ResponseBuilder rb{ctx, 2};
470 rb.Push(ResultSuccess); 760 rb.Push(ResultSuccess);
@@ -489,37 +779,60 @@ void SET_SYS::GetKeyboardLayout(HLERequestContext& ctx) {
489 rb.Push(static_cast<u32>(selected_keyboard_layout)); 779 rb.Push(static_cast<u32>(selected_keyboard_layout));
490} 780}
491 781
492void SET_SYS::GetChineseTraditionalInputMethod(HLERequestContext& ctx) { 782void SET_SYS::GetDeviceTimeZoneLocationUpdatedTime(HLERequestContext& ctx) {
493 LOG_WARNING(Service_SET, "(STUBBED) called"); 783 LOG_WARNING(Service_SET, "called.");
494 784
495 IPC::ResponseBuilder rb{ctx, 3}; 785 Service::Time::Clock::SteadyClockTimePoint time_point{};
496 rb.Push(ResultSuccess); 786 auto res = GetDeviceTimeZoneLocationUpdatedTime(time_point);
497 rb.PushEnum(ChineseTraditionalInputMethod::Unknown0); 787
788 IPC::ResponseBuilder rb{ctx, 4};
789 rb.Push(res);
790 rb.PushRaw<Service::Time::Clock::SteadyClockTimePoint>(time_point);
498} 791}
499 792
500void SET_SYS::GetHomeMenuScheme(HLERequestContext& ctx) { 793void SET_SYS::SetDeviceTimeZoneLocationUpdatedTime(HLERequestContext& ctx) {
501 LOG_DEBUG(Service_SET, "(STUBBED) called"); 794 LOG_WARNING(Service_SET, "called.");
502 795
503 const HomeMenuScheme default_color = { 796 IPC::RequestParser rp{ctx};
504 .main = 0xFF323232, 797 auto time_point{rp.PopRaw<Service::Time::Clock::SteadyClockTimePoint>()};
505 .back = 0xFF323232,
506 .sub = 0xFFFFFFFF,
507 .bezel = 0xFFFFFFFF,
508 .extra = 0xFF000000,
509 };
510 798
511 IPC::ResponseBuilder rb{ctx, 7}; 799 auto res = SetDeviceTimeZoneLocationUpdatedTime(time_point);
512 rb.Push(ResultSuccess); 800
513 rb.PushRaw(default_color); 801 IPC::ResponseBuilder rb{ctx, 2};
802 rb.Push(res);
514} 803}
515 804
516void SET_SYS::GetHomeMenuSchemeModel(HLERequestContext& ctx) { 805void SET_SYS::GetUserSystemClockAutomaticCorrectionUpdatedTime(HLERequestContext& ctx) {
806 LOG_WARNING(Service_SET, "called.");
807
808 Service::Time::Clock::SteadyClockTimePoint time_point{};
809 auto res = GetUserSystemClockAutomaticCorrectionUpdatedTime(time_point);
810
811 IPC::ResponseBuilder rb{ctx, 4};
812 rb.Push(res);
813 rb.PushRaw<Service::Time::Clock::SteadyClockTimePoint>(time_point);
814}
815
816void SET_SYS::SetUserSystemClockAutomaticCorrectionUpdatedTime(HLERequestContext& ctx) {
817 LOG_WARNING(Service_SET, "called.");
818
819 IPC::RequestParser rp{ctx};
820 auto time_point{rp.PopRaw<Service::Time::Clock::SteadyClockTimePoint>()};
821
822 auto res = SetUserSystemClockAutomaticCorrectionUpdatedTime(time_point);
823
824 IPC::ResponseBuilder rb{ctx, 2};
825 rb.Push(res);
826}
827
828void SET_SYS::GetChineseTraditionalInputMethod(HLERequestContext& ctx) {
517 LOG_WARNING(Service_SET, "(STUBBED) called"); 829 LOG_WARNING(Service_SET, "(STUBBED) called");
518 830
519 IPC::ResponseBuilder rb{ctx, 3}; 831 IPC::ResponseBuilder rb{ctx, 3};
520 rb.Push(ResultSuccess); 832 rb.Push(ResultSuccess);
521 rb.Push(0); 833 rb.PushEnum(ChineseTraditionalInputMethod::Unknown0);
522} 834}
835
523void SET_SYS::GetFieldTestingFlag(HLERequestContext& ctx) { 836void SET_SYS::GetFieldTestingFlag(HLERequestContext& ctx) {
524 LOG_WARNING(Service_SET, "(STUBBED) called"); 837 LOG_WARNING(Service_SET, "(STUBBED) called");
525 838
@@ -528,7 +841,7 @@ void SET_SYS::GetFieldTestingFlag(HLERequestContext& ctx) {
528 rb.Push<u8>(false); 841 rb.Push<u8>(false);
529} 842}
530 843
531SET_SYS::SET_SYS(Core::System& system_) : ServiceFramework{system_, "set:sys"} { 844SET_SYS::SET_SYS(Core::System& system_) : ServiceFramework{system_, "set:sys"}, m_system{system} {
532 // clang-format off 845 // clang-format off
533 static const FunctionInfo functions[] = { 846 static const FunctionInfo functions[] = {
534 {0, &SET_SYS::SetLanguageCode, "SetLanguageCode"}, 847 {0, &SET_SYS::SetLanguageCode, "SetLanguageCode"},
@@ -543,10 +856,10 @@ SET_SYS::SET_SYS(Core::System& system_) : ServiceFramework{system_, "set:sys"} {
543 {10, nullptr, "SetBacklightSettings"}, 856 {10, nullptr, "SetBacklightSettings"},
544 {11, nullptr, "SetBluetoothDevicesSettings"}, 857 {11, nullptr, "SetBluetoothDevicesSettings"},
545 {12, nullptr, "GetBluetoothDevicesSettings"}, 858 {12, nullptr, "GetBluetoothDevicesSettings"},
546 {13, nullptr, "GetExternalSteadyClockSourceId"}, 859 {13, &SET_SYS::GetExternalSteadyClockSourceId, "GetExternalSteadyClockSourceId"},
547 {14, nullptr, "SetExternalSteadyClockSourceId"}, 860 {14, &SET_SYS::SetExternalSteadyClockSourceId, "SetExternalSteadyClockSourceId"},
548 {15, nullptr, "GetUserSystemClockContext"}, 861 {15, &SET_SYS::GetUserSystemClockContext, "GetUserSystemClockContext"},
549 {16, nullptr, "SetUserSystemClockContext"}, 862 {16, &SET_SYS::SetUserSystemClockContext, "SetUserSystemClockContext"},
550 {17, &SET_SYS::GetAccountSettings, "GetAccountSettings"}, 863 {17, &SET_SYS::GetAccountSettings, "GetAccountSettings"},
551 {18, &SET_SYS::SetAccountSettings, "SetAccountSettings"}, 864 {18, &SET_SYS::SetAccountSettings, "SetAccountSettings"},
552 {19, nullptr, "GetAudioVolume"}, 865 {19, nullptr, "GetAudioVolume"},
@@ -581,15 +894,15 @@ SET_SYS::SET_SYS(Core::System& system_) : ServiceFramework{system_, "set:sys"} {
581 {50, nullptr, "SetDataDeletionSettings"}, 894 {50, nullptr, "SetDataDeletionSettings"},
582 {51, nullptr, "GetInitialSystemAppletProgramId"}, 895 {51, nullptr, "GetInitialSystemAppletProgramId"},
583 {52, nullptr, "GetOverlayDispProgramId"}, 896 {52, nullptr, "GetOverlayDispProgramId"},
584 {53, nullptr, "GetDeviceTimeZoneLocationName"}, 897 {53, &SET_SYS::GetDeviceTimeZoneLocationName, "GetDeviceTimeZoneLocationName"},
585 {54, nullptr, "SetDeviceTimeZoneLocationName"}, 898 {54, &SET_SYS::SetDeviceTimeZoneLocationName, "SetDeviceTimeZoneLocationName"},
586 {55, nullptr, "GetWirelessCertificationFileSize"}, 899 {55, nullptr, "GetWirelessCertificationFileSize"},
587 {56, nullptr, "GetWirelessCertificationFile"}, 900 {56, nullptr, "GetWirelessCertificationFile"},
588 {57, &SET_SYS::SetRegionCode, "SetRegionCode"}, 901 {57, &SET_SYS::SetRegionCode, "SetRegionCode"},
589 {58, nullptr, "GetNetworkSystemClockContext"}, 902 {58, &SET_SYS::GetNetworkSystemClockContext, "GetNetworkSystemClockContext"},
590 {59, nullptr, "SetNetworkSystemClockContext"}, 903 {59, &SET_SYS::SetNetworkSystemClockContext, "SetNetworkSystemClockContext"},
591 {60, nullptr, "IsUserSystemClockAutomaticCorrectionEnabled"}, 904 {60, &SET_SYS::IsUserSystemClockAutomaticCorrectionEnabled, "IsUserSystemClockAutomaticCorrectionEnabled"},
592 {61, nullptr, "SetUserSystemClockAutomaticCorrectionEnabled"}, 905 {61, &SET_SYS::SetUserSystemClockAutomaticCorrectionEnabled, "SetUserSystemClockAutomaticCorrectionEnabled"},
593 {62, nullptr, "GetDebugModeFlag"}, 906 {62, nullptr, "GetDebugModeFlag"},
594 {63, &SET_SYS::GetPrimaryAlbumStorage, "GetPrimaryAlbumStorage"}, 907 {63, &SET_SYS::GetPrimaryAlbumStorage, "GetPrimaryAlbumStorage"},
595 {64, nullptr, "SetPrimaryAlbumStorage"}, 908 {64, nullptr, "SetPrimaryAlbumStorage"},
@@ -633,8 +946,8 @@ SET_SYS::SET_SYS(Core::System& system_) : ServiceFramework{system_, "set:sys"} {
633 {102, nullptr, "SetExternalRtcResetFlag"}, 946 {102, nullptr, "SetExternalRtcResetFlag"},
634 {103, nullptr, "GetUsbFullKeyEnableFlag"}, 947 {103, nullptr, "GetUsbFullKeyEnableFlag"},
635 {104, nullptr, "SetUsbFullKeyEnableFlag"}, 948 {104, nullptr, "SetUsbFullKeyEnableFlag"},
636 {105, nullptr, "SetExternalSteadyClockInternalOffset"}, 949 {105, &SET_SYS::SetExternalSteadyClockInternalOffset, "SetExternalSteadyClockInternalOffset"},
637 {106, nullptr, "GetExternalSteadyClockInternalOffset"}, 950 {106, &SET_SYS::GetExternalSteadyClockInternalOffset, "GetExternalSteadyClockInternalOffset"},
638 {107, nullptr, "GetBacklightSettingsEx"}, 951 {107, nullptr, "GetBacklightSettingsEx"},
639 {108, nullptr, "SetBacklightSettingsEx"}, 952 {108, nullptr, "SetBacklightSettingsEx"},
640 {109, nullptr, "GetHeadphoneVolumeWarningCount"}, 953 {109, nullptr, "GetHeadphoneVolumeWarningCount"},
@@ -678,10 +991,10 @@ SET_SYS::SET_SYS(Core::System& system_) : ServiceFramework{system_, "set:sys"} {
678 {147, nullptr, "GetConsoleSixAxisSensorAngularAcceleration"}, 991 {147, nullptr, "GetConsoleSixAxisSensorAngularAcceleration"},
679 {148, nullptr, "SetConsoleSixAxisSensorAngularAcceleration"}, 992 {148, nullptr, "SetConsoleSixAxisSensorAngularAcceleration"},
680 {149, nullptr, "GetRebootlessSystemUpdateVersion"}, 993 {149, nullptr, "GetRebootlessSystemUpdateVersion"},
681 {150, nullptr, "GetDeviceTimeZoneLocationUpdatedTime"}, 994 {150, &SET_SYS::GetDeviceTimeZoneLocationUpdatedTime, "GetDeviceTimeZoneLocationUpdatedTime"},
682 {151, nullptr, "SetDeviceTimeZoneLocationUpdatedTime"}, 995 {151, &SET_SYS::SetDeviceTimeZoneLocationUpdatedTime, "SetDeviceTimeZoneLocationUpdatedTime"},
683 {152, nullptr, "GetUserSystemClockAutomaticCorrectionUpdatedTime"}, 996 {152, &SET_SYS::GetUserSystemClockAutomaticCorrectionUpdatedTime, "GetUserSystemClockAutomaticCorrectionUpdatedTime"},
684 {153, nullptr, "SetUserSystemClockAutomaticCorrectionUpdatedTime"}, 997 {153, &SET_SYS::SetUserSystemClockAutomaticCorrectionUpdatedTime, "SetUserSystemClockAutomaticCorrectionUpdatedTime"},
685 {154, nullptr, "GetAccountOnlineStorageSettings"}, 998 {154, nullptr, "GetAccountOnlineStorageSettings"},
686 {155, nullptr, "SetAccountOnlineStorageSettings"}, 999 {155, nullptr, "SetAccountOnlineStorageSettings"},
687 {156, nullptr, "GetPctlReadyFlag"}, 1000 {156, nullptr, "GetPctlReadyFlag"},
@@ -702,7 +1015,7 @@ SET_SYS::SET_SYS(Core::System& system_) : ServiceFramework{system_, "set:sys"} {
702 {171, nullptr, "SetChineseTraditionalInputMethod"}, 1015 {171, nullptr, "SetChineseTraditionalInputMethod"},
703 {172, nullptr, "GetPtmCycleCountReliability"}, 1016 {172, nullptr, "GetPtmCycleCountReliability"},
704 {173, nullptr, "SetPtmCycleCountReliability"}, 1017 {173, nullptr, "SetPtmCycleCountReliability"},
705 {174, &SET_SYS::GetHomeMenuScheme, "GetHomeMenuScheme"}, 1018 {174, nullptr, "GetHomeMenuScheme"},
706 {175, nullptr, "GetThemeSettings"}, 1019 {175, nullptr, "GetThemeSettings"},
707 {176, nullptr, "SetThemeSettings"}, 1020 {176, nullptr, "SetThemeSettings"},
708 {177, nullptr, "GetThemeKey"}, 1021 {177, nullptr, "GetThemeKey"},
@@ -713,7 +1026,7 @@ SET_SYS::SET_SYS(Core::System& system_) : ServiceFramework{system_, "set:sys"} {
713 {182, nullptr, "SetT"}, 1026 {182, nullptr, "SetT"},
714 {183, nullptr, "GetPlatformRegion"}, 1027 {183, nullptr, "GetPlatformRegion"},
715 {184, nullptr, "SetPlatformRegion"}, 1028 {184, nullptr, "SetPlatformRegion"},
716 {185, &SET_SYS::GetHomeMenuSchemeModel, "GetHomeMenuSchemeModel"}, 1029 {185, nullptr, "GetHomeMenuSchemeModel"},
717 {186, nullptr, "GetMemoryUsageRateFlag"}, 1030 {186, nullptr, "GetMemoryUsageRateFlag"},
718 {187, nullptr, "GetTouchScreenMode"}, 1031 {187, nullptr, "GetTouchScreenMode"},
719 {188, nullptr, "SetTouchScreenMode"}, 1032 {188, nullptr, "SetTouchScreenMode"},
@@ -743,8 +1056,184 @@ SET_SYS::SET_SYS(Core::System& system_) : ServiceFramework{system_, "set:sys"} {
743 // clang-format on 1056 // clang-format on
744 1057
745 RegisterHandlers(functions); 1058 RegisterHandlers(functions);
1059
1060 SetupSettings();
1061 m_save_thread =
1062 std::jthread([this](std::stop_token stop_token) { StoreSettingsThreadFunc(stop_token); });
746} 1063}
747 1064
748SET_SYS::~SET_SYS() = default; 1065SET_SYS::~SET_SYS() {
1066 SetSaveNeeded();
1067 m_save_thread.request_stop();
1068}
1069
1070void SET_SYS::SetupSettings() {
1071 auto system_dir =
1072 Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/8000000000000050";
1073 if (!LoadSettingsFile(system_dir, []() { return DefaultSystemSettings(); })) {
1074 ASSERT(false);
1075 }
1076
1077 auto private_dir =
1078 Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/8000000000000052";
1079 if (!LoadSettingsFile(private_dir, []() { return DefaultPrivateSettings(); })) {
1080 ASSERT(false);
1081 }
1082
1083 auto device_dir =
1084 Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/8000000000000053";
1085 if (!LoadSettingsFile(device_dir, []() { return DefaultDeviceSettings(); })) {
1086 ASSERT(false);
1087 }
1088
1089 auto appln_dir =
1090 Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/8000000000000054";
1091 if (!LoadSettingsFile(appln_dir, []() { return DefaultApplnSettings(); })) {
1092 ASSERT(false);
1093 }
1094}
1095
1096void SET_SYS::StoreSettings() {
1097 auto system_dir =
1098 Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/8000000000000050";
1099 if (!StoreSettingsFile(system_dir, m_system_settings)) {
1100 LOG_ERROR(HW_GPU, "Failed to store System settings");
1101 }
1102
1103 auto private_dir =
1104 Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/8000000000000052";
1105 if (!StoreSettingsFile(private_dir, m_private_settings)) {
1106 LOG_ERROR(HW_GPU, "Failed to store Private settings");
1107 }
1108
1109 auto device_dir =
1110 Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/8000000000000053";
1111 if (!StoreSettingsFile(device_dir, m_device_settings)) {
1112 LOG_ERROR(HW_GPU, "Failed to store Device settings");
1113 }
1114
1115 auto appln_dir =
1116 Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/8000000000000054";
1117 if (!StoreSettingsFile(appln_dir, m_appln_settings)) {
1118 LOG_ERROR(HW_GPU, "Failed to store ApplLn settings");
1119 }
1120}
1121
1122void SET_SYS::StoreSettingsThreadFunc(std::stop_token stop_token) {
1123 while (Common::StoppableTimedWait(stop_token, std::chrono::minutes(1))) {
1124 std::scoped_lock l{m_save_needed_mutex};
1125 if (!std::exchange(m_save_needed, false)) {
1126 continue;
1127 }
1128 StoreSettings();
1129 }
1130}
1131
1132void SET_SYS::SetSaveNeeded() {
1133 std::scoped_lock l{m_save_needed_mutex};
1134 m_save_needed = true;
1135}
1136
1137Result SET_SYS::GetSettingsItemValue(std::vector<u8>& out_value, const std::string& category,
1138 const std::string& name) {
1139 auto settings{GetSettings()};
1140 R_UNLESS(settings.contains(category) && settings[category].contains(name), ResultUnknown);
1141
1142 out_value = settings[category][name];
1143 R_SUCCEED();
1144}
1145
1146Result SET_SYS::GetExternalSteadyClockSourceId(Common::UUID& out_id) {
1147 out_id = m_private_settings.external_clock_source_id;
1148 R_SUCCEED();
1149}
1150
1151Result SET_SYS::SetExternalSteadyClockSourceId(Common::UUID id) {
1152 m_private_settings.external_clock_source_id = id;
1153 SetSaveNeeded();
1154 R_SUCCEED();
1155}
1156
1157Result SET_SYS::GetUserSystemClockContext(Service::Time::Clock::SystemClockContext& out_context) {
1158 out_context = m_system_settings.user_system_clock_context;
1159 R_SUCCEED();
1160}
1161
1162Result SET_SYS::SetUserSystemClockContext(Service::Time::Clock::SystemClockContext& context) {
1163 m_system_settings.user_system_clock_context = context;
1164 SetSaveNeeded();
1165 R_SUCCEED();
1166}
1167
1168Result SET_SYS::GetDeviceTimeZoneLocationName(Service::Time::TimeZone::LocationName& out_name) {
1169 out_name = m_system_settings.device_time_zone_location_name;
1170 R_SUCCEED();
1171}
1172
1173Result SET_SYS::SetDeviceTimeZoneLocationName(Service::Time::TimeZone::LocationName& name) {
1174 m_system_settings.device_time_zone_location_name = name;
1175 SetSaveNeeded();
1176 R_SUCCEED();
1177}
1178
1179Result SET_SYS::GetNetworkSystemClockContext(
1180 Service::Time::Clock::SystemClockContext& out_context) {
1181 out_context = m_system_settings.network_system_clock_context;
1182 R_SUCCEED();
1183}
1184
1185Result SET_SYS::SetNetworkSystemClockContext(Service::Time::Clock::SystemClockContext& context) {
1186 m_system_settings.network_system_clock_context = context;
1187 SetSaveNeeded();
1188 R_SUCCEED();
1189}
1190
1191Result SET_SYS::IsUserSystemClockAutomaticCorrectionEnabled(bool& out_enabled) {
1192 out_enabled = m_system_settings.user_system_clock_automatic_correction_enabled;
1193 R_SUCCEED();
1194}
1195
1196Result SET_SYS::SetUserSystemClockAutomaticCorrectionEnabled(bool enabled) {
1197 m_system_settings.user_system_clock_automatic_correction_enabled = enabled;
1198 SetSaveNeeded();
1199 R_SUCCEED();
1200}
1201
1202Result SET_SYS::SetExternalSteadyClockInternalOffset(s64 offset) {
1203 m_private_settings.external_steady_clock_internal_offset = offset;
1204 SetSaveNeeded();
1205 R_SUCCEED();
1206}
1207
1208Result SET_SYS::GetExternalSteadyClockInternalOffset(s64& out_offset) {
1209 out_offset = m_private_settings.external_steady_clock_internal_offset;
1210 R_SUCCEED();
1211}
1212
1213Result SET_SYS::GetDeviceTimeZoneLocationUpdatedTime(
1214 Service::Time::Clock::SteadyClockTimePoint& out_time_point) {
1215 out_time_point = m_system_settings.device_time_zone_location_updated_time;
1216 R_SUCCEED();
1217}
1218
1219Result SET_SYS::SetDeviceTimeZoneLocationUpdatedTime(
1220 Service::Time::Clock::SteadyClockTimePoint& time_point) {
1221 m_system_settings.device_time_zone_location_updated_time = time_point;
1222 SetSaveNeeded();
1223 R_SUCCEED();
1224}
1225
1226Result SET_SYS::GetUserSystemClockAutomaticCorrectionUpdatedTime(
1227 Service::Time::Clock::SteadyClockTimePoint& out_time_point) {
1228 out_time_point = m_system_settings.user_system_clock_automatic_correction_updated_time_point;
1229 R_SUCCEED();
1230}
1231
1232Result SET_SYS::SetUserSystemClockAutomaticCorrectionUpdatedTime(
1233 Service::Time::Clock::SteadyClockTimePoint out_time_point) {
1234 m_system_settings.user_system_clock_automatic_correction_updated_time_point = out_time_point;
1235 SetSaveNeeded();
1236 R_SUCCEED();
1237}
749 1238
750} // namespace Service::Set 1239} // namespace Service::Set
diff --git a/src/core/hle/service/set/set_sys.h b/src/core/hle/service/set/set_sys.h
index f12a2cbbf..621c7ae36 100755
--- a/src/core/hle/service/set/set_sys.h
+++ b/src/core/hle/service/set/set_sys.h
@@ -3,17 +3,26 @@
3 3
4#pragma once 4#pragma once
5 5
6#include <filesystem>
7#include <mutex>
8#include <string>
9#include <thread>
10
6#include "common/uuid.h" 11#include "common/uuid.h"
7#include "core/hle/result.h" 12#include "core/hle/result.h"
8#include "core/hle/service/service.h" 13#include "core/hle/service/service.h"
14#include "core/hle/service/set/appln_settings.h"
15#include "core/hle/service/set/device_settings.h"
16#include "core/hle/service/set/private_settings.h"
17#include "core/hle/service/set/system_settings.h"
9#include "core/hle/service/time/clock_types.h" 18#include "core/hle/service/time/clock_types.h"
19#include "core/hle/service/time/time_zone_types.h"
10 20
11namespace Core { 21namespace Core {
12class System; 22class System;
13} 23}
14 24
15namespace Service::Set { 25namespace Service::Set {
16enum class LanguageCode : u64;
17enum class GetFirmwareVersionType { 26enum class GetFirmwareVersionType {
18 Version1, 27 Version1,
19 Version2, 28 Version2,
@@ -42,270 +51,38 @@ public:
42 explicit SET_SYS(Core::System& system_); 51 explicit SET_SYS(Core::System& system_);
43 ~SET_SYS() override; 52 ~SET_SYS() override;
44 53
45private: 54 Result GetSettingsItemValue(std::vector<u8>& out_value, const std::string& category,
46 /// Indicates the current theme set by the system settings 55 const std::string& name);
47 enum class ColorSet : u32 { 56
48 BasicWhite = 0, 57 Result GetExternalSteadyClockSourceId(Common::UUID& out_id);
49 BasicBlack = 1, 58 Result SetExternalSteadyClockSourceId(Common::UUID id);
50 }; 59 Result GetUserSystemClockContext(Service::Time::Clock::SystemClockContext& out_context);
51 60 Result SetUserSystemClockContext(Service::Time::Clock::SystemClockContext& context);
52 /// Indicates the current console is a retail or kiosk unit 61 Result GetDeviceTimeZoneLocationName(Service::Time::TimeZone::LocationName& out_name);
53 enum class QuestFlag : u8 { 62 Result SetDeviceTimeZoneLocationName(Service::Time::TimeZone::LocationName& name);
54 Retail = 0, 63 Result GetNetworkSystemClockContext(Service::Time::Clock::SystemClockContext& out_context);
55 Kiosk = 1, 64 Result SetNetworkSystemClockContext(Service::Time::Clock::SystemClockContext& context);
56 }; 65 Result IsUserSystemClockAutomaticCorrectionEnabled(bool& out_enabled);
57 66 Result SetUserSystemClockAutomaticCorrectionEnabled(bool enabled);
58 /// This is nn::settings::system::TvResolution 67 Result SetExternalSteadyClockInternalOffset(s64 offset);
59 enum class TvResolution : u32 { 68 Result GetExternalSteadyClockInternalOffset(s64& out_offset);
60 Auto, 69 Result GetDeviceTimeZoneLocationUpdatedTime(
61 Resolution1080p, 70 Service::Time::Clock::SteadyClockTimePoint& out_time_point);
62 Resolution720p, 71 Result SetDeviceTimeZoneLocationUpdatedTime(
63 Resolution480p, 72 Service::Time::Clock::SteadyClockTimePoint& time_point);
64 }; 73 Result GetUserSystemClockAutomaticCorrectionUpdatedTime(
65 74 Service::Time::Clock::SteadyClockTimePoint& out_time_point);
66 /// This is nn::settings::system::HdmiContentType 75 Result SetUserSystemClockAutomaticCorrectionUpdatedTime(
67 enum class HdmiContentType : u32 { 76 Service::Time::Clock::SteadyClockTimePoint time_point);
68 None,
69 Graphics,
70 Cinema,
71 Photo,
72 Game,
73 };
74
75 /// This is nn::settings::system::RgbRange
76 enum class RgbRange : u32 {
77 Auto,
78 Full,
79 Limited,
80 };
81
82 /// This is nn::settings::system::CmuMode
83 enum class CmuMode : u32 {
84 None,
85 ColorInvert,
86 HighContrast,
87 GrayScale,
88 };
89
90 /// This is nn::settings::system::PrimaryAlbumStorage
91 enum class PrimaryAlbumStorage : u32 {
92 Nand,
93 SdCard,
94 };
95
96 /// This is nn::settings::system::NotificationVolume
97 enum class NotificationVolume : u32 {
98 Mute,
99 Low,
100 High,
101 };
102
103 /// This is nn::settings::system::ChineseTraditionalInputMethod
104 enum class ChineseTraditionalInputMethod : u32 {
105 Unknown0 = 0,
106 Unknown1 = 1,
107 Unknown2 = 2,
108 };
109
110 /// This is nn::settings::system::ErrorReportSharePermission
111 enum class ErrorReportSharePermission : u32 {
112 NotConfirmed,
113 Granted,
114 Denied,
115 };
116
117 /// This is nn::settings::system::FriendPresenceOverlayPermission
118 enum class FriendPresenceOverlayPermission : u8 {
119 NotConfirmed,
120 NoDisplay,
121 FavoriteFriends,
122 Friends,
123 };
124
125 /// This is nn::settings::system::HandheldSleepPlan
126 enum class HandheldSleepPlan : u32 {
127 Sleep1Min,
128 Sleep3Min,
129 Sleep5Min,
130 Sleep10Min,
131 Sleep30Min,
132 Never,
133 };
134
135 /// This is nn::settings::system::ConsoleSleepPlan
136 enum class ConsoleSleepPlan : u32 {
137 Sleep1Hour,
138 Sleep2Hour,
139 Sleep3Hour,
140 Sleep6Hour,
141 Sleep12Hour,
142 Never,
143 };
144
145 /// This is nn::settings::system::RegionCode
146 enum class RegionCode : u32 {
147 Japan,
148 Usa,
149 Europe,
150 Australia,
151 HongKongTaiwanKorea,
152 China,
153 };
154
155 /// This is nn::settings::system::EulaVersionClockType
156 enum class EulaVersionClockType : u32 {
157 NetworkSystemClock,
158 SteadyClock,
159 };
160
161 /// This is nn::settings::system::SleepFlag
162 struct SleepFlag {
163 union {
164 u32 raw{};
165
166 BitField<0, 1, u32> SleepsWhilePlayingMedia;
167 BitField<1, 1, u32> WakesAtPowerStateChange;
168 };
169 };
170 static_assert(sizeof(SleepFlag) == 4, "TvFlag is an invalid size");
171
172 /// This is nn::settings::system::TvFlag
173 struct TvFlag {
174 union {
175 u32 raw{};
176
177 BitField<0, 1, u32> Allows4k;
178 BitField<1, 1, u32> Allows3d;
179 BitField<2, 1, u32> AllowsCec;
180 BitField<3, 1, u32> PreventsScreenBurnIn;
181 };
182 };
183 static_assert(sizeof(TvFlag) == 4, "TvFlag is an invalid size");
184
185 /// This is nn::settings::system::InitialLaunchFlag
186 struct InitialLaunchFlag {
187 union {
188 u32 raw{};
189
190 BitField<0, 1, u32> InitialLaunchCompletionFlag;
191 BitField<8, 1, u32> InitialLaunchUserAdditionFlag;
192 BitField<16, 1, u32> InitialLaunchTimestampFlag;
193 };
194 };
195 static_assert(sizeof(InitialLaunchFlag) == 4, "InitialLaunchFlag is an invalid size");
196
197 /// This is nn::settings::system::NotificationFlag
198 struct NotificationFlag {
199 union {
200 u32 raw{};
201
202 BitField<0, 1, u32> RingtoneFlag;
203 BitField<1, 1, u32> DownloadCompletionFlag;
204 BitField<8, 1, u32> EnablesNews;
205 BitField<9, 1, u32> IncomingLampFlag;
206 };
207 };
208 static_assert(sizeof(NotificationFlag) == 4, "NotificationFlag is an invalid size");
209
210 /// This is nn::settings::system::AccountNotificationFlag
211 struct AccountNotificationFlag {
212 union {
213 u32 raw{};
214
215 BitField<0, 1, u32> FriendOnlineFlag;
216 BitField<1, 1, u32> FriendRequestFlag;
217 BitField<8, 1, u32> CoralInvitationFlag;
218 };
219 };
220 static_assert(sizeof(AccountNotificationFlag) == 4,
221 "AccountNotificationFlag is an invalid size");
222
223 /// This is nn::settings::system::TvSettings
224 struct TvSettings {
225 TvFlag flags;
226 TvResolution tv_resolution;
227 HdmiContentType hdmi_content_type;
228 RgbRange rgb_range;
229 CmuMode cmu_mode;
230 u32 tv_underscan;
231 f32 tv_gama;
232 f32 constrast_ratio;
233 };
234 static_assert(sizeof(TvSettings) == 0x20, "TvSettings is an invalid size");
235
236 /// This is nn::settings::system::NotificationTime
237 struct NotificationTime {
238 u32 hour;
239 u32 minute;
240 };
241 static_assert(sizeof(NotificationTime) == 0x8, "NotificationTime is an invalid size");
242
243 /// This is nn::settings::system::NotificationSettings
244 struct NotificationSettings {
245 NotificationFlag flags;
246 NotificationVolume volume;
247 NotificationTime start_time;
248 NotificationTime stop_time;
249 };
250 static_assert(sizeof(NotificationSettings) == 0x18, "NotificationSettings is an invalid size");
251
252 /// This is nn::settings::system::AccountSettings
253 struct AccountSettings {
254 u32 flags;
255 };
256 static_assert(sizeof(AccountSettings) == 0x4, "AccountSettings is an invalid size");
257
258 /// This is nn::settings::system::AccountNotificationSettings
259 struct AccountNotificationSettings {
260 Common::UUID uid;
261 AccountNotificationFlag flags;
262 FriendPresenceOverlayPermission friend_presence_permission;
263 FriendPresenceOverlayPermission friend_invitation_permission;
264 INSERT_PADDING_BYTES(0x2);
265 };
266 static_assert(sizeof(AccountNotificationSettings) == 0x18,
267 "AccountNotificationSettings is an invalid size");
268
269 /// This is nn::settings::system::InitialLaunchSettings
270 struct SleepSettings {
271 SleepFlag flags;
272 HandheldSleepPlan handheld_sleep_plan;
273 ConsoleSleepPlan console_sleep_plan;
274 };
275 static_assert(sizeof(SleepSettings) == 0xc, "SleepSettings is incorrect size");
276
277 /// This is nn::settings::system::InitialLaunchSettings
278 struct InitialLaunchSettings {
279 InitialLaunchFlag flags;
280 INSERT_PADDING_BYTES(0x4);
281 Time::Clock::SteadyClockTimePoint timestamp;
282 };
283 static_assert(sizeof(InitialLaunchSettings) == 0x20, "InitialLaunchSettings is incorrect size");
284
285 /// This is nn::settings::system::InitialLaunchSettings
286 struct EulaVersion {
287 u32 version;
288 RegionCode region_code;
289 EulaVersionClockType clock_type;
290 INSERT_PADDING_BYTES(0x4);
291 s64 posix_time;
292 Time::Clock::SteadyClockTimePoint timestamp;
293 };
294 static_assert(sizeof(EulaVersion) == 0x30, "EulaVersion is incorrect size");
295
296 /// This is nn::settings::system::HomeMenuScheme
297 struct HomeMenuScheme {
298 u32 main;
299 u32 back;
300 u32 sub;
301 u32 bezel;
302 u32 extra;
303 };
304 static_assert(sizeof(HomeMenuScheme) == 0x14, "HomeMenuScheme is incorrect size");
305 77
78private:
306 void SetLanguageCode(HLERequestContext& ctx); 79 void SetLanguageCode(HLERequestContext& ctx);
307 void GetFirmwareVersion(HLERequestContext& ctx); 80 void GetFirmwareVersion(HLERequestContext& ctx);
308 void GetFirmwareVersion2(HLERequestContext& ctx); 81 void GetFirmwareVersion2(HLERequestContext& ctx);
82 void GetExternalSteadyClockSourceId(HLERequestContext& ctx);
83 void SetExternalSteadyClockSourceId(HLERequestContext& ctx);
84 void GetUserSystemClockContext(HLERequestContext& ctx);
85 void SetUserSystemClockContext(HLERequestContext& ctx);
309 void GetAccountSettings(HLERequestContext& ctx); 86 void GetAccountSettings(HLERequestContext& ctx);
310 void SetAccountSettings(HLERequestContext& ctx); 87 void SetAccountSettings(HLERequestContext& ctx);
311 void GetEulaVersions(HLERequestContext& ctx); 88 void GetEulaVersions(HLERequestContext& ctx);
@@ -321,7 +98,13 @@ private:
321 void GetTvSettings(HLERequestContext& ctx); 98 void GetTvSettings(HLERequestContext& ctx);
322 void SetTvSettings(HLERequestContext& ctx); 99 void SetTvSettings(HLERequestContext& ctx);
323 void GetQuestFlag(HLERequestContext& ctx); 100 void GetQuestFlag(HLERequestContext& ctx);
101 void GetDeviceTimeZoneLocationName(HLERequestContext& ctx);
102 void SetDeviceTimeZoneLocationName(HLERequestContext& ctx);
324 void SetRegionCode(HLERequestContext& ctx); 103 void SetRegionCode(HLERequestContext& ctx);
104 void GetNetworkSystemClockContext(HLERequestContext& ctx);
105 void SetNetworkSystemClockContext(HLERequestContext& ctx);
106 void IsUserSystemClockAutomaticCorrectionEnabled(HLERequestContext& ctx);
107 void SetUserSystemClockAutomaticCorrectionEnabled(HLERequestContext& ctx);
325 void GetPrimaryAlbumStorage(HLERequestContext& ctx); 108 void GetPrimaryAlbumStorage(HLERequestContext& ctx);
326 void GetSleepSettings(HLERequestContext& ctx); 109 void GetSleepSettings(HLERequestContext& ctx);
327 void SetSleepSettings(HLERequestContext& ctx); 110 void SetSleepSettings(HLERequestContext& ctx);
@@ -333,59 +116,34 @@ private:
333 void GetMiiAuthorId(HLERequestContext& ctx); 116 void GetMiiAuthorId(HLERequestContext& ctx);
334 void GetAutoUpdateEnableFlag(HLERequestContext& ctx); 117 void GetAutoUpdateEnableFlag(HLERequestContext& ctx);
335 void GetBatteryPercentageFlag(HLERequestContext& ctx); 118 void GetBatteryPercentageFlag(HLERequestContext& ctx);
119 void SetExternalSteadyClockInternalOffset(HLERequestContext& ctx);
120 void GetExternalSteadyClockInternalOffset(HLERequestContext& ctx);
336 void GetErrorReportSharePermission(HLERequestContext& ctx); 121 void GetErrorReportSharePermission(HLERequestContext& ctx);
337 void GetAppletLaunchFlags(HLERequestContext& ctx); 122 void GetAppletLaunchFlags(HLERequestContext& ctx);
338 void SetAppletLaunchFlags(HLERequestContext& ctx); 123 void SetAppletLaunchFlags(HLERequestContext& ctx);
339 void GetKeyboardLayout(HLERequestContext& ctx); 124 void GetKeyboardLayout(HLERequestContext& ctx);
125 void GetDeviceTimeZoneLocationUpdatedTime(HLERequestContext& ctx);
126 void SetDeviceTimeZoneLocationUpdatedTime(HLERequestContext& ctx);
127 void GetUserSystemClockAutomaticCorrectionUpdatedTime(HLERequestContext& ctx);
128 void SetUserSystemClockAutomaticCorrectionUpdatedTime(HLERequestContext& ctx);
340 void GetChineseTraditionalInputMethod(HLERequestContext& ctx); 129 void GetChineseTraditionalInputMethod(HLERequestContext& ctx);
341 void GetFieldTestingFlag(HLERequestContext& ctx); 130 void GetFieldTestingFlag(HLERequestContext& ctx);
342 void GetHomeMenuScheme(HLERequestContext& ctx);
343 void GetHomeMenuSchemeModel(HLERequestContext& ctx);
344
345 AccountSettings account_settings{
346 .flags = {},
347 };
348
349 ColorSet color_set = ColorSet::BasicWhite;
350
351 NotificationSettings notification_settings{
352 .flags = {0x300},
353 .volume = NotificationVolume::High,
354 .start_time = {.hour = 9, .minute = 0},
355 .stop_time = {.hour = 21, .minute = 0},
356 };
357
358 std::vector<AccountNotificationSettings> account_notifications{};
359
360 TvSettings tv_settings{
361 .flags = {0xc},
362 .tv_resolution = TvResolution::Auto,
363 .hdmi_content_type = HdmiContentType::Game,
364 .rgb_range = RgbRange::Auto,
365 .cmu_mode = CmuMode::None,
366 .tv_underscan = {},
367 .tv_gama = 1.0f,
368 .constrast_ratio = 0.5f,
369 };
370
371 InitialLaunchSettings launch_settings{
372 .flags = {0x10001},
373 .timestamp = {},
374 };
375
376 SleepSettings sleep_settings{
377 .flags = {0x3},
378 .handheld_sleep_plan = HandheldSleepPlan::Sleep10Min,
379 .console_sleep_plan = ConsoleSleepPlan::Sleep1Hour,
380 };
381
382 u32 applet_launch_flag{};
383
384 std::vector<EulaVersion> eula_versions{};
385
386 RegionCode region_code;
387 131
388 LanguageCode language_code_setting; 132 bool LoadSettingsFile(std::filesystem::path& path, auto&& default_func);
133 bool StoreSettingsFile(std::filesystem::path& path, auto& settings);
134 void SetupSettings();
135 void StoreSettings();
136 void StoreSettingsThreadFunc(std::stop_token stop_token);
137 void SetSaveNeeded();
138
139 Core::System& m_system;
140 SystemSettings m_system_settings{};
141 PrivateSettings m_private_settings{};
142 DeviceSettings m_device_settings{};
143 ApplnSettings m_appln_settings{};
144 std::jthread m_save_thread;
145 std::mutex m_save_needed_mutex;
146 bool m_save_needed{false};
389}; 147};
390 148
391} // namespace Service::Set 149} // namespace Service::Set
diff --git a/src/core/hle/service/set/system_settings.cpp b/src/core/hle/service/set/system_settings.cpp
new file mode 100755
index 000000000..2723417ad
--- /dev/null
+++ b/src/core/hle/service/set/system_settings.cpp
@@ -0,0 +1,51 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/service/set/system_settings.h"
5
6namespace Service::Set {
7
8SystemSettings DefaultSystemSettings() {
9 SystemSettings settings{};
10
11 settings.version = 0x140000;
12 settings.flags = 7;
13
14 settings.color_set_id = ColorSet::BasicWhite;
15
16 settings.notification_settings = {
17 .flags{0x300},
18 .volume = NotificationVolume::High,
19 .start_time = {.hour = 9, .minute = 0},
20 .stop_time = {.hour = 21, .minute = 0},
21 };
22
23 settings.tv_settings = {
24 .flags = {0xC},
25 .tv_resolution = TvResolution::Auto,
26 .hdmi_content_type = HdmiContentType::Game,
27 .rgb_range = RgbRange::Auto,
28 .cmu_mode = CmuMode::None,
29 .tv_underscan = {},
30 .tv_gama = 1.0f,
31 .constrast_ratio = 0.5f,
32 };
33
34 settings.initial_launch_settings_packed = {
35 .flags = {0x10001},
36 .timestamp = {},
37 };
38
39 settings.sleep_settings = {
40 .flags = {0x3},
41 .handheld_sleep_plan = HandheldSleepPlan::Sleep10Min,
42 .console_sleep_plan = ConsoleSleepPlan::Sleep1Hour,
43 };
44
45 settings.device_time_zone_location_name = {"UTC"};
46 settings.user_system_clock_automatic_correction_enabled = false;
47
48 return settings;
49}
50
51} // namespace Service::Set
diff --git a/src/core/hle/service/set/system_settings.h b/src/core/hle/service/set/system_settings.h
new file mode 100755
index 000000000..bbc791623
--- /dev/null
+++ b/src/core/hle/service/set/system_settings.h
@@ -0,0 +1,689 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include <array>
7
8#include "common/bit_field.h"
9#include "common/common_funcs.h"
10#include "common/common_types.h"
11#include "core/hle/service/set/private_settings.h"
12#include "core/hle/service/time/clock_types.h"
13
14namespace Service::Set {
15
16/// This is "nn::settings::LanguageCode", which is a NUL-terminated string stored in a u64.
17enum class LanguageCode : u64 {
18 JA = 0x000000000000616A,
19 EN_US = 0x00000053552D6E65,
20 FR = 0x0000000000007266,
21 DE = 0x0000000000006564,
22 IT = 0x0000000000007469,
23 ES = 0x0000000000007365,
24 ZH_CN = 0x0000004E432D687A,
25 KO = 0x0000000000006F6B,
26 NL = 0x0000000000006C6E,
27 PT = 0x0000000000007470,
28 RU = 0x0000000000007572,
29 ZH_TW = 0x00000057542D687A,
30 EN_GB = 0x00000042472D6E65,
31 FR_CA = 0x00000041432D7266,
32 ES_419 = 0x00003931342D7365,
33 ZH_HANS = 0x00736E61482D687A,
34 ZH_HANT = 0x00746E61482D687A,
35 PT_BR = 0x00000052422D7470,
36};
37
38/// This is nn::settings::system::ErrorReportSharePermission
39enum class ErrorReportSharePermission : u32 {
40 NotConfirmed,
41 Granted,
42 Denied,
43};
44
45/// This is nn::settings::system::ChineseTraditionalInputMethod
46enum class ChineseTraditionalInputMethod : u32 {
47 Unknown0 = 0,
48 Unknown1 = 1,
49 Unknown2 = 2,
50};
51
52/// Indicates the current theme set by the system settings
53enum class ColorSet : u32 {
54 BasicWhite = 0,
55 BasicBlack = 1,
56};
57
58/// Indicates the current console is a retail or kiosk unit
59enum class QuestFlag : u8 {
60 Retail = 0,
61 Kiosk = 1,
62};
63
64/// This is nn::settings::system::RegionCode
65enum class RegionCode : u32 {
66 Japan,
67 Usa,
68 Europe,
69 Australia,
70 HongKongTaiwanKorea,
71 China,
72};
73
74/// This is nn::settings::system::AccountSettings
75struct AccountSettings {
76 u32 flags;
77};
78static_assert(sizeof(AccountSettings) == 4, "AccountSettings is an invalid size");
79
80/// This is nn::settings::system::NotificationVolume
81enum class NotificationVolume : u32 {
82 Mute,
83 Low,
84 High,
85};
86
87/// This is nn::settings::system::NotificationFlag
88struct NotificationFlag {
89 union {
90 u32 raw{};
91
92 BitField<0, 1, u32> RingtoneFlag;
93 BitField<1, 1, u32> DownloadCompletionFlag;
94 BitField<8, 1, u32> EnablesNews;
95 BitField<9, 1, u32> IncomingLampFlag;
96 };
97};
98static_assert(sizeof(NotificationFlag) == 4, "NotificationFlag is an invalid size");
99
100/// This is nn::settings::system::NotificationTime
101struct NotificationTime {
102 u32 hour;
103 u32 minute;
104};
105static_assert(sizeof(NotificationTime) == 0x8, "NotificationTime is an invalid size");
106
107/// This is nn::settings::system::NotificationSettings
108struct NotificationSettings {
109 NotificationFlag flags;
110 NotificationVolume volume;
111 NotificationTime start_time;
112 NotificationTime stop_time;
113};
114static_assert(sizeof(NotificationSettings) == 0x18, "NotificationSettings is an invalid size");
115
116/// This is nn::settings::system::AccountNotificationFlag
117struct AccountNotificationFlag {
118 union {
119 u32 raw{};
120
121 BitField<0, 1, u32> FriendOnlineFlag;
122 BitField<1, 1, u32> FriendRequestFlag;
123 BitField<8, 1, u32> CoralInvitationFlag;
124 };
125};
126static_assert(sizeof(AccountNotificationFlag) == 4, "AccountNotificationFlag is an invalid size");
127
128/// This is nn::settings::system::FriendPresenceOverlayPermission
129enum class FriendPresenceOverlayPermission : u8 {
130 NotConfirmed,
131 NoDisplay,
132 FavoriteFriends,
133 Friends,
134};
135
136/// This is nn::settings::system::AccountNotificationSettings
137struct AccountNotificationSettings {
138 Common::UUID uid;
139 AccountNotificationFlag flags;
140 FriendPresenceOverlayPermission friend_presence_permission;
141 FriendPresenceOverlayPermission friend_invitation_permission;
142 INSERT_PADDING_BYTES(0x2);
143};
144static_assert(sizeof(AccountNotificationSettings) == 0x18,
145 "AccountNotificationSettings is an invalid size");
146
147/// This is nn::settings::system::TvFlag
148struct TvFlag {
149 union {
150 u32 raw{};
151
152 BitField<0, 1, u32> Allows4k;
153 BitField<1, 1, u32> Allows3d;
154 BitField<2, 1, u32> AllowsCec;
155 BitField<3, 1, u32> PreventsScreenBurnIn;
156 };
157};
158static_assert(sizeof(TvFlag) == 4, "TvFlag is an invalid size");
159
160/// This is nn::settings::system::TvResolution
161enum class TvResolution : u32 {
162 Auto,
163 Resolution1080p,
164 Resolution720p,
165 Resolution480p,
166};
167
168/// This is nn::settings::system::HdmiContentType
169enum class HdmiContentType : u32 {
170 None,
171 Graphics,
172 Cinema,
173 Photo,
174 Game,
175};
176
177/// This is nn::settings::system::RgbRange
178enum class RgbRange : u32 {
179 Auto,
180 Full,
181 Limited,
182};
183
184/// This is nn::settings::system::CmuMode
185enum class CmuMode : u32 {
186 None,
187 ColorInvert,
188 HighContrast,
189 GrayScale,
190};
191
192/// This is nn::settings::system::TvSettings
193struct TvSettings {
194 TvFlag flags;
195 TvResolution tv_resolution;
196 HdmiContentType hdmi_content_type;
197 RgbRange rgb_range;
198 CmuMode cmu_mode;
199 u32 tv_underscan;
200 f32 tv_gama;
201 f32 constrast_ratio;
202};
203static_assert(sizeof(TvSettings) == 0x20, "TvSettings is an invalid size");
204
205/// This is nn::settings::system::PrimaryAlbumStorage
206enum class PrimaryAlbumStorage : u32 {
207 Nand,
208 SdCard,
209};
210
211/// This is nn::settings::system::HandheldSleepPlan
212enum class HandheldSleepPlan : u32 {
213 Sleep1Min,
214 Sleep3Min,
215 Sleep5Min,
216 Sleep10Min,
217 Sleep30Min,
218 Never,
219};
220
221/// This is nn::settings::system::ConsoleSleepPlan
222enum class ConsoleSleepPlan : u32 {
223 Sleep1Hour,
224 Sleep2Hour,
225 Sleep3Hour,
226 Sleep6Hour,
227 Sleep12Hour,
228 Never,
229};
230
231/// This is nn::settings::system::SleepFlag
232struct SleepFlag {
233 union {
234 u32 raw{};
235
236 BitField<0, 1, u32> SleepsWhilePlayingMedia;
237 BitField<1, 1, u32> WakesAtPowerStateChange;
238 };
239};
240static_assert(sizeof(SleepFlag) == 4, "TvFlag is an invalid size");
241
242/// This is nn::settings::system::SleepSettings
243struct SleepSettings {
244 SleepFlag flags;
245 HandheldSleepPlan handheld_sleep_plan;
246 ConsoleSleepPlan console_sleep_plan;
247};
248static_assert(sizeof(SleepSettings) == 0xc, "SleepSettings is incorrect size");
249
250/// This is nn::settings::system::EulaVersionClockType
251enum class EulaVersionClockType : u32 {
252 NetworkSystemClock,
253 SteadyClock,
254};
255
256/// This is nn::settings::system::EulaVersion
257struct EulaVersion {
258 u32 version;
259 RegionCode region_code;
260 EulaVersionClockType clock_type;
261 INSERT_PADDING_BYTES(0x4);
262 s64 posix_time;
263 Time::Clock::SteadyClockTimePoint timestamp;
264};
265static_assert(sizeof(EulaVersion) == 0x30, "EulaVersion is incorrect size");
266
267struct SystemSettings {
268 // 0/unwritten (1.0.0), 0x20000 (2.0.0), 0x30000 (3.0.0-3.0.1), 0x40001 (4.0.0-4.1.0), 0x50000
269 // (5.0.0-5.1.0), 0x60000 (6.0.0-6.2.0), 0x70000 (7.0.0), 0x80000 (8.0.0-8.1.1), 0x90000
270 // (9.0.0-10.0.4), 0x100100 (10.1.0+), 0x120000 (12.0.0-12.1.0), 0x130000 (13.0.0-13.2.1),
271 // 0x140000 (14.0.0+)
272 u32 version;
273 // 0/unwritten (1.0.0), 1 (6.0.0-8.1.0), 2 (8.1.1), 7 (9.0.0+).
274 // if (flags & 2), defaults are written for AnalogStickUserCalibration
275 u32 flags;
276
277 std::array<u8, 0x8> reserved_00008;
278
279 // nn::settings::LanguageCode
280 LanguageCode language_code;
281
282 std::array<u8, 0x38> reserved_00018;
283
284 // nn::settings::system::NetworkSettings
285 u32 network_setting_count;
286 bool wireless_lan_enable_flag;
287 std::array<u8, 0x3> pad_00055;
288
289 std::array<u8, 0x8> reserved_00058;
290
291 // nn::settings::system::NetworkSettings
292 std::array<std::array<u8, 0x400>, 32> network_settings_1B0;
293
294 // nn::settings::system::BluetoothDevicesSettings
295 std::array<u8, 0x4> bluetooth_device_settings_count;
296 bool bluetooth_enable_flag;
297 std::array<u8, 0x3> pad_08065;
298 bool bluetooth_afh_enable_flag;
299 std::array<u8, 0x3> pad_08069;
300 bool bluetooth_boost_enable_flag;
301 std::array<u8, 0x3> pad_0806D;
302 std::array<std::array<u8, 0x200>, 10> bluetooth_device_settings_first_10;
303
304 s32 ldn_channel;
305
306 std::array<u8, 0x3C> reserved_09474;
307
308 // nn::util::Uuid MiiAuthorId
309 std::array<u8, 0x10> mii_author_id;
310
311 std::array<u8, 0x30> reserved_094C0;
312
313 // nn::settings::system::NxControllerSettings
314 u32 nx_controller_settings_count;
315
316 std::array<u8, 0xC> reserved_094F4;
317
318 // nn::settings::system::NxControllerSettings,
319 // nn::settings::system::NxControllerLegacySettings on 13.0.0+
320 std::array<std::array<u8, 0x40>, 10> nx_controller_legacy_settings;
321
322 std::array<u8, 0x170> reserved_09780;
323
324 bool external_rtc_reset_flag;
325 std::array<u8, 0x3> pad_098F1;
326
327 std::array<u8, 0x3C> reserved_098F4;
328
329 s32 push_notification_activity_mode_on_sleep;
330
331 std::array<u8, 0x3C> reserved_09934;
332
333 // nn::settings::system::ErrorReportSharePermission
334 ErrorReportSharePermission error_report_share_permssion;
335
336 std::array<u8, 0x3C> reserved_09974;
337
338 // nn::settings::KeyboardLayout
339 std::array<u8, 0x4> keyboard_layout;
340
341 std::array<u8, 0x3C> reserved_099B4;
342
343 bool web_inspector_flag;
344 std::array<u8, 0x3> pad_099F1;
345
346 // nn::settings::system::AllowedSslHost
347 u32 allowed_ssl_host_count;
348
349 bool memory_usage_rate_flag;
350 std::array<u8, 0x3> pad_099F9;
351
352 std::array<u8, 0x34> reserved_099FC;
353
354 // nn::settings::system::HostFsMountPoint
355 std::array<u8, 0x100> host_fs_mount_point;
356
357 // nn::settings::system::AllowedSslHost
358 std::array<std::array<u8, 0x100>, 8> allowed_ssl_hosts;
359
360 std::array<u8, 0x6C0> reserved_0A330;
361
362 // nn::settings::system::BlePairingSettings
363 u32 ble_pairing_settings_count;
364 std::array<u8, 0xC> reserved_0A9F4;
365 std::array<std::array<u8, 0x80>, 10> ble_pairing_settings;
366
367 // nn::settings::system::AccountOnlineStorageSettings
368 u32 account_online_storage_settings_count;
369 std::array<u8, 0xC> reserved_0AF04;
370 std::array<std::array<u8, 0x40>, 8> account_online_storage_settings;
371
372 bool pctl_ready_flag;
373 std::array<u8, 0x3> pad_0B111;
374
375 std::array<u8, 0x3C> reserved_0B114;
376
377 // nn::settings::system::ThemeId
378 std::array<u8, 0x80> theme_id_type0;
379 std::array<u8, 0x80> theme_id_type1;
380
381 std::array<u8, 0x100> reserved_0B250;
382
383 // nn::settings::ChineseTraditionalInputMethod
384 ChineseTraditionalInputMethod chinese_traditional_input_method;
385
386 std::array<u8, 0x3C> reserved_0B354;
387
388 bool zoom_flag;
389 std::array<u8, 0x3> pad_0B391;
390
391 std::array<u8, 0x3C> reserved_0B394;
392
393 // nn::settings::system::ButtonConfigRegisteredSettings
394 u32 button_config_registered_settings_count;
395 std::array<u8, 0xC> reserved_0B3D4;
396
397 // nn::settings::system::ButtonConfigSettings
398 u32 button_config_settings_count;
399 std::array<u8, 0x4> reserved_0B3E4;
400 std::array<std::array<u8, 0x5A8>, 5> button_config_settings;
401 std::array<u8, 0x13B0> reserved_0D030;
402 u32 button_config_settings_embedded_count;
403 std::array<u8, 0x4> reserved_0E3E4;
404 std::array<std::array<u8, 0x5A8>, 5> button_config_settings_embedded;
405 std::array<u8, 0x13B0> reserved_10030;
406 u32 button_config_settings_left_count;
407 std::array<u8, 0x4> reserved_113E4;
408 std::array<std::array<u8, 0x5A8>, 5> button_config_settings_left;
409 std::array<u8, 0x13B0> reserved_13030;
410 u32 button_config_settings_right_count;
411 std::array<u8, 0x4> reserved_143E4;
412 std::array<std::array<u8, 0x5A8>, 5> button_config_settings_right;
413 std::array<u8, 0x73B0> reserved_16030;
414 // nn::settings::system::ButtonConfigRegisteredSettings
415 std::array<u8, 0x5C8> button_config_registered_settings_embedded;
416 std::array<std::array<u8, 0x5C8>, 10> button_config_registered_settings;
417
418 std::array<u8, 0x7FF8> reserved_21378;
419
420 // nn::settings::system::ConsoleSixAxisSensorAccelerationBias
421 std::array<u8, 0xC> console_six_axis_sensor_acceleration_bias;
422 // nn::settings::system::ConsoleSixAxisSensorAngularVelocityBias
423 std::array<u8, 0xC> console_six_axis_sensor_angular_velocity_bias;
424 // nn::settings::system::ConsoleSixAxisSensorAccelerationGain
425 std::array<u8, 0x24> console_six_axis_sensor_acceleration_gain;
426 // nn::settings::system::ConsoleSixAxisSensorAngularVelocityGain
427 std::array<u8, 0x24> console_six_axis_sensor_angular_velocity_gain;
428 // nn::settings::system::ConsoleSixAxisSensorAngularVelocityTimeBias
429 std::array<u8, 0xC> console_six_axis_sensor_angular_velocity_time_bias;
430 // nn::settings::system::ConsoleSixAxisSensorAngularAcceleration
431 std::array<u8, 0x24> console_six_axis_sensor_angular_velocity_acceleration;
432
433 std::array<u8, 0x70> reserved_29400;
434
435 bool lock_screen_flag;
436 std::array<u8, 0x3> pad_29471;
437
438 std::array<u8, 0x4> reserved_249274;
439
440 ColorSet color_set_id;
441
442 QuestFlag quest_flag;
443
444 // nn::settings::system::RegionCode
445 RegionCode region_code;
446
447 // Different to nn::settings::system::InitialLaunchSettings?
448 InitialLaunchSettingsPacked initial_launch_settings_packed;
449
450 bool battery_percentage_flag;
451 std::array<u8, 0x3> pad_294A1;
452
453 // BitFlagSet<32, nn::settings::system::AppletLaunchFlag>
454 u32 applet_launch_flag;
455
456 // nn::settings::system::ThemeSettings
457 std::array<u8, 0x8> theme_settings;
458 // nn::fssystem::ArchiveMacKey
459 std::array<u8, 0x10> theme_key;
460
461 bool field_testing_flag;
462 std::array<u8, 0x3> pad_294C1;
463
464 s32 panel_crc_mode;
465
466 std::array<u8, 0x28> reserved_294C8;
467
468 // nn::settings::system::BacklightSettings
469 std::array<u8, 0x2C> backlight_settings_mixed_up;
470
471 std::array<u8, 0x64> reserved_2951C;
472
473 // nn::time::SystemClockContext
474 Service::Time::Clock::SystemClockContext user_system_clock_context;
475 Service::Time::Clock::SystemClockContext network_system_clock_context;
476 bool user_system_clock_automatic_correction_enabled;
477 std::array<u8, 0x3> pad_295C1;
478 std::array<u8, 0x4> reserved_295C4;
479 // nn::time::SteadyClockTimePoint
480 Service::Time::Clock::SteadyClockTimePoint
481 user_system_clock_automatic_correction_updated_time_point;
482
483 std::array<u8, 0x10> reserved_295E0;
484
485 // nn::settings::system::AccountSettings
486 AccountSettings account_settings;
487
488 std::array<u8, 0xFC> reserved_295F4;
489
490 // nn::settings::system::AudioVolume
491 std::array<u8, 0x8> audio_volume_type0;
492 std::array<u8, 0x8> audio_volume_type1;
493 // nn::settings::system::AudioOutputMode
494 s32 audio_output_mode_type0;
495 s32 audio_output_mode_type1;
496 s32 audio_output_mode_type2;
497 bool force_mute_on_headphone_removed;
498 std::array<u8, 0x3> pad_2970D;
499 s32 headphone_volume_warning_count;
500 bool heaphone_volume_update_flag;
501 std::array<u8, 0x3> pad_29715;
502 // nn::settings::system::AudioVolume
503 std::array<u8, 0x8> audio_volume_type2;
504 // nn::settings::system::AudioOutputMode
505 s32 audio_output_mode_type3;
506 s32 audio_output_mode_type4;
507 bool hearing_protection_safeguard_flag;
508 std::array<u8, 0x3> pad_29729;
509 std::array<u8, 0x4> reserved_2972C;
510 s64 hearing_protection_safeguard_remaining_time;
511 std::array<u8, 0x38> reserved_29738;
512
513 bool console_information_upload_flag;
514 std::array<u8, 0x3> pad_29771;
515
516 std::array<u8, 0x3C> reserved_29774;
517
518 bool automatic_application_download_flag;
519 std::array<u8, 0x3> pad_297B1;
520
521 std::array<u8, 0x4> reserved_297B4;
522
523 // nn::settings::system::NotificationSettings
524 NotificationSettings notification_settings;
525
526 std::array<u8, 0x60> reserved_297D0;
527
528 // nn::settings::system::AccountNotificationSettings
529 u32 account_notification_settings_count;
530 std::array<u8, 0xC> reserved_29834;
531 std::array<AccountNotificationSettings, 8> account_notification_settings;
532
533 std::array<u8, 0x140> reserved_29900;
534
535 f32 vibration_master_volume;
536
537 bool usb_full_key_enable_flag;
538 std::array<u8, 0x3> pad_29A45;
539
540 // nn::settings::system::AnalogStickUserCalibration
541 std::array<u8, 0x10> analog_stick_user_calibration_left;
542 std::array<u8, 0x10> analog_stick_user_calibration_right;
543
544 // nn::settings::system::TouchScreenMode
545 s32 touch_screen_mode;
546
547 std::array<u8, 0x14> reserved_29A6C;
548
549 // nn::settings::system::TvSettings
550 TvSettings tv_settings;
551
552 // nn::settings::system::Edid
553 std::array<u8, 0x100> edid;
554
555 std::array<u8, 0x2E0> reserved_29BA0;
556
557 // nn::settings::system::DataDeletionSettings
558 std::array<u8, 0x8> data_deletion_settings;
559
560 std::array<u8, 0x38> reserved_29E88;
561
562 // nn::ncm::ProgramId
563 std::array<u8, 0x8> initial_system_applet_program_id;
564 std::array<u8, 0x8> overlay_disp_program_id;
565
566 std::array<u8, 0x4> reserved_29ED0;
567
568 bool requires_run_repair_time_reviser;
569
570 std::array<u8, 0x6B> reserved_29ED5;
571
572 // nn::time::LocationName
573 Service::Time::TimeZone::LocationName device_time_zone_location_name;
574 std::array<u8, 0x4> reserved_29F64;
575 // nn::time::SteadyClockTimePoint
576 Service::Time::Clock::SteadyClockTimePoint device_time_zone_location_updated_time;
577
578 std::array<u8, 0xC0> reserved_29F80;
579
580 // nn::settings::system::PrimaryAlbumStorage
581 PrimaryAlbumStorage primary_album_storage;
582
583 std::array<u8, 0x3C> reserved_2A044;
584
585 bool usb_30_enable_flag;
586 std::array<u8, 0x3> pad_2A081;
587 bool usb_30_host_enable_flag;
588 std::array<u8, 0x3> pad_2A085;
589 bool usb_30_device_enable_flag;
590 std::array<u8, 0x3> pad_2A089;
591
592 std::array<u8, 0x34> reserved_2A08C;
593
594 bool nfc_enable_flag;
595 std::array<u8, 0x3> pad_2A0C1;
596
597 std::array<u8, 0x3C> reserved_2A0C4;
598
599 // nn::settings::system::SleepSettings
600 SleepSettings sleep_settings;
601
602 std::array<u8, 0x34> reserved_2A10C;
603
604 // nn::settings::system::EulaVersion
605 u32 eula_version_count;
606 std::array<u8, 0xC> reserved_2A144;
607 std::array<EulaVersion, 32> eula_versions;
608
609 std::array<u8, 0x200> reserved_2A750;
610
611 // nn::settings::system::DeviceNickName
612 std::array<u8, 0x80> device_nick_name;
613
614 std::array<u8, 0x80> reserved_2A9D0;
615
616 bool auto_update_enable_flag;
617 std::array<u8, 0x3> pad_2AA51;
618
619 std::array<u8, 0x4C> reserved_2AA54;
620
621 // nn::settings::system::BluetoothDevicesSettings
622 std::array<std::array<u8, 0x200>, 14> bluetooth_device_settings_last_14;
623
624 std::array<u8, 0x2000> reserved_2C6A0;
625
626 // nn::settings::system::NxControllerSettings
627 std::array<std::array<u8, 0x800>, 10> nx_controller_settings_data_from_offset_30;
628};
629
630static_assert(offsetof(SystemSettings, language_code) == 0x10);
631static_assert(offsetof(SystemSettings, network_setting_count) == 0x50);
632static_assert(offsetof(SystemSettings, network_settings_1B0) == 0x60);
633static_assert(offsetof(SystemSettings, bluetooth_device_settings_count) == 0x8060);
634static_assert(offsetof(SystemSettings, bluetooth_enable_flag) == 0x8064);
635static_assert(offsetof(SystemSettings, bluetooth_device_settings_first_10) == 0x8070);
636static_assert(offsetof(SystemSettings, ldn_channel) == 0x9470);
637static_assert(offsetof(SystemSettings, mii_author_id) == 0x94B0);
638static_assert(offsetof(SystemSettings, nx_controller_settings_count) == 0x94F0);
639static_assert(offsetof(SystemSettings, nx_controller_legacy_settings) == 0x9500);
640static_assert(offsetof(SystemSettings, external_rtc_reset_flag) == 0x98F0);
641static_assert(offsetof(SystemSettings, push_notification_activity_mode_on_sleep) == 0x9930);
642static_assert(offsetof(SystemSettings, allowed_ssl_host_count) == 0x99F4);
643static_assert(offsetof(SystemSettings, host_fs_mount_point) == 0x9A30);
644static_assert(offsetof(SystemSettings, allowed_ssl_hosts) == 0x9B30);
645static_assert(offsetof(SystemSettings, ble_pairing_settings_count) == 0xA9F0);
646static_assert(offsetof(SystemSettings, ble_pairing_settings) == 0xAA00);
647static_assert(offsetof(SystemSettings, account_online_storage_settings_count) == 0xAF00);
648static_assert(offsetof(SystemSettings, account_online_storage_settings) == 0xAF10);
649static_assert(offsetof(SystemSettings, pctl_ready_flag) == 0xB110);
650static_assert(offsetof(SystemSettings, theme_id_type0) == 0xB150);
651static_assert(offsetof(SystemSettings, chinese_traditional_input_method) == 0xB350);
652static_assert(offsetof(SystemSettings, button_config_registered_settings_count) == 0xB3D0);
653static_assert(offsetof(SystemSettings, button_config_settings_count) == 0xB3E0);
654static_assert(offsetof(SystemSettings, button_config_settings) == 0xB3E8);
655static_assert(offsetof(SystemSettings, button_config_registered_settings_embedded) == 0x1D3E0);
656static_assert(offsetof(SystemSettings, console_six_axis_sensor_acceleration_bias) == 0x29370);
657static_assert(offsetof(SystemSettings, lock_screen_flag) == 0x29470);
658static_assert(offsetof(SystemSettings, battery_percentage_flag) == 0x294A0);
659static_assert(offsetof(SystemSettings, field_testing_flag) == 0x294C0);
660static_assert(offsetof(SystemSettings, backlight_settings_mixed_up) == 0x294F0);
661static_assert(offsetof(SystemSettings, user_system_clock_context) == 0x29580);
662static_assert(offsetof(SystemSettings, network_system_clock_context) == 0x295A0);
663static_assert(offsetof(SystemSettings, user_system_clock_automatic_correction_enabled) == 0x295C0);
664static_assert(offsetof(SystemSettings, user_system_clock_automatic_correction_updated_time_point) ==
665 0x295C8);
666static_assert(offsetof(SystemSettings, account_settings) == 0x295F0);
667static_assert(offsetof(SystemSettings, audio_volume_type0) == 0x296F0);
668static_assert(offsetof(SystemSettings, hearing_protection_safeguard_remaining_time) == 0x29730);
669static_assert(offsetof(SystemSettings, automatic_application_download_flag) == 0x297B0);
670static_assert(offsetof(SystemSettings, notification_settings) == 0x297B8);
671static_assert(offsetof(SystemSettings, account_notification_settings) == 0x29840);
672static_assert(offsetof(SystemSettings, vibration_master_volume) == 0x29A40);
673static_assert(offsetof(SystemSettings, analog_stick_user_calibration_left) == 0x29A48);
674static_assert(offsetof(SystemSettings, touch_screen_mode) == 0x29A68);
675static_assert(offsetof(SystemSettings, edid) == 0x29AA0);
676static_assert(offsetof(SystemSettings, data_deletion_settings) == 0x29E80);
677static_assert(offsetof(SystemSettings, requires_run_repair_time_reviser) == 0x29ED4);
678static_assert(offsetof(SystemSettings, device_time_zone_location_name) == 0x29F40);
679static_assert(offsetof(SystemSettings, nfc_enable_flag) == 0x2A0C0);
680static_assert(offsetof(SystemSettings, eula_version_count) == 0x2A140);
681static_assert(offsetof(SystemSettings, device_nick_name) == 0x2A950);
682static_assert(offsetof(SystemSettings, bluetooth_device_settings_last_14) == 0x2AAA0);
683static_assert(offsetof(SystemSettings, nx_controller_settings_data_from_offset_30) == 0x2E6A0);
684
685static_assert(sizeof(SystemSettings) == 0x336A0, "SystemSettings has the wrong size!");
686
687SystemSettings DefaultSystemSettings();
688
689} // namespace Service::Set