summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt6
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt5
-rw-r--r--src/core/CMakeLists.txt17
-rw-r--r--src/core/hle/service/hid/hid.cpp2
-rw-r--r--src/core/hle/service/nfc/common/device.cpp5
-rw-r--r--src/core/hle/service/set/private_settings.h72
-rw-r--r--src/core/hle/service/set/setting_formats/appln_settings.cpp (renamed from src/core/hle/service/set/appln_settings.cpp)8
-rw-r--r--src/core/hle/service/set/setting_formats/appln_settings.h (renamed from src/core/hle/service/set/appln_settings.h)17
-rw-r--r--src/core/hle/service/set/setting_formats/device_settings.cpp (renamed from src/core/hle/service/set/device_settings.cpp)2
-rw-r--r--src/core/hle/service/set/setting_formats/device_settings.h (renamed from src/core/hle/service/set/device_settings.h)16
-rw-r--r--src/core/hle/service/set/setting_formats/private_settings.cpp (renamed from src/core/hle/service/set/private_settings.cpp)2
-rw-r--r--src/core/hle/service/set/setting_formats/private_settings.h39
-rw-r--r--src/core/hle/service/set/setting_formats/system_settings.cpp (renamed from src/core/hle/service/set/system_settings.cpp)8
-rw-r--r--src/core/hle/service/set/setting_formats/system_settings.h (renamed from src/core/hle/service/set/system_settings.h)496
-rw-r--r--src/core/hle/service/set/settings_server.h61
-rw-r--r--src/core/hle/service/set/settings_types.h451
-rw-r--r--src/core/hle/service/set/system_settings_server.cpp215
-rw-r--r--src/core/hle/service/set/system_settings_server.h48
-rw-r--r--src/hid_core/resources/hid_firmware_settings.cpp35
-rw-r--r--src/hid_core/resources/hid_firmware_settings.h12
-rw-r--r--src/input_common/CMakeLists.txt2
-rw-r--r--src/input_common/drivers/android.cpp48
-rw-r--r--src/input_common/drivers/android.h54
-rw-r--r--src/input_common/input_mapping.cpp3
-rw-r--r--src/input_common/main.cpp22
-rw-r--r--src/input_common/main.h7
-rw-r--r--src/shader_recompiler/backend/spirv/emit_spirv_image.cpp76
-rw-r--r--src/shader_recompiler/backend/spirv/emit_spirv_instructions.h2
28 files changed, 1049 insertions, 682 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt
index 93c8ce922..9b08f008d 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt
@@ -49,7 +49,6 @@ import org.yuzu.yuzu_emu.utils.ForegroundService
49import org.yuzu.yuzu_emu.utils.InputHandler 49import org.yuzu.yuzu_emu.utils.InputHandler
50import org.yuzu.yuzu_emu.utils.Log 50import org.yuzu.yuzu_emu.utils.Log
51import org.yuzu.yuzu_emu.utils.MemoryUtil 51import org.yuzu.yuzu_emu.utils.MemoryUtil
52import org.yuzu.yuzu_emu.utils.NativeConfig
53import org.yuzu.yuzu_emu.utils.NfcReader 52import org.yuzu.yuzu_emu.utils.NfcReader
54import org.yuzu.yuzu_emu.utils.ThemeHelper 53import org.yuzu.yuzu_emu.utils.ThemeHelper
55import java.text.NumberFormat 54import java.text.NumberFormat
@@ -171,11 +170,6 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
171 stopMotionSensorListener() 170 stopMotionSensorListener()
172 } 171 }
173 172
174 override fun onStop() {
175 super.onStop()
176 NativeConfig.saveGlobalConfig()
177 }
178
179 override fun onUserLeaveHint() { 173 override fun onUserLeaveHint() {
180 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) { 174 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
181 if (BooleanSetting.PICTURE_IN_PICTURE.getBoolean() && !isInPictureInPictureMode) { 175 if (BooleanSetting.PICTURE_IN_PICTURE.getBoolean() && !isInPictureInPictureMode) {
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt
index 9efc1705d..47767454a 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt
@@ -554,6 +554,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
554 findItem(R.id.menu_touchscreen).isChecked = BooleanSetting.TOUCHSCREEN.getBoolean() 554 findItem(R.id.menu_touchscreen).isChecked = BooleanSetting.TOUCHSCREEN.getBoolean()
555 } 555 }
556 556
557 popup.setOnDismissListener { NativeConfig.saveGlobalConfig() }
557 popup.setOnMenuItemClickListener { 558 popup.setOnMenuItemClickListener {
558 when (it.itemId) { 559 when (it.itemId) {
559 R.id.menu_toggle_fps -> { 560 R.id.menu_toggle_fps -> {
@@ -720,7 +721,9 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
720 MaterialAlertDialogBuilder(requireContext()) 721 MaterialAlertDialogBuilder(requireContext())
721 .setTitle(R.string.emulation_control_adjust) 722 .setTitle(R.string.emulation_control_adjust)
722 .setView(adjustBinding.root) 723 .setView(adjustBinding.root)
723 .setPositiveButton(android.R.string.ok, null) 724 .setPositiveButton(android.R.string.ok) { _: DialogInterface?, _: Int ->
725 NativeConfig.saveGlobalConfig()
726 }
724 .setNeutralButton(R.string.slider_default) { _: DialogInterface?, _: Int -> 727 .setNeutralButton(R.string.slider_default) { _: DialogInterface?, _: Int ->
725 setControlScale(50) 728 setControlScale(50)
726 setControlOpacity(100) 729 setControlOpacity(100)
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 293d9647b..16ddb5e90 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -712,22 +712,23 @@ add_library(core STATIC
712 hle/service/server_manager.h 712 hle/service/server_manager.h
713 hle/service/service.cpp 713 hle/service/service.cpp
714 hle/service/service.h 714 hle/service/service.h
715 hle/service/set/appln_settings.cpp 715 hle/service/set/setting_formats/appln_settings.cpp
716 hle/service/set/appln_settings.h 716 hle/service/set/setting_formats/appln_settings.h
717 hle/service/set/device_settings.cpp 717 hle/service/set/setting_formats/device_settings.cpp
718 hle/service/set/device_settings.h 718 hle/service/set/setting_formats/device_settings.h
719 hle/service/set/setting_formats/system_settings.cpp
720 hle/service/set/setting_formats/system_settings.h
721 hle/service/set/setting_formats/private_settings.cpp
722 hle/service/set/setting_formats/private_settings.h
719 hle/service/set/factory_settings_server.cpp 723 hle/service/set/factory_settings_server.cpp
720 hle/service/set/factory_settings_server.h 724 hle/service/set/factory_settings_server.h
721 hle/service/set/firmware_debug_settings_server.cpp 725 hle/service/set/firmware_debug_settings_server.cpp
722 hle/service/set/firmware_debug_settings_server.h 726 hle/service/set/firmware_debug_settings_server.h
723 hle/service/set/private_settings.cpp
724 hle/service/set/private_settings.h
725 hle/service/set/settings.cpp 727 hle/service/set/settings.cpp
726 hle/service/set/settings.h 728 hle/service/set/settings.h
727 hle/service/set/settings_server.cpp 729 hle/service/set/settings_server.cpp
728 hle/service/set/settings_server.h 730 hle/service/set/settings_server.h
729 hle/service/set/system_settings.cpp 731 hle/service/set/settings_types.h
730 hle/service/set/system_settings.h
731 hle/service/set/system_settings_server.cpp 732 hle/service/set/system_settings_server.cpp
732 hle/service/set/system_settings_server.h 733 hle/service/set/system_settings_server.h
733 hle/service/sm/sm.cpp 734 hle/service/sm/sm.cpp
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index 4ce0a9834..03ebdc137 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -20,7 +20,7 @@ void LoopProcess(Core::System& system) {
20 auto server_manager = std::make_unique<ServerManager>(system); 20 auto server_manager = std::make_unique<ServerManager>(system);
21 std::shared_ptr<ResourceManager> resource_manager = std::make_shared<ResourceManager>(system); 21 std::shared_ptr<ResourceManager> resource_manager = std::make_shared<ResourceManager>(system);
22 std::shared_ptr<HidFirmwareSettings> firmware_settings = 22 std::shared_ptr<HidFirmwareSettings> firmware_settings =
23 std::make_shared<HidFirmwareSettings>(); 23 std::make_shared<HidFirmwareSettings>(system);
24 24
25 // TODO: Remove this hack when am is emulated properly. 25 // TODO: Remove this hack when am is emulated properly.
26 resource_manager->Initialize(); 26 resource_manager->Initialize();
diff --git a/src/core/hle/service/nfc/common/device.cpp b/src/core/hle/service/nfc/common/device.cpp
index 31cc87acc..cc7776efc 100644
--- a/src/core/hle/service/nfc/common/device.cpp
+++ b/src/core/hle/service/nfc/common/device.cpp
@@ -441,7 +441,10 @@ Result NfcDevice::Mount(NFP::ModelType model_type, NFP::MountTarget mount_target
441 device_state = DeviceState::TagMounted; 441 device_state = DeviceState::TagMounted;
442 mount_target = mount_target_; 442 mount_target = mount_target_;
443 443
444 if (!is_corrupted && mount_target != NFP::MountTarget::Rom) { 444 const bool create_backup =
445 mount_target == NFP::MountTarget::All || mount_target == NFP::MountTarget::Ram ||
446 (mount_target == NFP::MountTarget::Rom && HasBackup(encrypted_tag_data.uuid).IsError());
447 if (!is_corrupted && create_backup) {
445 std::vector<u8> data(sizeof(NFP::EncryptedNTAG215File)); 448 std::vector<u8> data(sizeof(NFP::EncryptedNTAG215File));
446 memcpy(data.data(), &encrypted_tag_data, sizeof(encrypted_tag_data)); 449 memcpy(data.data(), &encrypted_tag_data, sizeof(encrypted_tag_data));
447 WriteBackupData(encrypted_tag_data.uuid, data); 450 WriteBackupData(encrypted_tag_data.uuid, data);
diff --git a/src/core/hle/service/set/private_settings.h b/src/core/hle/service/set/private_settings.h
deleted file mode 100644
index b63eaf45c..000000000
--- a/src/core/hle/service/set/private_settings.h
+++ /dev/null
@@ -1,72 +0,0 @@
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/appln_settings.cpp b/src/core/hle/service/set/setting_formats/appln_settings.cpp
index a5d802757..f7c7d5b91 100644
--- a/src/core/hle/service/set/appln_settings.cpp
+++ b/src/core/hle/service/set/setting_formats/appln_settings.cpp
@@ -1,12 +1,16 @@
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 "core/hle/service/set/appln_settings.h" 4#include "core/hle/service/set/setting_formats/appln_settings.h"
5 5
6namespace Service::Set { 6namespace Service::Set {
7 7
8ApplnSettings DefaultApplnSettings() { 8ApplnSettings DefaultApplnSettings() {
9 return {}; 9 ApplnSettings settings{};
10
11 settings.mii_author_id = Common::UUID::MakeDefault();
12
13 return settings;
10} 14}
11 15
12} // namespace Service::Set 16} // namespace Service::Set
diff --git a/src/core/hle/service/set/appln_settings.h b/src/core/hle/service/set/setting_formats/appln_settings.h
index 126375860..ba9af998a 100644
--- a/src/core/hle/service/set/appln_settings.h
+++ b/src/core/hle/service/set/setting_formats/appln_settings.h
@@ -7,24 +7,23 @@
7#include <cstddef> 7#include <cstddef>
8 8
9#include "common/common_types.h" 9#include "common/common_types.h"
10#include "common/uuid.h"
11#include "core/hle/service/set/settings_types.h"
10 12
11namespace Service::Set { 13namespace Service::Set {
12struct ApplnSettings { 14struct ApplnSettings {
13 std::array<u8, 0x10> reserved_000; 15 INSERT_PADDING_BYTES(0x10); // Reserved
14 16
15 // nn::util::Uuid MiiAuthorId, copied from system settings 0x94B0 17 // nn::util::Uuid MiiAuthorId, copied from system settings 0x94B0
16 std::array<u8, 0x10> mii_author_id; 18 Common::UUID mii_author_id;
17 19 INSERT_PADDING_BYTES(0x30); // Reserved
18 std::array<u8, 0x30> reserved_020;
19 20
20 // nn::settings::system::ServiceDiscoveryControlSettings 21 // nn::settings::system::ServiceDiscoveryControlSettings
21 std::array<u8, 0x4> service_discovery_control_settings; 22 u32 service_discovery_control_settings;
22 23 INSERT_PADDING_BYTES(0x20); // Reserved
23 std::array<u8, 0x20> reserved_054;
24 24
25 bool in_repair_process_enable_flag; 25 bool in_repair_process_enable_flag;
26 26 INSERT_PADDING_BYTES(0x3);
27 std::array<u8, 0x3> pad_075;
28}; 27};
29static_assert(offsetof(ApplnSettings, mii_author_id) == 0x10); 28static_assert(offsetof(ApplnSettings, mii_author_id) == 0x10);
30static_assert(offsetof(ApplnSettings, service_discovery_control_settings) == 0x50); 29static_assert(offsetof(ApplnSettings, service_discovery_control_settings) == 0x50);
diff --git a/src/core/hle/service/set/device_settings.cpp b/src/core/hle/service/set/setting_formats/device_settings.cpp
index e423ce38a..5f295404d 100644
--- a/src/core/hle/service/set/device_settings.cpp
+++ b/src/core/hle/service/set/setting_formats/device_settings.cpp
@@ -1,7 +1,7 @@
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 "core/hle/service/set/device_settings.h" 4#include "core/hle/service/set/setting_formats/device_settings.h"
5 5
6namespace Service::Set { 6namespace Service::Set {
7 7
diff --git a/src/core/hle/service/set/device_settings.h b/src/core/hle/service/set/setting_formats/device_settings.h
index f291d0ebe..2827756f6 100644
--- a/src/core/hle/service/set/device_settings.h
+++ b/src/core/hle/service/set/setting_formats/device_settings.h
@@ -7,10 +7,12 @@
7#include <cstddef> 7#include <cstddef>
8 8
9#include "common/common_types.h" 9#include "common/common_types.h"
10#include "common/vector_math.h"
11#include "core/hle/service/set/settings_types.h"
10 12
11namespace Service::Set { 13namespace Service::Set {
12struct DeviceSettings { 14struct DeviceSettings {
13 std::array<u8, 0x10> reserved_000; 15 INSERT_PADDING_BYTES(0x10); // Reserved
14 16
15 // nn::settings::BatteryLot 17 // nn::settings::BatteryLot
16 std::array<u8, 0x18> ptm_battery_lot; 18 std::array<u8, 0x18> ptm_battery_lot;
@@ -19,26 +21,24 @@ struct DeviceSettings {
19 u8 ptm_battery_version; 21 u8 ptm_battery_version;
20 // nn::settings::system::PtmCycleCountReliability 22 // nn::settings::system::PtmCycleCountReliability
21 u32 ptm_cycle_count_reliability; 23 u32 ptm_cycle_count_reliability;
22 24 INSERT_PADDING_BYTES(0x48); // Reserved
23 std::array<u8, 0x48> reserved_048;
24 25
25 // nn::settings::system::AnalogStickUserCalibration L 26 // nn::settings::system::AnalogStickUserCalibration L
26 std::array<u8, 0x10> analog_user_stick_calibration_l; 27 std::array<u8, 0x10> analog_user_stick_calibration_l;
27 // nn::settings::system::AnalogStickUserCalibration R 28 // nn::settings::system::AnalogStickUserCalibration R
28 std::array<u8, 0x10> analog_user_stick_calibration_r; 29 std::array<u8, 0x10> analog_user_stick_calibration_r;
29 30 INSERT_PADDING_BYTES(0x20); // Reserved
30 std::array<u8, 0x20> reserved_0B0;
31 31
32 // nn::settings::system::ConsoleSixAxisSensorAccelerationBias 32 // nn::settings::system::ConsoleSixAxisSensorAccelerationBias
33 std::array<u8, 0xC> console_six_axis_sensor_acceleration_bias; 33 Common::Vec3<f32> console_six_axis_sensor_acceleration_bias;
34 // nn::settings::system::ConsoleSixAxisSensorAngularVelocityBias 34 // nn::settings::system::ConsoleSixAxisSensorAngularVelocityBias
35 std::array<u8, 0xC> console_six_axis_sensor_angular_velocity_bias; 35 Common::Vec3<f32> console_six_axis_sensor_angular_velocity_bias;
36 // nn::settings::system::ConsoleSixAxisSensorAccelerationGain 36 // nn::settings::system::ConsoleSixAxisSensorAccelerationGain
37 std::array<u8, 0x24> console_six_axis_sensor_acceleration_gain; 37 std::array<u8, 0x24> console_six_axis_sensor_acceleration_gain;
38 // nn::settings::system::ConsoleSixAxisSensorAngularVelocityGain 38 // nn::settings::system::ConsoleSixAxisSensorAngularVelocityGain
39 std::array<u8, 0x24> console_six_axis_sensor_angular_velocity_gain; 39 std::array<u8, 0x24> console_six_axis_sensor_angular_velocity_gain;
40 // nn::settings::system::ConsoleSixAxisSensorAngularVelocityTimeBias 40 // nn::settings::system::ConsoleSixAxisSensorAngularVelocityTimeBias
41 std::array<u8, 0xC> console_six_axis_sensor_angular_velocity_time_bias; 41 Common::Vec3<f32> console_six_axis_sensor_angular_velocity_time_bias;
42 // nn::settings::system::ConsoleSixAxisSensorAngularAcceleration 42 // nn::settings::system::ConsoleSixAxisSensorAngularAcceleration
43 std::array<u8, 0x24> console_six_axis_sensor_angular_acceleration; 43 std::array<u8, 0x24> console_six_axis_sensor_angular_acceleration;
44}; 44};
diff --git a/src/core/hle/service/set/private_settings.cpp b/src/core/hle/service/set/setting_formats/private_settings.cpp
index 70bf65727..81c362482 100644
--- a/src/core/hle/service/set/private_settings.cpp
+++ b/src/core/hle/service/set/setting_formats/private_settings.cpp
@@ -1,7 +1,7 @@
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 "core/hle/service/set/private_settings.h" 4#include "core/hle/service/set/setting_formats/private_settings.h"
5 5
6namespace Service::Set { 6namespace Service::Set {
7 7
diff --git a/src/core/hle/service/set/setting_formats/private_settings.h b/src/core/hle/service/set/setting_formats/private_settings.h
new file mode 100644
index 000000000..6c40f62e1
--- /dev/null
+++ b/src/core/hle/service/set/setting_formats/private_settings.h
@@ -0,0 +1,39 @@
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#include "common/uuid.h"
10#include "core/hle/service/set/settings_types.h"
11#include "core/hle/service/time/clock_types.h"
12
13namespace Service::Set {
14
15struct PrivateSettings {
16 INSERT_PADDING_BYTES(0x10); // Reserved
17
18 InitialLaunchSettings initial_launch_settings;
19 INSERT_PADDING_BYTES(0x20); // Reserved
20
21 Common::UUID external_clock_source_id;
22 s64 shutdown_rtc_value;
23 s64 external_steady_clock_internal_offset;
24 INSERT_PADDING_BYTES(0x60); // Reserved
25
26 // nn::settings::system::PlatformRegion
27 s32 platform_region;
28 INSERT_PADDING_BYTES(0x4); // Reserved
29};
30static_assert(offsetof(PrivateSettings, initial_launch_settings) == 0x10);
31static_assert(offsetof(PrivateSettings, external_clock_source_id) == 0x50);
32static_assert(offsetof(PrivateSettings, shutdown_rtc_value) == 0x60);
33static_assert(offsetof(PrivateSettings, external_steady_clock_internal_offset) == 0x68);
34static_assert(offsetof(PrivateSettings, platform_region) == 0xD0);
35static_assert(sizeof(PrivateSettings) == 0xD8, "PrivateSettings has the wrong size!");
36
37PrivateSettings DefaultPrivateSettings();
38
39} // namespace Service::Set
diff --git a/src/core/hle/service/set/system_settings.cpp b/src/core/hle/service/set/setting_formats/system_settings.cpp
index 5977429b2..66e57651e 100644
--- a/src/core/hle/service/set/system_settings.cpp
+++ b/src/core/hle/service/set/setting_formats/system_settings.cpp
@@ -1,7 +1,7 @@
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 "core/hle/service/set/system_settings.h" 4#include "core/hle/service/set/setting_formats/system_settings.h"
5 5
6namespace Service::Set { 6namespace Service::Set {
7 7
@@ -11,6 +11,8 @@ SystemSettings DefaultSystemSettings() {
11 settings.version = 0x140000; 11 settings.version = 0x140000;
12 settings.flags = 7; 12 settings.flags = 7;
13 13
14 settings.mii_author_id = Common::UUID::MakeDefault();
15
14 settings.color_set_id = ColorSet::BasicWhite; 16 settings.color_set_id = ColorSet::BasicWhite;
15 17
16 settings.notification_settings = { 18 settings.notification_settings = {
@@ -45,6 +47,10 @@ SystemSettings DefaultSystemSettings() {
45 settings.device_time_zone_location_name = {"UTC"}; 47 settings.device_time_zone_location_name = {"UTC"};
46 settings.user_system_clock_automatic_correction_enabled = false; 48 settings.user_system_clock_automatic_correction_enabled = false;
47 49
50 settings.primary_album_storage = PrimaryAlbumStorage::SdCard;
51 settings.battery_percentage_flag = true;
52 settings.chinese_traditional_input_method = ChineseTraditionalInputMethod::Unknown0;
53
48 return settings; 54 return settings;
49} 55}
50 56
diff --git a/src/core/hle/service/set/system_settings.h b/src/core/hle/service/set/setting_formats/system_settings.h
index 6ec9e71e7..14654f8b1 100644
--- a/src/core/hle/service/set/system_settings.h
+++ b/src/core/hle/service/set/setting_formats/system_settings.h
@@ -8,272 +8,14 @@
8#include "common/bit_field.h" 8#include "common/bit_field.h"
9#include "common/common_funcs.h" 9#include "common/common_funcs.h"
10#include "common/common_types.h" 10#include "common/common_types.h"
11#include "core/hle/service/set/private_settings.h" 11#include "common/uuid.h"
12#include "common/vector_math.h"
13#include "core/hle/service/set/setting_formats/private_settings.h"
14#include "core/hle/service/set/settings_types.h"
12#include "core/hle/service/time/clock_types.h" 15#include "core/hle/service/time/clock_types.h"
13 16
14namespace Service::Set { 17namespace Service::Set {
15 18
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/// This is nn::settings::system::HomeMenuScheme
53struct HomeMenuScheme {
54 u32 main;
55 u32 back;
56 u32 sub;
57 u32 bezel;
58 u32 extra;
59};
60static_assert(sizeof(HomeMenuScheme) == 0x14, "HomeMenuScheme is incorrect size");
61
62/// Indicates the current theme set by the system settings
63enum class ColorSet : u32 {
64 BasicWhite = 0,
65 BasicBlack = 1,
66};
67
68/// Indicates the current console is a retail or kiosk unit
69enum class QuestFlag : u8 {
70 Retail = 0,
71 Kiosk = 1,
72};
73
74/// This is nn::settings::system::RegionCode
75enum class RegionCode : u32 {
76 Japan,
77 Usa,
78 Europe,
79 Australia,
80 HongKongTaiwanKorea,
81 China,
82};
83
84/// This is nn::settings::system::AccountSettings
85struct AccountSettings {
86 u32 flags;
87};
88static_assert(sizeof(AccountSettings) == 4, "AccountSettings is an invalid size");
89
90/// This is nn::settings::system::NotificationVolume
91enum class NotificationVolume : u32 {
92 Mute,
93 Low,
94 High,
95};
96
97/// This is nn::settings::system::NotificationFlag
98struct NotificationFlag {
99 union {
100 u32 raw{};
101
102 BitField<0, 1, u32> RingtoneFlag;
103 BitField<1, 1, u32> DownloadCompletionFlag;
104 BitField<8, 1, u32> EnablesNews;
105 BitField<9, 1, u32> IncomingLampFlag;
106 };
107};
108static_assert(sizeof(NotificationFlag) == 4, "NotificationFlag is an invalid size");
109
110/// This is nn::settings::system::NotificationTime
111struct NotificationTime {
112 u32 hour;
113 u32 minute;
114};
115static_assert(sizeof(NotificationTime) == 0x8, "NotificationTime is an invalid size");
116
117/// This is nn::settings::system::NotificationSettings
118struct NotificationSettings {
119 NotificationFlag flags;
120 NotificationVolume volume;
121 NotificationTime start_time;
122 NotificationTime stop_time;
123};
124static_assert(sizeof(NotificationSettings) == 0x18, "NotificationSettings is an invalid size");
125
126/// This is nn::settings::system::AccountNotificationFlag
127struct AccountNotificationFlag {
128 union {
129 u32 raw{};
130
131 BitField<0, 1, u32> FriendOnlineFlag;
132 BitField<1, 1, u32> FriendRequestFlag;
133 BitField<8, 1, u32> CoralInvitationFlag;
134 };
135};
136static_assert(sizeof(AccountNotificationFlag) == 4, "AccountNotificationFlag is an invalid size");
137
138/// This is nn::settings::system::FriendPresenceOverlayPermission
139enum class FriendPresenceOverlayPermission : u8 {
140 NotConfirmed,
141 NoDisplay,
142 FavoriteFriends,
143 Friends,
144};
145
146/// This is nn::settings::system::AccountNotificationSettings
147struct AccountNotificationSettings {
148 Common::UUID uid;
149 AccountNotificationFlag flags;
150 FriendPresenceOverlayPermission friend_presence_permission;
151 FriendPresenceOverlayPermission friend_invitation_permission;
152 INSERT_PADDING_BYTES(0x2);
153};
154static_assert(sizeof(AccountNotificationSettings) == 0x18,
155 "AccountNotificationSettings is an invalid size");
156
157/// This is nn::settings::system::TvFlag
158struct TvFlag {
159 union {
160 u32 raw{};
161
162 BitField<0, 1, u32> Allows4k;
163 BitField<1, 1, u32> Allows3d;
164 BitField<2, 1, u32> AllowsCec;
165 BitField<3, 1, u32> PreventsScreenBurnIn;
166 };
167};
168static_assert(sizeof(TvFlag) == 4, "TvFlag is an invalid size");
169
170/// This is nn::settings::system::TvResolution
171enum class TvResolution : u32 {
172 Auto,
173 Resolution1080p,
174 Resolution720p,
175 Resolution480p,
176};
177
178/// This is nn::settings::system::HdmiContentType
179enum class HdmiContentType : u32 {
180 None,
181 Graphics,
182 Cinema,
183 Photo,
184 Game,
185};
186
187/// This is nn::settings::system::RgbRange
188enum class RgbRange : u32 {
189 Auto,
190 Full,
191 Limited,
192};
193
194/// This is nn::settings::system::CmuMode
195enum class CmuMode : u32 {
196 None,
197 ColorInvert,
198 HighContrast,
199 GrayScale,
200};
201
202/// This is nn::settings::system::TvSettings
203struct TvSettings {
204 TvFlag flags;
205 TvResolution tv_resolution;
206 HdmiContentType hdmi_content_type;
207 RgbRange rgb_range;
208 CmuMode cmu_mode;
209 u32 tv_underscan;
210 f32 tv_gama;
211 f32 contrast_ratio;
212};
213static_assert(sizeof(TvSettings) == 0x20, "TvSettings is an invalid size");
214
215/// This is nn::settings::system::PrimaryAlbumStorage
216enum class PrimaryAlbumStorage : u32 {
217 Nand,
218 SdCard,
219};
220
221/// This is nn::settings::system::HandheldSleepPlan
222enum class HandheldSleepPlan : u32 {
223 Sleep1Min,
224 Sleep3Min,
225 Sleep5Min,
226 Sleep10Min,
227 Sleep30Min,
228 Never,
229};
230
231/// This is nn::settings::system::ConsoleSleepPlan
232enum class ConsoleSleepPlan : u32 {
233 Sleep1Hour,
234 Sleep2Hour,
235 Sleep3Hour,
236 Sleep6Hour,
237 Sleep12Hour,
238 Never,
239};
240
241/// This is nn::settings::system::SleepFlag
242struct SleepFlag {
243 union {
244 u32 raw{};
245
246 BitField<0, 1, u32> SleepsWhilePlayingMedia;
247 BitField<1, 1, u32> WakesAtPowerStateChange;
248 };
249};
250static_assert(sizeof(SleepFlag) == 4, "TvFlag is an invalid size");
251
252/// This is nn::settings::system::SleepSettings
253struct SleepSettings {
254 SleepFlag flags;
255 HandheldSleepPlan handheld_sleep_plan;
256 ConsoleSleepPlan console_sleep_plan;
257};
258static_assert(sizeof(SleepSettings) == 0xc, "SleepSettings is incorrect size");
259
260/// This is nn::settings::system::EulaVersionClockType
261enum class EulaVersionClockType : u32 {
262 NetworkSystemClock,
263 SteadyClock,
264};
265
266/// This is nn::settings::system::EulaVersion
267struct EulaVersion {
268 u32 version;
269 RegionCode region_code;
270 EulaVersionClockType clock_type;
271 INSERT_PADDING_BYTES(0x4);
272 s64 posix_time;
273 Time::Clock::SteadyClockTimePoint timestamp;
274};
275static_assert(sizeof(EulaVersion) == 0x30, "EulaVersion is incorrect size");
276
277struct SystemSettings { 19struct SystemSettings {
278 // 0/unwritten (1.0.0), 0x20000 (2.0.0), 0x30000 (3.0.0-3.0.1), 0x40001 (4.0.0-4.1.0), 0x50000 20 // 0/unwritten (1.0.0), 0x20000 (2.0.0), 0x30000 (3.0.0-3.0.1), 0x40001 (4.0.0-4.1.0), 0x50000
279 // (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 21 // (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
@@ -283,20 +25,16 @@ struct SystemSettings {
283 // 0/unwritten (1.0.0), 1 (6.0.0-8.1.0), 2 (8.1.1), 7 (9.0.0+). 25 // 0/unwritten (1.0.0), 1 (6.0.0-8.1.0), 2 (8.1.1), 7 (9.0.0+).
284 // if (flags & 2), defaults are written for AnalogStickUserCalibration 26 // if (flags & 2), defaults are written for AnalogStickUserCalibration
285 u32 flags; 27 u32 flags;
28 INSERT_PADDING_BYTES(0x8); // Reserved
286 29
287 std::array<u8, 0x8> reserved_00008;
288
289 // nn::settings::LanguageCode
290 LanguageCode language_code; 30 LanguageCode language_code;
291 31 INSERT_PADDING_BYTES(0x38); // Reserved
292 std::array<u8, 0x38> reserved_00018;
293 32
294 // nn::settings::system::NetworkSettings 33 // nn::settings::system::NetworkSettings
295 u32 network_setting_count; 34 u32 network_setting_count;
296 bool wireless_lan_enable_flag; 35 bool wireless_lan_enable_flag;
297 std::array<u8, 0x3> pad_00055; 36 INSERT_PADDING_BYTES(0x3);
298 37 INSERT_PADDING_BYTES(0x8); // Reserved
299 std::array<u8, 0x8> reserved_00058;
300 38
301 // nn::settings::system::NetworkSettings 39 // nn::settings::system::NetworkSettings
302 std::array<std::array<u8, 0x400>, 32> network_settings_1B0; 40 std::array<std::array<u8, 0x400>, 32> network_settings_1B0;
@@ -304,161 +42,142 @@ struct SystemSettings {
304 // nn::settings::system::BluetoothDevicesSettings 42 // nn::settings::system::BluetoothDevicesSettings
305 std::array<u8, 0x4> bluetooth_device_settings_count; 43 std::array<u8, 0x4> bluetooth_device_settings_count;
306 bool bluetooth_enable_flag; 44 bool bluetooth_enable_flag;
307 std::array<u8, 0x3> pad_08065; 45 INSERT_PADDING_BYTES(0x3);
308 bool bluetooth_afh_enable_flag; 46 bool bluetooth_afh_enable_flag;
309 std::array<u8, 0x3> pad_08069; 47 INSERT_PADDING_BYTES(0x3);
310 bool bluetooth_boost_enable_flag; 48 bool bluetooth_boost_enable_flag;
311 std::array<u8, 0x3> pad_0806D; 49 INSERT_PADDING_BYTES(0x3);
312 std::array<std::array<u8, 0x200>, 10> bluetooth_device_settings_first_10; 50 std::array<std::array<u8, 0x200>, 10> bluetooth_device_settings_first_10;
313 51
314 s32 ldn_channel; 52 s32 ldn_channel;
315 53 INSERT_PADDING_BYTES(0x3C); // Reserved
316 std::array<u8, 0x3C> reserved_09474;
317 54
318 // nn::util::Uuid MiiAuthorId 55 // nn::util::Uuid MiiAuthorId
319 std::array<u8, 0x10> mii_author_id; 56 Common::UUID mii_author_id;
320 57
321 std::array<u8, 0x30> reserved_094C0; 58 INSERT_PADDING_BYTES(0x30); // Reserved
322 59
323 // nn::settings::system::NxControllerSettings 60 // nn::settings::system::NxControllerSettings
324 u32 nx_controller_settings_count; 61 u32 nx_controller_settings_count;
325 62
326 std::array<u8, 0xC> reserved_094F4; 63 INSERT_PADDING_BYTES(0xC); // Reserved
327 64
328 // nn::settings::system::NxControllerSettings, 65 // nn::settings::system::NxControllerSettings,
329 // nn::settings::system::NxControllerLegacySettings on 13.0.0+ 66 // nn::settings::system::NxControllerLegacySettings on 13.0.0+
330 std::array<std::array<u8, 0x40>, 10> nx_controller_legacy_settings; 67 std::array<std::array<u8, 0x40>, 10> nx_controller_legacy_settings;
331 68 INSERT_PADDING_BYTES(0x170); // Reserved
332 std::array<u8, 0x170> reserved_09780;
333 69
334 bool external_rtc_reset_flag; 70 bool external_rtc_reset_flag;
335 std::array<u8, 0x3> pad_098F1; 71 INSERT_PADDING_BYTES(0x3);
336 72 INSERT_PADDING_BYTES(0x3C); // Reserved
337 std::array<u8, 0x3C> reserved_098F4;
338 73
339 s32 push_notification_activity_mode_on_sleep; 74 s32 push_notification_activity_mode_on_sleep;
75 INSERT_PADDING_BYTES(0x3C); // Reserved
340 76
341 std::array<u8, 0x3C> reserved_09934;
342
343 // nn::settings::system::ErrorReportSharePermission
344 ErrorReportSharePermission error_report_share_permission; 77 ErrorReportSharePermission error_report_share_permission;
78 INSERT_PADDING_BYTES(0x3C); // Reserved
345 79
346 std::array<u8, 0x3C> reserved_09974; 80 KeyboardLayout keyboard_layout;
347 81 INSERT_PADDING_BYTES(0x3C); // Reserved
348 // nn::settings::KeyboardLayout
349 std::array<u8, 0x4> keyboard_layout;
350
351 std::array<u8, 0x3C> reserved_099B4;
352 82
353 bool web_inspector_flag; 83 bool web_inspector_flag;
354 std::array<u8, 0x3> pad_099F1; 84 INSERT_PADDING_BYTES(0x3);
355 85
356 // nn::settings::system::AllowedSslHost 86 // nn::settings::system::AllowedSslHost
357 u32 allowed_ssl_host_count; 87 u32 allowed_ssl_host_count;
358 88
359 bool memory_usage_rate_flag; 89 bool memory_usage_rate_flag;
360 std::array<u8, 0x3> pad_099F9; 90 INSERT_PADDING_BYTES(0x3);
361 91 INSERT_PADDING_BYTES(0x34); // Reserved
362 std::array<u8, 0x34> reserved_099FC;
363 92
364 // nn::settings::system::HostFsMountPoint 93 // nn::settings::system::HostFsMountPoint
365 std::array<u8, 0x100> host_fs_mount_point; 94 std::array<u8, 0x100> host_fs_mount_point;
366 95
367 // nn::settings::system::AllowedSslHost 96 // nn::settings::system::AllowedSslHost
368 std::array<std::array<u8, 0x100>, 8> allowed_ssl_hosts; 97 std::array<std::array<u8, 0x100>, 8> allowed_ssl_hosts;
369 98 INSERT_PADDING_BYTES(0x6C0); // Reserved
370 std::array<u8, 0x6C0> reserved_0A330;
371 99
372 // nn::settings::system::BlePairingSettings 100 // nn::settings::system::BlePairingSettings
373 u32 ble_pairing_settings_count; 101 u32 ble_pairing_settings_count;
374 std::array<u8, 0xC> reserved_0A9F4; 102 INSERT_PADDING_BYTES(0xC); // Reserved
375 std::array<std::array<u8, 0x80>, 10> ble_pairing_settings; 103 std::array<std::array<u8, 0x80>, 10> ble_pairing_settings;
376 104
377 // nn::settings::system::AccountOnlineStorageSettings 105 // nn::settings::system::AccountOnlineStorageSettings
378 u32 account_online_storage_settings_count; 106 u32 account_online_storage_settings_count;
379 std::array<u8, 0xC> reserved_0AF04; 107 INSERT_PADDING_BYTES(0xC); // Reserved
380 std::array<std::array<u8, 0x40>, 8> account_online_storage_settings; 108 std::array<std::array<u8, 0x40>, 8> account_online_storage_settings;
381 109
382 bool pctl_ready_flag; 110 bool pctl_ready_flag;
383 std::array<u8, 0x3> pad_0B111; 111 INSERT_PADDING_BYTES(0x3);
384 112 INSERT_PADDING_BYTES(0x3C); // Reserved
385 std::array<u8, 0x3C> reserved_0B114;
386 113
387 // nn::settings::system::ThemeId 114 // nn::settings::system::ThemeId
388 std::array<u8, 0x80> theme_id_type0; 115 std::array<u8, 0x80> theme_id_type0;
389 std::array<u8, 0x80> theme_id_type1; 116 std::array<u8, 0x80> theme_id_type1;
117 INSERT_PADDING_BYTES(0x100); // Reserved
390 118
391 std::array<u8, 0x100> reserved_0B250;
392
393 // nn::settings::ChineseTraditionalInputMethod
394 ChineseTraditionalInputMethod chinese_traditional_input_method; 119 ChineseTraditionalInputMethod chinese_traditional_input_method;
395 120 INSERT_PADDING_BYTES(0x3C); // Reserved
396 std::array<u8, 0x3C> reserved_0B354;
397 121
398 bool zoom_flag; 122 bool zoom_flag;
399 std::array<u8, 0x3> pad_0B391; 123 INSERT_PADDING_BYTES(0x3);
400 124 INSERT_PADDING_BYTES(0x3C); // Reserved
401 std::array<u8, 0x3C> reserved_0B394;
402 125
403 // nn::settings::system::ButtonConfigRegisteredSettings 126 // nn::settings::system::ButtonConfigRegisteredSettings
404 u32 button_config_registered_settings_count; 127 u32 button_config_registered_settings_count;
405 std::array<u8, 0xC> reserved_0B3D4; 128 INSERT_PADDING_BYTES(0xC); // Reserved
406 129
407 // nn::settings::system::ButtonConfigSettings 130 // nn::settings::system::ButtonConfigSettings
408 u32 button_config_settings_count; 131 u32 button_config_settings_count;
409 std::array<u8, 0x4> reserved_0B3E4; 132 INSERT_PADDING_BYTES(0x4); // Reserved
410 std::array<std::array<u8, 0x5A8>, 5> button_config_settings; 133 std::array<std::array<u8, 0x5A8>, 5> button_config_settings;
411 std::array<u8, 0x13B0> reserved_0D030; 134 INSERT_PADDING_BYTES(0x13B0); // Reserved
412 u32 button_config_settings_embedded_count; 135 u32 button_config_settings_embedded_count;
413 std::array<u8, 0x4> reserved_0E3E4; 136 INSERT_PADDING_BYTES(0x4); // Reserved
414 std::array<std::array<u8, 0x5A8>, 5> button_config_settings_embedded; 137 std::array<std::array<u8, 0x5A8>, 5> button_config_settings_embedded;
415 std::array<u8, 0x13B0> reserved_10030; 138 INSERT_PADDING_BYTES(0x13B0); // Reserved
416 u32 button_config_settings_left_count; 139 u32 button_config_settings_left_count;
417 std::array<u8, 0x4> reserved_113E4; 140 INSERT_PADDING_BYTES(0x4); // Reserved
418 std::array<std::array<u8, 0x5A8>, 5> button_config_settings_left; 141 std::array<std::array<u8, 0x5A8>, 5> button_config_settings_left;
419 std::array<u8, 0x13B0> reserved_13030; 142 INSERT_PADDING_BYTES(0x13B0); // Reserved
420 u32 button_config_settings_right_count; 143 u32 button_config_settings_right_count;
421 std::array<u8, 0x4> reserved_143E4; 144 INSERT_PADDING_BYTES(0x4); // Reserved
422 std::array<std::array<u8, 0x5A8>, 5> button_config_settings_right; 145 std::array<std::array<u8, 0x5A8>, 5> button_config_settings_right;
423 std::array<u8, 0x73B0> reserved_16030; 146 INSERT_PADDING_BYTES(0x73B0); // Reserved
424 // nn::settings::system::ButtonConfigRegisteredSettings 147 // nn::settings::system::ButtonConfigRegisteredSettings
425 std::array<u8, 0x5C8> button_config_registered_settings_embedded; 148 std::array<u8, 0x5C8> button_config_registered_settings_embedded;
426 std::array<std::array<u8, 0x5C8>, 10> button_config_registered_settings; 149 std::array<std::array<u8, 0x5C8>, 10> button_config_registered_settings;
427 150 INSERT_PADDING_BYTES(0x7FF8); // Reserved
428 std::array<u8, 0x7FF8> reserved_21378;
429 151
430 // nn::settings::system::ConsoleSixAxisSensorAccelerationBias 152 // nn::settings::system::ConsoleSixAxisSensorAccelerationBias
431 std::array<u8, 0xC> console_six_axis_sensor_acceleration_bias; 153 Common::Vec3<f32> console_six_axis_sensor_acceleration_bias;
432 // nn::settings::system::ConsoleSixAxisSensorAngularVelocityBias 154 // nn::settings::system::ConsoleSixAxisSensorAngularVelocityBias
433 std::array<u8, 0xC> console_six_axis_sensor_angular_velocity_bias; 155 Common::Vec3<f32> console_six_axis_sensor_angular_velocity_bias;
434 // nn::settings::system::ConsoleSixAxisSensorAccelerationGain 156 // nn::settings::system::ConsoleSixAxisSensorAccelerationGain
435 std::array<u8, 0x24> console_six_axis_sensor_acceleration_gain; 157 std::array<u8, 0x24> console_six_axis_sensor_acceleration_gain;
436 // nn::settings::system::ConsoleSixAxisSensorAngularVelocityGain 158 // nn::settings::system::ConsoleSixAxisSensorAngularVelocityGain
437 std::array<u8, 0x24> console_six_axis_sensor_angular_velocity_gain; 159 std::array<u8, 0x24> console_six_axis_sensor_angular_velocity_gain;
438 // nn::settings::system::ConsoleSixAxisSensorAngularVelocityTimeBias 160 // nn::settings::system::ConsoleSixAxisSensorAngularVelocityTimeBias
439 std::array<u8, 0xC> console_six_axis_sensor_angular_velocity_time_bias; 161 Common::Vec3<f32> console_six_axis_sensor_angular_velocity_time_bias;
440 // nn::settings::system::ConsoleSixAxisSensorAngularAcceleration 162 // nn::settings::system::ConsoleSixAxisSensorAngularAcceleration
441 std::array<u8, 0x24> console_six_axis_sensor_angular_velocity_acceleration; 163 std::array<u8, 0x24> console_six_axis_sensor_angular_velocity_acceleration;
442 164 INSERT_PADDING_BYTES(0x70); // Reserved
443 std::array<u8, 0x70> reserved_29400;
444 165
445 bool lock_screen_flag; 166 bool lock_screen_flag;
446 std::array<u8, 0x3> pad_29471; 167 INSERT_PADDING_BYTES(0x3);
447 168 INSERT_PADDING_BYTES(0x4); // Reserved
448 std::array<u8, 0x4> reserved_249274;
449 169
450 ColorSet color_set_id; 170 ColorSet color_set_id;
451 171
452 QuestFlag quest_flag; 172 QuestFlag quest_flag;
453 173
454 // nn::settings::system::RegionCode 174 SystemRegionCode region_code;
455 RegionCode region_code;
456 175
457 // Different to nn::settings::system::InitialLaunchSettings? 176 // Different to nn::settings::system::InitialLaunchSettings?
458 InitialLaunchSettingsPacked initial_launch_settings_packed; 177 InitialLaunchSettingsPacked initial_launch_settings_packed;
459 178
460 bool battery_percentage_flag; 179 bool battery_percentage_flag;
461 std::array<u8, 0x3> pad_294A1; 180 INSERT_PADDING_BYTES(0x3);
462 181
463 // BitFlagSet<32, nn::settings::system::AppletLaunchFlag> 182 // BitFlagSet<32, nn::settings::system::AppletLaunchFlag>
464 u32 applet_launch_flag; 183 u32 applet_launch_flag;
@@ -469,33 +188,26 @@ struct SystemSettings {
469 std::array<u8, 0x10> theme_key; 188 std::array<u8, 0x10> theme_key;
470 189
471 bool field_testing_flag; 190 bool field_testing_flag;
472 std::array<u8, 0x3> pad_294C1; 191 INSERT_PADDING_BYTES(0x3);
473 192
474 s32 panel_crc_mode; 193 s32 panel_crc_mode;
475 194 INSERT_PADDING_BYTES(0x28); // Reserved
476 std::array<u8, 0x28> reserved_294C8;
477 195
478 // nn::settings::system::BacklightSettings 196 // nn::settings::system::BacklightSettings
479 std::array<u8, 0x2C> backlight_settings_mixed_up; 197 std::array<u8, 0x2C> backlight_settings_mixed_up;
198 INSERT_PADDING_BYTES(0x64); // Reserved
480 199
481 std::array<u8, 0x64> reserved_2951C;
482
483 // nn::time::SystemClockContext
484 Service::Time::Clock::SystemClockContext user_system_clock_context; 200 Service::Time::Clock::SystemClockContext user_system_clock_context;
485 Service::Time::Clock::SystemClockContext network_system_clock_context; 201 Service::Time::Clock::SystemClockContext network_system_clock_context;
486 bool user_system_clock_automatic_correction_enabled; 202 bool user_system_clock_automatic_correction_enabled;
487 std::array<u8, 0x3> pad_295C1; 203 INSERT_PADDING_BYTES(0x3);
488 std::array<u8, 0x4> reserved_295C4; 204 INSERT_PADDING_BYTES(0x4); // Reserved
489 // nn::time::SteadyClockTimePoint
490 Service::Time::Clock::SteadyClockTimePoint 205 Service::Time::Clock::SteadyClockTimePoint
491 user_system_clock_automatic_correction_updated_time_point; 206 user_system_clock_automatic_correction_updated_time_point;
207 INSERT_PADDING_BYTES(0x10); // Reserved
492 208
493 std::array<u8, 0x10> reserved_295E0;
494
495 // nn::settings::system::AccountSettings
496 AccountSettings account_settings; 209 AccountSettings account_settings;
497 210 INSERT_PADDING_BYTES(0xFC); // Reserved
498 std::array<u8, 0xFC> reserved_295F4;
499 211
500 // nn::settings::system::AudioVolume 212 // nn::settings::system::AudioVolume
501 std::array<u8, 0x8> audio_volume_type0; 213 std::array<u8, 0x8> audio_volume_type0;
@@ -505,47 +217,42 @@ struct SystemSettings {
505 s32 audio_output_mode_type1; 217 s32 audio_output_mode_type1;
506 s32 audio_output_mode_type2; 218 s32 audio_output_mode_type2;
507 bool force_mute_on_headphone_removed; 219 bool force_mute_on_headphone_removed;
508 std::array<u8, 0x3> pad_2970D; 220 INSERT_PADDING_BYTES(0x3);
509 s32 headphone_volume_warning_count; 221 s32 headphone_volume_warning_count;
510 bool heaphone_volume_update_flag; 222 bool heaphone_volume_update_flag;
511 std::array<u8, 0x3> pad_29715; 223 INSERT_PADDING_BYTES(0x3);
512 // nn::settings::system::AudioVolume 224 // nn::settings::system::AudioVolume
513 std::array<u8, 0x8> audio_volume_type2; 225 std::array<u8, 0x8> audio_volume_type2;
514 // nn::settings::system::AudioOutputMode 226 // nn::settings::system::AudioOutputMode
515 s32 audio_output_mode_type3; 227 s32 audio_output_mode_type3;
516 s32 audio_output_mode_type4; 228 s32 audio_output_mode_type4;
517 bool hearing_protection_safeguard_flag; 229 bool hearing_protection_safeguard_flag;
518 std::array<u8, 0x3> pad_29729; 230 INSERT_PADDING_BYTES(0x3);
519 std::array<u8, 0x4> reserved_2972C; 231 INSERT_PADDING_BYTES(0x4); // Reserved
520 s64 hearing_protection_safeguard_remaining_time; 232 s64 hearing_protection_safeguard_remaining_time;
521 std::array<u8, 0x38> reserved_29738; 233 INSERT_PADDING_BYTES(0x38); // Reserved
522 234
523 bool console_information_upload_flag; 235 bool console_information_upload_flag;
524 std::array<u8, 0x3> pad_29771; 236 INSERT_PADDING_BYTES(0x3);
525 237 INSERT_PADDING_BYTES(0x3C); // Reserved
526 std::array<u8, 0x3C> reserved_29774;
527 238
528 bool automatic_application_download_flag; 239 bool automatic_application_download_flag;
529 std::array<u8, 0x3> pad_297B1; 240 INSERT_PADDING_BYTES(0x3);
530 241 INSERT_PADDING_BYTES(0x4); // Reserved
531 std::array<u8, 0x4> reserved_297B4;
532 242
533 // nn::settings::system::NotificationSettings
534 NotificationSettings notification_settings; 243 NotificationSettings notification_settings;
535 244 INSERT_PADDING_BYTES(0x60); // Reserved
536 std::array<u8, 0x60> reserved_297D0;
537 245
538 // nn::settings::system::AccountNotificationSettings 246 // nn::settings::system::AccountNotificationSettings
539 u32 account_notification_settings_count; 247 u32 account_notification_settings_count;
540 std::array<u8, 0xC> reserved_29834; 248 INSERT_PADDING_BYTES(0xC); // Reserved
541 std::array<AccountNotificationSettings, 8> account_notification_settings; 249 std::array<AccountNotificationSettings, 8> account_notification_settings;
542 250 INSERT_PADDING_BYTES(0x140); // Reserved
543 std::array<u8, 0x140> reserved_29900;
544 251
545 f32 vibration_master_volume; 252 f32 vibration_master_volume;
546 253
547 bool usb_full_key_enable_flag; 254 bool usb_full_key_enable_flag;
548 std::array<u8, 0x3> pad_29A45; 255 INSERT_PADDING_BYTES(0x3);
549 256
550 // nn::settings::system::AnalogStickUserCalibration 257 // nn::settings::system::AnalogStickUserCalibration
551 std::array<u8, 0x10> analog_stick_user_calibration_left; 258 std::array<u8, 0x10> analog_stick_user_calibration_left;
@@ -553,85 +260,68 @@ struct SystemSettings {
553 260
554 // nn::settings::system::TouchScreenMode 261 // nn::settings::system::TouchScreenMode
555 s32 touch_screen_mode; 262 s32 touch_screen_mode;
263 INSERT_PADDING_BYTES(0x14); // Reserved
556 264
557 std::array<u8, 0x14> reserved_29A6C;
558
559 // nn::settings::system::TvSettings
560 TvSettings tv_settings; 265 TvSettings tv_settings;
561 266
562 // nn::settings::system::Edid 267 // nn::settings::system::Edid
563 std::array<u8, 0x100> edid; 268 std::array<u8, 0x100> edid;
564 269 INSERT_PADDING_BYTES(0x2E0); // Reserved
565 std::array<u8, 0x2E0> reserved_29BA0;
566 270
567 // nn::settings::system::DataDeletionSettings 271 // nn::settings::system::DataDeletionSettings
568 std::array<u8, 0x8> data_deletion_settings; 272 std::array<u8, 0x8> data_deletion_settings;
569 273 INSERT_PADDING_BYTES(0x38); // Reserved
570 std::array<u8, 0x38> reserved_29E88;
571 274
572 // nn::ncm::ProgramId 275 // nn::ncm::ProgramId
573 std::array<u8, 0x8> initial_system_applet_program_id; 276 std::array<u8, 0x8> initial_system_applet_program_id;
574 std::array<u8, 0x8> overlay_disp_program_id; 277 std::array<u8, 0x8> overlay_disp_program_id;
575 278 INSERT_PADDING_BYTES(0x4); // Reserved
576 std::array<u8, 0x4> reserved_29ED0;
577 279
578 bool requires_run_repair_time_reviser; 280 bool requires_run_repair_time_reviser;
281 INSERT_PADDING_BYTES(0x6B); // Reserved
579 282
580 std::array<u8, 0x6B> reserved_29ED5;
581
582 // nn::time::LocationName
583 Service::Time::TimeZone::LocationName device_time_zone_location_name; 283 Service::Time::TimeZone::LocationName device_time_zone_location_name;
584 std::array<u8, 0x4> reserved_29F64; 284 INSERT_PADDING_BYTES(0x4); // Reserved
585 // nn::time::SteadyClockTimePoint
586 Service::Time::Clock::SteadyClockTimePoint device_time_zone_location_updated_time; 285 Service::Time::Clock::SteadyClockTimePoint device_time_zone_location_updated_time;
587 286 INSERT_PADDING_BYTES(0xC0); // Reserved
588 std::array<u8, 0xC0> reserved_29F80;
589 287
590 // nn::settings::system::PrimaryAlbumStorage 288 // nn::settings::system::PrimaryAlbumStorage
591 PrimaryAlbumStorage primary_album_storage; 289 PrimaryAlbumStorage primary_album_storage;
592 290 INSERT_PADDING_BYTES(0x3C); // Reserved
593 std::array<u8, 0x3C> reserved_2A044;
594 291
595 bool usb_30_enable_flag; 292 bool usb_30_enable_flag;
596 std::array<u8, 0x3> pad_2A081; 293 INSERT_PADDING_BYTES(0x3);
597 bool usb_30_host_enable_flag; 294 bool usb_30_host_enable_flag;
598 std::array<u8, 0x3> pad_2A085; 295 INSERT_PADDING_BYTES(0x3);
599 bool usb_30_device_enable_flag; 296 bool usb_30_device_enable_flag;
600 std::array<u8, 0x3> pad_2A089; 297 INSERT_PADDING_BYTES(0x3);
601 298 INSERT_PADDING_BYTES(0x34); // Reserved
602 std::array<u8, 0x34> reserved_2A08C;
603 299
604 bool nfc_enable_flag; 300 bool nfc_enable_flag;
605 std::array<u8, 0x3> pad_2A0C1; 301 INSERT_PADDING_BYTES(0x3);
606 302 INSERT_PADDING_BYTES(0x3C); // Reserved
607 std::array<u8, 0x3C> reserved_2A0C4;
608 303
609 // nn::settings::system::SleepSettings 304 // nn::settings::system::SleepSettings
610 SleepSettings sleep_settings; 305 SleepSettings sleep_settings;
611 306 INSERT_PADDING_BYTES(0x34); // Reserved
612 std::array<u8, 0x34> reserved_2A10C;
613 307
614 // nn::settings::system::EulaVersion 308 // nn::settings::system::EulaVersion
615 u32 eula_version_count; 309 u32 eula_version_count;
616 std::array<u8, 0xC> reserved_2A144; 310 INSERT_PADDING_BYTES(0xC); // Reserved
617 std::array<EulaVersion, 32> eula_versions; 311 std::array<EulaVersion, 32> eula_versions;
618 312 INSERT_PADDING_BYTES(0x200); // Reserved
619 std::array<u8, 0x200> reserved_2A750;
620 313
621 // nn::settings::system::DeviceNickName 314 // nn::settings::system::DeviceNickName
622 std::array<u8, 0x80> device_nick_name; 315 std::array<u8, 0x80> device_nick_name;
623 316 INSERT_PADDING_BYTES(0x80); // Reserved
624 std::array<u8, 0x80> reserved_2A9D0;
625 317
626 bool auto_update_enable_flag; 318 bool auto_update_enable_flag;
627 std::array<u8, 0x3> pad_2AA51; 319 INSERT_PADDING_BYTES(0x3);
628 320 INSERT_PADDING_BYTES(0x4C); // Reserved
629 std::array<u8, 0x4C> reserved_2AA54;
630 321
631 // nn::settings::system::BluetoothDevicesSettings 322 // nn::settings::system::BluetoothDevicesSettings
632 std::array<std::array<u8, 0x200>, 14> bluetooth_device_settings_last_14; 323 std::array<std::array<u8, 0x200>, 14> bluetooth_device_settings_last_14;
633 324 INSERT_PADDING_BYTES(0x2000); // Reserved
634 std::array<u8, 0x2000> reserved_2C6A0;
635 325
636 // nn::settings::system::NxControllerSettings 326 // nn::settings::system::NxControllerSettings
637 std::array<std::array<u8, 0x800>, 10> nx_controller_settings_data_from_offset_30; 327 std::array<std::array<u8, 0x800>, 10> nx_controller_settings_data_from_offset_30;
diff --git a/src/core/hle/service/set/settings_server.h b/src/core/hle/service/set/settings_server.h
index a4e78db6c..8304e8424 100644
--- a/src/core/hle/service/set/settings_server.h
+++ b/src/core/hle/service/set/settings_server.h
@@ -4,72 +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#include "core/hle/service/set/settings_types.h"
8 8
9namespace Core { 9namespace Core {
10class System; 10class System;
11} 11}
12 12
13namespace Service::Set { 13namespace Service::Set {
14enum class KeyboardLayout : u64 {
15 Japanese = 0,
16 EnglishUs = 1,
17 EnglishUsInternational = 2,
18 EnglishUk = 3,
19 French = 4,
20 FrenchCa = 5,
21 Spanish = 6,
22 SpanishLatin = 7,
23 German = 8,
24 Italian = 9,
25 Portuguese = 10,
26 Russian = 11,
27 Korean = 12,
28 ChineseSimplified = 13,
29 ChineseTraditional = 14,
30};
31
32constexpr std::array<LanguageCode, 18> available_language_codes = {{
33 LanguageCode::JA,
34 LanguageCode::EN_US,
35 LanguageCode::FR,
36 LanguageCode::DE,
37 LanguageCode::IT,
38 LanguageCode::ES,
39 LanguageCode::ZH_CN,
40 LanguageCode::KO,
41 LanguageCode::NL,
42 LanguageCode::PT,
43 LanguageCode::RU,
44 LanguageCode::ZH_TW,
45 LanguageCode::EN_GB,
46 LanguageCode::FR_CA,
47 LanguageCode::ES_419,
48 LanguageCode::ZH_HANS,
49 LanguageCode::ZH_HANT,
50 LanguageCode::PT_BR,
51}};
52
53static constexpr std::array<std::pair<LanguageCode, KeyboardLayout>, 18> language_to_layout{{
54 {LanguageCode::JA, KeyboardLayout::Japanese},
55 {LanguageCode::EN_US, KeyboardLayout::EnglishUs},
56 {LanguageCode::FR, KeyboardLayout::French},
57 {LanguageCode::DE, KeyboardLayout::German},
58 {LanguageCode::IT, KeyboardLayout::Italian},
59 {LanguageCode::ES, KeyboardLayout::Spanish},
60 {LanguageCode::ZH_CN, KeyboardLayout::ChineseSimplified},
61 {LanguageCode::KO, KeyboardLayout::Korean},
62 {LanguageCode::NL, KeyboardLayout::EnglishUsInternational},
63 {LanguageCode::PT, KeyboardLayout::Portuguese},
64 {LanguageCode::RU, KeyboardLayout::Russian},
65 {LanguageCode::ZH_TW, KeyboardLayout::ChineseTraditional},
66 {LanguageCode::EN_GB, KeyboardLayout::EnglishUk},
67 {LanguageCode::FR_CA, KeyboardLayout::FrenchCa},
68 {LanguageCode::ES_419, KeyboardLayout::SpanishLatin},
69 {LanguageCode::ZH_HANS, KeyboardLayout::ChineseSimplified},
70 {LanguageCode::ZH_HANT, KeyboardLayout::ChineseTraditional},
71 {LanguageCode::PT_BR, KeyboardLayout::Portuguese},
72}};
73 14
74LanguageCode GetLanguageCodeFromIndex(std::size_t idx); 15LanguageCode GetLanguageCodeFromIndex(std::size_t idx);
75 16
diff --git a/src/core/hle/service/set/settings_types.h b/src/core/hle/service/set/settings_types.h
new file mode 100644
index 000000000..4dee202d7
--- /dev/null
+++ b/src/core/hle/service/set/settings_types.h
@@ -0,0 +1,451 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-3.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::AudioOutputMode
17enum class AudioOutputMode : u32 {
18 ch_1,
19 ch_2,
20 ch_5_1,
21 ch_7_1,
22};
23
24/// This is nn::settings::system::AudioOutputModeTarget
25enum class AudioOutputModeTarget : u32 {
26 Hdmi,
27 Speaker,
28 Headphone,
29};
30
31/// This is nn::settings::system::AudioVolumeTarget
32enum class AudioVolumeTarget : u32 {
33 Speaker,
34 Headphone,
35};
36
37/// This is nn::settings::system::ClockSourceId
38enum class ClockSourceId : u32 {
39 NetworkSystemClock,
40 SteadyClock,
41};
42
43/// This is nn::settings::system::CmuMode
44enum class CmuMode : u32 {
45 None,
46 ColorInvert,
47 HighContrast,
48 GrayScale,
49};
50
51/// This is nn::settings::system::ChineseTraditionalInputMethod
52enum class ChineseTraditionalInputMethod : u32 {
53 Unknown0 = 0,
54 Unknown1 = 1,
55 Unknown2 = 2,
56};
57
58/// Indicates the current theme set by the system settings
59enum class ColorSet : u32 {
60 BasicWhite = 0,
61 BasicBlack = 1,
62};
63
64/// This is nn::settings::system::ConsoleSleepPlan
65enum class ConsoleSleepPlan : u32 {
66 Sleep1Hour,
67 Sleep2Hour,
68 Sleep3Hour,
69 Sleep6Hour,
70 Sleep12Hour,
71 Never,
72};
73
74/// This is nn::settings::system::ErrorReportSharePermission
75enum class ErrorReportSharePermission : u32 {
76 NotConfirmed,
77 Granted,
78 Denied,
79};
80
81/// This is nn::settings::system::EulaVersionClockType
82enum class EulaVersionClockType : u32 {
83 NetworkSystemClock,
84 SteadyClock,
85};
86
87/// This is nn::settings::factory::RegionCode
88enum class FactoryRegionCode : u32 {
89 Japan,
90 Usa,
91 Europe,
92 Australia,
93 China,
94 Korea,
95 Taiwan,
96};
97
98/// This is nn::settings::system::FriendPresenceOverlayPermission
99enum class FriendPresenceOverlayPermission : u8 {
100 NotConfirmed,
101 NoDisplay,
102 FavoriteFriends,
103 Friends,
104};
105
106enum class GetFirmwareVersionType {
107 Version1,
108 Version2,
109};
110
111/// This is nn::settings::system::HandheldSleepPlan
112enum class HandheldSleepPlan : u32 {
113 Sleep1Min,
114 Sleep3Min,
115 Sleep5Min,
116 Sleep10Min,
117 Sleep30Min,
118 Never,
119};
120
121/// This is nn::settings::system::HdmiContentType
122enum class HdmiContentType : u32 {
123 None,
124 Graphics,
125 Cinema,
126 Photo,
127 Game,
128};
129
130enum class KeyboardLayout : u32 {
131 Japanese = 0,
132 EnglishUs = 1,
133 EnglishUsInternational = 2,
134 EnglishUk = 3,
135 French = 4,
136 FrenchCa = 5,
137 Spanish = 6,
138 SpanishLatin = 7,
139 German = 8,
140 Italian = 9,
141 Portuguese = 10,
142 Russian = 11,
143 Korean = 12,
144 ChineseSimplified = 13,
145 ChineseTraditional = 14,
146};
147
148/// This is "nn::settings::LanguageCode", which is a NUL-terminated string stored in a u64.
149enum class LanguageCode : u64 {
150 JA = 0x000000000000616A,
151 EN_US = 0x00000053552D6E65,
152 FR = 0x0000000000007266,
153 DE = 0x0000000000006564,
154 IT = 0x0000000000007469,
155 ES = 0x0000000000007365,
156 ZH_CN = 0x0000004E432D687A,
157 KO = 0x0000000000006F6B,
158 NL = 0x0000000000006C6E,
159 PT = 0x0000000000007470,
160 RU = 0x0000000000007572,
161 ZH_TW = 0x00000057542D687A,
162 EN_GB = 0x00000042472D6E65,
163 FR_CA = 0x00000041432D7266,
164 ES_419 = 0x00003931342D7365,
165 ZH_HANS = 0x00736E61482D687A,
166 ZH_HANT = 0x00746E61482D687A,
167 PT_BR = 0x00000052422D7470,
168};
169
170/// This is nn::settings::system::NotificationVolume
171enum class NotificationVolume : u32 {
172 Mute,
173 Low,
174 High,
175};
176
177/// This is nn::settings::system::PrimaryAlbumStorage
178enum class PrimaryAlbumStorage : u32 {
179 Nand,
180 SdCard,
181};
182
183/// Indicates the current console is a retail or kiosk unit
184enum class QuestFlag : u8 {
185 Retail = 0,
186 Kiosk = 1,
187};
188
189/// This is nn::settings::system::RgbRange
190enum class RgbRange : u32 {
191 Auto,
192 Full,
193 Limited,
194};
195
196/// This is nn::settings::system::RegionCode
197enum class SystemRegionCode : u32 {
198 Japan,
199 Usa,
200 Europe,
201 Australia,
202 HongKongTaiwanKorea,
203 China,
204};
205
206/// This is nn::settings::system::TouchScreenMode
207enum class TouchScreenMode : u32 {
208 Stylus,
209 Standard,
210};
211
212/// This is nn::settings::system::TvResolution
213enum class TvResolution : u32 {
214 Auto,
215 Resolution1080p,
216 Resolution720p,
217 Resolution480p,
218};
219
220constexpr std::array<LanguageCode, 18> available_language_codes = {{
221 LanguageCode::JA,
222 LanguageCode::EN_US,
223 LanguageCode::FR,
224 LanguageCode::DE,
225 LanguageCode::IT,
226 LanguageCode::ES,
227 LanguageCode::ZH_CN,
228 LanguageCode::KO,
229 LanguageCode::NL,
230 LanguageCode::PT,
231 LanguageCode::RU,
232 LanguageCode::ZH_TW,
233 LanguageCode::EN_GB,
234 LanguageCode::FR_CA,
235 LanguageCode::ES_419,
236 LanguageCode::ZH_HANS,
237 LanguageCode::ZH_HANT,
238 LanguageCode::PT_BR,
239}};
240
241static constexpr std::array<std::pair<LanguageCode, KeyboardLayout>, 18> language_to_layout{{
242 {LanguageCode::JA, KeyboardLayout::Japanese},
243 {LanguageCode::EN_US, KeyboardLayout::EnglishUs},
244 {LanguageCode::FR, KeyboardLayout::French},
245 {LanguageCode::DE, KeyboardLayout::German},
246 {LanguageCode::IT, KeyboardLayout::Italian},
247 {LanguageCode::ES, KeyboardLayout::Spanish},
248 {LanguageCode::ZH_CN, KeyboardLayout::ChineseSimplified},
249 {LanguageCode::KO, KeyboardLayout::Korean},
250 {LanguageCode::NL, KeyboardLayout::EnglishUsInternational},
251 {LanguageCode::PT, KeyboardLayout::Portuguese},
252 {LanguageCode::RU, KeyboardLayout::Russian},
253 {LanguageCode::ZH_TW, KeyboardLayout::ChineseTraditional},
254 {LanguageCode::EN_GB, KeyboardLayout::EnglishUk},
255 {LanguageCode::FR_CA, KeyboardLayout::FrenchCa},
256 {LanguageCode::ES_419, KeyboardLayout::SpanishLatin},
257 {LanguageCode::ZH_HANS, KeyboardLayout::ChineseSimplified},
258 {LanguageCode::ZH_HANT, KeyboardLayout::ChineseTraditional},
259 {LanguageCode::PT_BR, KeyboardLayout::Portuguese},
260}};
261
262/// This is nn::settings::system::AccountNotificationFlag
263struct AccountNotificationFlag {
264 union {
265 u32 raw{};
266
267 BitField<0, 1, u32> FriendOnlineFlag;
268 BitField<1, 1, u32> FriendRequestFlag;
269 BitField<8, 1, u32> CoralInvitationFlag;
270 };
271};
272static_assert(sizeof(AccountNotificationFlag) == 4, "AccountNotificationFlag is an invalid size");
273
274/// This is nn::settings::system::AccountSettings
275struct AccountSettings {
276 u32 flags;
277};
278static_assert(sizeof(AccountSettings) == 4, "AccountSettings is an invalid size");
279
280/// This is nn::settings::system::DataDeletionFlag
281struct DataDeletionFlag {
282 union {
283 u32 raw{};
284
285 BitField<0, 1, u32> AutomaticDeletionFlag;
286 };
287};
288static_assert(sizeof(DataDeletionFlag) == 4, "DataDeletionFlag is an invalid size");
289
290/// This is nn::settings::system::InitialLaunchFlag
291struct InitialLaunchFlag {
292 union {
293 u32 raw{};
294
295 BitField<0, 1, u32> InitialLaunchCompletionFlag;
296 BitField<8, 1, u32> InitialLaunchUserAdditionFlag;
297 BitField<16, 1, u32> InitialLaunchTimestampFlag;
298 };
299};
300static_assert(sizeof(InitialLaunchFlag) == 4, "InitialLaunchFlag is an invalid size");
301
302/// This is nn::settings::system::SleepFlag
303struct SleepFlag {
304 union {
305 u32 raw{};
306
307 BitField<0, 1, u32> SleepsWhilePlayingMedia;
308 BitField<1, 1, u32> WakesAtPowerStateChange;
309 };
310};
311static_assert(sizeof(SleepFlag) == 4, "TvFlag is an invalid size");
312
313/// This is nn::settings::system::NotificationFlag
314struct NotificationFlag {
315 union {
316 u32 raw{};
317
318 BitField<0, 1, u32> RingtoneFlag;
319 BitField<1, 1, u32> DownloadCompletionFlag;
320 BitField<8, 1, u32> EnablesNews;
321 BitField<9, 1, u32> IncomingLampFlag;
322 };
323};
324static_assert(sizeof(NotificationFlag) == 4, "NotificationFlag is an invalid size");
325
326/// This is nn::settings::system::TvFlag
327struct TvFlag {
328 union {
329 u32 raw{};
330
331 BitField<0, 1, u32> Allows4k;
332 BitField<1, 1, u32> Allows3d;
333 BitField<2, 1, u32> AllowsCec;
334 BitField<3, 1, u32> PreventsScreenBurnIn;
335 };
336};
337static_assert(sizeof(TvFlag) == 4, "TvFlag is an invalid size");
338
339/// This is nn::settings::system::UserSelectorFlag
340struct UserSelectorFlag {
341 union {
342 u32 raw{};
343
344 BitField<0, 1, u32> SkipIfSingleUser;
345 BitField<31, 1, u32> Unknown;
346 };
347};
348static_assert(sizeof(UserSelectorFlag) == 4, "UserSelectorFlag is an invalid size");
349
350/// This is nn::settings::system::AccountNotificationSettings
351struct AccountNotificationSettings {
352 Common::UUID uid;
353 AccountNotificationFlag flags;
354 FriendPresenceOverlayPermission friend_presence_permission;
355 FriendPresenceOverlayPermission friend_invitation_permission;
356 INSERT_PADDING_BYTES(0x2);
357};
358static_assert(sizeof(AccountNotificationSettings) == 0x18,
359 "AccountNotificationSettings is an invalid size");
360
361/// This is nn::settings::system::EulaVersion
362struct EulaVersion {
363 u32 version;
364 SystemRegionCode region_code;
365 EulaVersionClockType clock_type;
366 INSERT_PADDING_BYTES(0x4);
367 s64 posix_time;
368 Time::Clock::SteadyClockTimePoint timestamp;
369};
370static_assert(sizeof(EulaVersion) == 0x30, "EulaVersion is incorrect size");
371
372struct FirmwareVersionFormat {
373 u8 major;
374 u8 minor;
375 u8 micro;
376 INSERT_PADDING_BYTES(1);
377 u8 revision_major;
378 u8 revision_minor;
379 INSERT_PADDING_BYTES(2);
380 std::array<char, 0x20> platform;
381 std::array<u8, 0x40> version_hash;
382 std::array<char, 0x18> display_version;
383 std::array<char, 0x80> display_title;
384};
385static_assert(sizeof(FirmwareVersionFormat) == 0x100, "FirmwareVersionFormat is an invalid size");
386
387/// This is nn::settings::system::HomeMenuScheme
388struct HomeMenuScheme {
389 u32 main;
390 u32 back;
391 u32 sub;
392 u32 bezel;
393 u32 extra;
394};
395static_assert(sizeof(HomeMenuScheme) == 0x14, "HomeMenuScheme is incorrect size");
396
397/// This is nn::settings::system::InitialLaunchSettings
398struct InitialLaunchSettings {
399 InitialLaunchFlag flags;
400 INSERT_PADDING_BYTES(0x4);
401 Service::Time::Clock::SteadyClockTimePoint timestamp;
402};
403static_assert(sizeof(InitialLaunchSettings) == 0x20, "InitialLaunchSettings is incorrect size");
404
405#pragma pack(push, 4)
406struct InitialLaunchSettingsPacked {
407 InitialLaunchFlag flags;
408 Service::Time::Clock::SteadyClockTimePoint timestamp;
409};
410#pragma pack(pop)
411static_assert(sizeof(InitialLaunchSettingsPacked) == 0x1C,
412 "InitialLaunchSettingsPacked is incorrect size");
413
414/// This is nn::settings::system::NotificationTime
415struct NotificationTime {
416 u32 hour;
417 u32 minute;
418};
419static_assert(sizeof(NotificationTime) == 0x8, "NotificationTime is an invalid size");
420
421/// This is nn::settings::system::NotificationSettings
422struct NotificationSettings {
423 NotificationFlag flags;
424 NotificationVolume volume;
425 NotificationTime start_time;
426 NotificationTime stop_time;
427};
428static_assert(sizeof(NotificationSettings) == 0x18, "NotificationSettings is an invalid size");
429
430/// This is nn::settings::system::SleepSettings
431struct SleepSettings {
432 SleepFlag flags;
433 HandheldSleepPlan handheld_sleep_plan;
434 ConsoleSleepPlan console_sleep_plan;
435};
436static_assert(sizeof(SleepSettings) == 0xc, "SleepSettings is incorrect size");
437
438/// This is nn::settings::system::TvSettings
439struct TvSettings {
440 TvFlag flags;
441 TvResolution tv_resolution;
442 HdmiContentType hdmi_content_type;
443 RgbRange rgb_range;
444 CmuMode cmu_mode;
445 u32 tv_underscan;
446 f32 tv_gama;
447 f32 contrast_ratio;
448};
449static_assert(sizeof(TvSettings) == 0x20, "TvSettings is an invalid size");
450
451} // namespace Service::Set
diff --git a/src/core/hle/service/set/system_settings_server.cpp b/src/core/hle/service/set/system_settings_server.cpp
index af9348522..87242ae68 100644
--- a/src/core/hle/service/set/system_settings_server.cpp
+++ b/src/core/hle/service/set/system_settings_server.cpp
@@ -97,8 +97,8 @@ ISystemSettingsServer::ISystemSettingsServer(Core::System& system_)
97 {3, &ISystemSettingsServer::GetFirmwareVersion, "GetFirmwareVersion"}, 97 {3, &ISystemSettingsServer::GetFirmwareVersion, "GetFirmwareVersion"},
98 {4, &ISystemSettingsServer::GetFirmwareVersion2, "GetFirmwareVersion2"}, 98 {4, &ISystemSettingsServer::GetFirmwareVersion2, "GetFirmwareVersion2"},
99 {5, nullptr, "GetFirmwareVersionDigest"}, 99 {5, nullptr, "GetFirmwareVersionDigest"},
100 {7, nullptr, "GetLockScreenFlag"}, 100 {7, &ISystemSettingsServer::GetLockScreenFlag, "GetLockScreenFlag"},
101 {8, nullptr, "SetLockScreenFlag"}, 101 {8, &ISystemSettingsServer::SetLockScreenFlag, "SetLockScreenFlag"},
102 {9, nullptr, "GetBacklightSettings"}, 102 {9, nullptr, "GetBacklightSettings"},
103 {10, nullptr, "SetBacklightSettings"}, 103 {10, nullptr, "SetBacklightSettings"},
104 {11, nullptr, "SetBluetoothDevicesSettings"}, 104 {11, nullptr, "SetBluetoothDevicesSettings"},
@@ -157,12 +157,12 @@ ISystemSettingsServer::ISystemSettingsServer(Core::System& system_)
157 {66, nullptr, "SetUsb30EnableFlag"}, 157 {66, nullptr, "SetUsb30EnableFlag"},
158 {67, nullptr, "GetBatteryLot"}, 158 {67, nullptr, "GetBatteryLot"},
159 {68, nullptr, "GetSerialNumber"}, 159 {68, nullptr, "GetSerialNumber"},
160 {69, nullptr, "GetNfcEnableFlag"}, 160 {69, &ISystemSettingsServer::GetNfcEnableFlag, "GetNfcEnableFlag"},
161 {70, nullptr, "SetNfcEnableFlag"}, 161 {70, &ISystemSettingsServer::SetNfcEnableFlag, "SetNfcEnableFlag"},
162 {71, &ISystemSettingsServer::GetSleepSettings, "GetSleepSettings"}, 162 {71, &ISystemSettingsServer::GetSleepSettings, "GetSleepSettings"},
163 {72, &ISystemSettingsServer::SetSleepSettings, "SetSleepSettings"}, 163 {72, &ISystemSettingsServer::SetSleepSettings, "SetSleepSettings"},
164 {73, nullptr, "GetWirelessLanEnableFlag"}, 164 {73, &ISystemSettingsServer::GetWirelessLanEnableFlag, "GetWirelessLanEnableFlag"},
165 {74, nullptr, "SetWirelessLanEnableFlag"}, 165 {74, &ISystemSettingsServer::SetWirelessLanEnableFlag, "SetWirelessLanEnableFlag"},
166 {75, &ISystemSettingsServer::GetInitialLaunchSettings, "GetInitialLaunchSettings"}, 166 {75, &ISystemSettingsServer::GetInitialLaunchSettings, "GetInitialLaunchSettings"},
167 {76, &ISystemSettingsServer::SetInitialLaunchSettings, "SetInitialLaunchSettings"}, 167 {76, &ISystemSettingsServer::SetInitialLaunchSettings, "SetInitialLaunchSettings"},
168 {77, &ISystemSettingsServer::GetDeviceNickName, "GetDeviceNickName"}, 168 {77, &ISystemSettingsServer::GetDeviceNickName, "GetDeviceNickName"},
@@ -176,8 +176,8 @@ ISystemSettingsServer::ISystemSettingsServer(Core::System& system_)
176 {85, nullptr, "SetPtmBatteryLot"}, 176 {85, nullptr, "SetPtmBatteryLot"},
177 {86, nullptr, "GetPtmFuelGaugeParameter"}, 177 {86, nullptr, "GetPtmFuelGaugeParameter"},
178 {87, nullptr, "SetPtmFuelGaugeParameter"}, 178 {87, nullptr, "SetPtmFuelGaugeParameter"},
179 {88, nullptr, "GetBluetoothEnableFlag"}, 179 {88, &ISystemSettingsServer::GetBluetoothEnableFlag, "GetBluetoothEnableFlag"},
180 {89, nullptr, "SetBluetoothEnableFlag"}, 180 {89, &ISystemSettingsServer::SetBluetoothEnableFlag, "SetBluetoothEnableFlag"},
181 {90, &ISystemSettingsServer::GetMiiAuthorId, "GetMiiAuthorId"}, 181 {90, &ISystemSettingsServer::GetMiiAuthorId, "GetMiiAuthorId"},
182 {91, nullptr, "SetShutdownRtcValue"}, 182 {91, nullptr, "SetShutdownRtcValue"},
183 {92, nullptr, "GetShutdownRtcValue"}, 183 {92, nullptr, "GetShutdownRtcValue"},
@@ -510,6 +510,25 @@ void ISystemSettingsServer::SetUserSystemClockContext(HLERequestContext& ctx) {
510 rb.Push(res); 510 rb.Push(res);
511} 511}
512 512
513void ISystemSettingsServer::GetLockScreenFlag(HLERequestContext& ctx) {
514 LOG_INFO(Service_SET, "called, lock_screen_flag={}", m_system_settings.lock_screen_flag);
515
516 IPC::ResponseBuilder rb{ctx, 3};
517 rb.Push(ResultSuccess);
518 rb.Push(m_system_settings.lock_screen_flag);
519}
520
521void ISystemSettingsServer::SetLockScreenFlag(HLERequestContext& ctx) {
522 IPC::RequestParser rp{ctx};
523 m_system_settings.lock_screen_flag = rp.Pop<bool>();
524 SetSaveNeeded();
525
526 LOG_INFO(Service_SET, "called, lock_screen_flag={}", m_system_settings.lock_screen_flag);
527
528 IPC::ResponseBuilder rb{ctx, 2};
529 rb.Push(ResultSuccess);
530}
531
513void ISystemSettingsServer::GetAccountSettings(HLERequestContext& ctx) { 532void ISystemSettingsServer::GetAccountSettings(HLERequestContext& ctx) {
514 LOG_INFO(Service_SET, "called"); 533 LOG_INFO(Service_SET, "called");
515 534
@@ -531,7 +550,7 @@ void ISystemSettingsServer::SetAccountSettings(HLERequestContext& ctx) {
531} 550}
532 551
533void ISystemSettingsServer::GetEulaVersions(HLERequestContext& ctx) { 552void ISystemSettingsServer::GetEulaVersions(HLERequestContext& ctx) {
534 LOG_INFO(Service_SET, "called"); 553 LOG_INFO(Service_SET, "called, elements={}", m_system_settings.eula_version_count);
535 554
536 ctx.WriteBuffer(m_system_settings.eula_versions); 555 ctx.WriteBuffer(m_system_settings.eula_versions);
537 556
@@ -557,7 +576,7 @@ void ISystemSettingsServer::SetEulaVersions(HLERequestContext& ctx) {
557} 576}
558 577
559void ISystemSettingsServer::GetColorSetId(HLERequestContext& ctx) { 578void ISystemSettingsServer::GetColorSetId(HLERequestContext& ctx) {
560 LOG_DEBUG(Service_SET, "called"); 579 LOG_DEBUG(Service_SET, "called, color_set=", m_system_settings.color_set_id);
561 580
562 IPC::ResponseBuilder rb{ctx, 3}; 581 IPC::ResponseBuilder rb{ctx, 3};
563 rb.Push(ResultSuccess); 582 rb.Push(ResultSuccess);
@@ -576,7 +595,13 @@ void ISystemSettingsServer::SetColorSetId(HLERequestContext& ctx) {
576} 595}
577 596
578void ISystemSettingsServer::GetNotificationSettings(HLERequestContext& ctx) { 597void ISystemSettingsServer::GetNotificationSettings(HLERequestContext& ctx) {
579 LOG_INFO(Service_SET, "called"); 598 LOG_INFO(Service_SET, "called, flags={}, volume={}, head_time={}:{}, tailt_time={}:{}",
599 m_system_settings.notification_settings.flags.raw,
600 m_system_settings.notification_settings.volume,
601 m_system_settings.notification_settings.start_time.hour,
602 m_system_settings.notification_settings.start_time.minute,
603 m_system_settings.notification_settings.stop_time.hour,
604 m_system_settings.notification_settings.stop_time.minute);
580 605
581 IPC::ResponseBuilder rb{ctx, 8}; 606 IPC::ResponseBuilder rb{ctx, 8};
582 rb.Push(ResultSuccess); 607 rb.Push(ResultSuccess);
@@ -601,7 +626,8 @@ void ISystemSettingsServer::SetNotificationSettings(HLERequestContext& ctx) {
601} 626}
602 627
603void ISystemSettingsServer::GetAccountNotificationSettings(HLERequestContext& ctx) { 628void ISystemSettingsServer::GetAccountNotificationSettings(HLERequestContext& ctx) {
604 LOG_INFO(Service_SET, "called"); 629 LOG_INFO(Service_SET, "called, elements={}",
630 m_system_settings.account_notification_settings_count);
605 631
606 ctx.WriteBuffer(m_system_settings.account_notification_settings); 632 ctx.WriteBuffer(m_system_settings.account_notification_settings);
607 633
@@ -645,6 +671,7 @@ using Settings =
645static Settings GetSettings() { 671static Settings GetSettings() {
646 Settings ret; 672 Settings ret;
647 673
674 // AM
648 ret["hbloader"]["applet_heap_size"] = ToBytes(u64{0x0}); 675 ret["hbloader"]["applet_heap_size"] = ToBytes(u64{0x0});
649 ret["hbloader"]["applet_heap_reservation_size"] = ToBytes(u64{0x8600000}); 676 ret["hbloader"]["applet_heap_reservation_size"] = ToBytes(u64{0x8600000});
650 677
@@ -656,6 +683,24 @@ static Settings GetSettings() {
656 ret["time"]["standard_steady_clock_test_offset_minutes"] = ToBytes(s32{0}); 683 ret["time"]["standard_steady_clock_test_offset_minutes"] = ToBytes(s32{0});
657 ret["time"]["standard_user_clock_initial_year"] = ToBytes(s32{2023}); 684 ret["time"]["standard_user_clock_initial_year"] = ToBytes(s32{2023});
658 685
686 // HID
687 ret["hid_debug"]["enables_debugpad"] = ToBytes(bool{true});
688 ret["hid_debug"]["manages_devices"] = ToBytes(bool{true});
689 ret["hid_debug"]["manages_touch_ic_i2c"] = ToBytes(bool{true});
690 ret["hid_debug"]["emulate_future_device"] = ToBytes(bool{false});
691 ret["hid_debug"]["emulate_mcu_hardware_error"] = ToBytes(bool{false});
692 ret["hid_debug"]["enables_rail"] = ToBytes(bool{true});
693 ret["hid_debug"]["emulate_firmware_update_failure"] = ToBytes(bool{false});
694 ret["hid_debug"]["failure_firmware_update"] = ToBytes(s32{0});
695 ret["hid_debug"]["ble_disabled"] = ToBytes(bool{false});
696 ret["hid_debug"]["dscale_disabled"] = ToBytes(bool{false});
697 ret["hid_debug"]["force_handheld"] = ToBytes(bool{true});
698 ret["hid_debug"]["disabled_features_per_id"] = std::vector<u8>(0xa8);
699 ret["hid_debug"]["touch_firmware_auto_update_disabled"] = ToBytes(bool{false});
700
701 // Settings
702 ret["settings_debug"]["is_debug_mode_enabled"] = ToBytes(bool{false});
703
659 return ret; 704 return ret;
660} 705}
661 706
@@ -708,7 +753,15 @@ void ISystemSettingsServer::GetSettingsItemValue(HLERequestContext& ctx) {
708} 753}
709 754
710void ISystemSettingsServer::GetTvSettings(HLERequestContext& ctx) { 755void ISystemSettingsServer::GetTvSettings(HLERequestContext& ctx) {
711 LOG_INFO(Service_SET, "called"); 756 LOG_INFO(Service_SET,
757 "called, flags={}, cmu_mode={}, contrast_ratio={}, hdmi_content_type={}, "
758 "rgb_range={}, tv_gama={}, tv_resolution={}, tv_underscan={}",
759 m_system_settings.tv_settings.flags.raw, m_system_settings.tv_settings.cmu_mode,
760 m_system_settings.tv_settings.contrast_ratio,
761 m_system_settings.tv_settings.hdmi_content_type,
762 m_system_settings.tv_settings.rgb_range, m_system_settings.tv_settings.tv_gama,
763 m_system_settings.tv_settings.tv_resolution,
764 m_system_settings.tv_settings.tv_underscan);
712 765
713 IPC::ResponseBuilder rb{ctx, 10}; 766 IPC::ResponseBuilder rb{ctx, 10};
714 rb.Push(ResultSuccess); 767 rb.Push(ResultSuccess);
@@ -735,23 +788,26 @@ void ISystemSettingsServer::SetTvSettings(HLERequestContext& ctx) {
735} 788}
736 789
737void ISystemSettingsServer::GetDebugModeFlag(HLERequestContext& ctx) { 790void ISystemSettingsServer::GetDebugModeFlag(HLERequestContext& ctx) {
738 LOG_DEBUG(Service_SET, "called"); 791 bool is_debug_mode_enabled = false;
792 GetSettingsItemValue<bool>(is_debug_mode_enabled, "settings_debug", "is_debug_mode_enabled");
793
794 LOG_DEBUG(Service_SET, "called, is_debug_mode_enabled={}", is_debug_mode_enabled);
739 795
740 IPC::ResponseBuilder rb{ctx, 3}; 796 IPC::ResponseBuilder rb{ctx, 3};
741 rb.Push(ResultSuccess); 797 rb.Push(ResultSuccess);
742 rb.Push<u32>(0); 798 rb.Push(is_debug_mode_enabled);
743} 799}
744 800
745void ISystemSettingsServer::GetQuestFlag(HLERequestContext& ctx) { 801void ISystemSettingsServer::GetQuestFlag(HLERequestContext& ctx) {
746 LOG_WARNING(Service_SET, "(STUBBED) called"); 802 LOG_INFO(Service_SET, "called, quest_flag={}", m_system_settings.quest_flag);
747 803
748 IPC::ResponseBuilder rb{ctx, 3}; 804 IPC::ResponseBuilder rb{ctx, 3};
749 rb.Push(ResultSuccess); 805 rb.Push(ResultSuccess);
750 rb.PushEnum(QuestFlag::Retail); 806 rb.PushEnum(m_system_settings.quest_flag);
751} 807}
752 808
753void ISystemSettingsServer::GetDeviceTimeZoneLocationName(HLERequestContext& ctx) { 809void ISystemSettingsServer::GetDeviceTimeZoneLocationName(HLERequestContext& ctx) {
754 LOG_WARNING(Service_SET, "called"); 810 LOG_INFO(Service_SET, "called");
755 811
756 Service::Time::TimeZone::LocationName name{}; 812 Service::Time::TimeZone::LocationName name{};
757 auto res = GetDeviceTimeZoneLocationName(name); 813 auto res = GetDeviceTimeZoneLocationName(name);
@@ -762,7 +818,7 @@ void ISystemSettingsServer::GetDeviceTimeZoneLocationName(HLERequestContext& ctx
762} 818}
763 819
764void ISystemSettingsServer::SetDeviceTimeZoneLocationName(HLERequestContext& ctx) { 820void ISystemSettingsServer::SetDeviceTimeZoneLocationName(HLERequestContext& ctx) {
765 LOG_WARNING(Service_SET, "called"); 821 LOG_INFO(Service_SET, "called");
766 822
767 IPC::RequestParser rp{ctx}; 823 IPC::RequestParser rp{ctx};
768 auto name{rp.PopRaw<Service::Time::TimeZone::LocationName>()}; 824 auto name{rp.PopRaw<Service::Time::TimeZone::LocationName>()};
@@ -775,7 +831,7 @@ void ISystemSettingsServer::SetDeviceTimeZoneLocationName(HLERequestContext& ctx
775 831
776void ISystemSettingsServer::SetRegionCode(HLERequestContext& ctx) { 832void ISystemSettingsServer::SetRegionCode(HLERequestContext& ctx) {
777 IPC::RequestParser rp{ctx}; 833 IPC::RequestParser rp{ctx};
778 m_system_settings.region_code = rp.PopEnum<RegionCode>(); 834 m_system_settings.region_code = rp.PopEnum<SystemRegionCode>();
779 SetSaveNeeded(); 835 SetSaveNeeded();
780 836
781 LOG_INFO(Service_SET, "called, region_code={}", m_system_settings.region_code); 837 LOG_INFO(Service_SET, "called, region_code={}", m_system_settings.region_code);
@@ -832,15 +888,38 @@ void ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionEnabled(HLERequ
832} 888}
833 889
834void ISystemSettingsServer::GetPrimaryAlbumStorage(HLERequestContext& ctx) { 890void ISystemSettingsServer::GetPrimaryAlbumStorage(HLERequestContext& ctx) {
835 LOG_WARNING(Service_SET, "(STUBBED) called"); 891 LOG_INFO(Service_SET, "called, primary_album_storage={}",
892 m_system_settings.primary_album_storage);
893
894 IPC::ResponseBuilder rb{ctx, 3};
895 rb.Push(ResultSuccess);
896 rb.PushEnum(m_system_settings.primary_album_storage);
897}
898
899void ISystemSettingsServer::GetNfcEnableFlag(HLERequestContext& ctx) {
900 LOG_INFO(Service_SET, "called, nfc_enable_flag={}", m_system_settings.nfc_enable_flag);
836 901
837 IPC::ResponseBuilder rb{ctx, 3}; 902 IPC::ResponseBuilder rb{ctx, 3};
838 rb.Push(ResultSuccess); 903 rb.Push(ResultSuccess);
839 rb.PushEnum(PrimaryAlbumStorage::SdCard); 904 rb.Push<u8>(m_system_settings.nfc_enable_flag);
905}
906
907void ISystemSettingsServer::SetNfcEnableFlag(HLERequestContext& ctx) {
908 IPC::RequestParser rp{ctx};
909 m_system_settings.nfc_enable_flag = rp.Pop<bool>();
910 SetSaveNeeded();
911
912 LOG_INFO(Service_SET, "called, nfc_enable_flag={}", m_system_settings.nfc_enable_flag);
913
914 IPC::ResponseBuilder rb{ctx, 2};
915 rb.Push(ResultSuccess);
840} 916}
841 917
842void ISystemSettingsServer::GetSleepSettings(HLERequestContext& ctx) { 918void ISystemSettingsServer::GetSleepSettings(HLERequestContext& ctx) {
843 LOG_INFO(Service_SET, "called"); 919 LOG_INFO(Service_SET, "called, flags={}, handheld_sleep_plan={}, console_sleep_plan={}",
920 m_system_settings.sleep_settings.flags.raw,
921 m_system_settings.sleep_settings.handheld_sleep_plan,
922 m_system_settings.sleep_settings.console_sleep_plan);
844 923
845 IPC::ResponseBuilder rb{ctx, 5}; 924 IPC::ResponseBuilder rb{ctx, 5};
846 rb.Push(ResultSuccess); 925 rb.Push(ResultSuccess);
@@ -861,8 +940,32 @@ void ISystemSettingsServer::SetSleepSettings(HLERequestContext& ctx) {
861 rb.Push(ResultSuccess); 940 rb.Push(ResultSuccess);
862} 941}
863 942
943void ISystemSettingsServer::GetWirelessLanEnableFlag(HLERequestContext& ctx) {
944 LOG_INFO(Service_SET, "called, wireless_lan_enable_flag={}",
945 m_system_settings.wireless_lan_enable_flag);
946
947 IPC::ResponseBuilder rb{ctx, 3};
948 rb.Push(ResultSuccess);
949 rb.Push(m_system_settings.wireless_lan_enable_flag);
950}
951
952void ISystemSettingsServer::SetWirelessLanEnableFlag(HLERequestContext& ctx) {
953 IPC::RequestParser rp{ctx};
954 m_system_settings.wireless_lan_enable_flag = rp.Pop<bool>();
955 SetSaveNeeded();
956
957 LOG_INFO(Service_SET, "called, wireless_lan_enable_flag={}",
958 m_system_settings.wireless_lan_enable_flag);
959
960 IPC::ResponseBuilder rb{ctx, 2};
961 rb.Push(ResultSuccess);
962}
963
864void ISystemSettingsServer::GetInitialLaunchSettings(HLERequestContext& ctx) { 964void ISystemSettingsServer::GetInitialLaunchSettings(HLERequestContext& ctx) {
865 LOG_INFO(Service_SET, "called"); 965 LOG_INFO(Service_SET, "called, flags={}, timestamp={}",
966 m_system_settings.initial_launch_settings_packed.flags.raw,
967 m_system_settings.initial_launch_settings_packed.timestamp.time_point);
968
866 IPC::ResponseBuilder rb{ctx, 10}; 969 IPC::ResponseBuilder rb{ctx, 10};
867 rb.Push(ResultSuccess); 970 rb.Push(ResultSuccess);
868 rb.PushRaw(m_system_settings.initial_launch_settings_packed); 971 rb.PushRaw(m_system_settings.initial_launch_settings_packed);
@@ -913,35 +1016,51 @@ void ISystemSettingsServer::GetProductModel(HLERequestContext& ctx) {
913 rb.Push(product_model); 1016 rb.Push(product_model);
914} 1017}
915 1018
916void ISystemSettingsServer::GetMiiAuthorId(HLERequestContext& ctx) { 1019void ISystemSettingsServer::GetBluetoothEnableFlag(HLERequestContext& ctx) {
917 const auto author_id = Common::UUID::MakeDefault(); 1020 LOG_INFO(Service_SET, "called, bluetooth_enable_flag={}",
1021 m_system_settings.bluetooth_enable_flag);
918 1022
919 LOG_WARNING(Service_SET, "(STUBBED) called, author_id={}", author_id.FormattedString()); 1023 IPC::ResponseBuilder rb{ctx, 3};
1024 rb.Push(ResultSuccess);
1025 rb.Push<u8>(m_system_settings.bluetooth_enable_flag);
1026}
1027
1028void ISystemSettingsServer::SetBluetoothEnableFlag(HLERequestContext& ctx) {
1029 IPC::RequestParser rp{ctx};
1030 m_system_settings.bluetooth_enable_flag = rp.Pop<bool>();
1031 SetSaveNeeded();
1032
1033 LOG_INFO(Service_SET, "called, bluetooth_enable_flag={}",
1034 m_system_settings.bluetooth_enable_flag);
1035
1036 IPC::ResponseBuilder rb{ctx, 2};
1037 rb.Push(ResultSuccess);
1038}
1039
1040void ISystemSettingsServer::GetMiiAuthorId(HLERequestContext& ctx) {
1041 LOG_INFO(Service_SET, "called, author_id={}",
1042 m_system_settings.mii_author_id.FormattedString());
920 1043
921 IPC::ResponseBuilder rb{ctx, 6}; 1044 IPC::ResponseBuilder rb{ctx, 6};
922 rb.Push(ResultSuccess); 1045 rb.Push(ResultSuccess);
923 rb.PushRaw(author_id); 1046 rb.PushRaw(m_system_settings.mii_author_id);
924} 1047}
925 1048
926void ISystemSettingsServer::GetAutoUpdateEnableFlag(HLERequestContext& ctx) { 1049void ISystemSettingsServer::GetAutoUpdateEnableFlag(HLERequestContext& ctx) {
927 u8 auto_update_flag{}; 1050 LOG_INFO(Service_SET, "called, auto_update_flag={}", m_system_settings.auto_update_enable_flag);
928
929 LOG_WARNING(Service_SET, "(STUBBED) called, auto_update_flag={}", auto_update_flag);
930 1051
931 IPC::ResponseBuilder rb{ctx, 3}; 1052 IPC::ResponseBuilder rb{ctx, 3};
932 rb.Push(ResultSuccess); 1053 rb.Push(ResultSuccess);
933 rb.Push(auto_update_flag); 1054 rb.Push(m_system_settings.auto_update_enable_flag);
934} 1055}
935 1056
936void ISystemSettingsServer::GetBatteryPercentageFlag(HLERequestContext& ctx) { 1057void ISystemSettingsServer::GetBatteryPercentageFlag(HLERequestContext& ctx) {
937 u8 battery_percentage_flag{1}; 1058 LOG_DEBUG(Service_SET, "called, battery_percentage_flag={}",
938 1059 m_system_settings.battery_percentage_flag);
939 LOG_WARNING(Service_SET, "(STUBBED) called, battery_percentage_flag={}",
940 battery_percentage_flag);
941 1060
942 IPC::ResponseBuilder rb{ctx, 3}; 1061 IPC::ResponseBuilder rb{ctx, 3};
943 rb.Push(ResultSuccess); 1062 rb.Push(ResultSuccess);
944 rb.Push(battery_percentage_flag); 1063 rb.Push(m_system_settings.battery_percentage_flag);
945} 1064}
946 1065
947void ISystemSettingsServer::SetExternalSteadyClockInternalOffset(HLERequestContext& ctx) { 1066void ISystemSettingsServer::SetExternalSteadyClockInternalOffset(HLERequestContext& ctx) {
@@ -968,11 +1087,12 @@ void ISystemSettingsServer::GetExternalSteadyClockInternalOffset(HLERequestConte
968} 1087}
969 1088
970void ISystemSettingsServer::GetErrorReportSharePermission(HLERequestContext& ctx) { 1089void ISystemSettingsServer::GetErrorReportSharePermission(HLERequestContext& ctx) {
971 LOG_WARNING(Service_SET, "(STUBBED) called"); 1090 LOG_INFO(Service_SET, "called, error_report_share_permission={}",
1091 m_system_settings.error_report_share_permission);
972 1092
973 IPC::ResponseBuilder rb{ctx, 3}; 1093 IPC::ResponseBuilder rb{ctx, 3};
974 rb.Push(ResultSuccess); 1094 rb.Push(ResultSuccess);
975 rb.PushEnum(ErrorReportSharePermission::Denied); 1095 rb.PushEnum(m_system_settings.error_report_share_permission);
976} 1096}
977 1097
978void ISystemSettingsServer::GetAppletLaunchFlags(HLERequestContext& ctx) { 1098void ISystemSettingsServer::GetAppletLaunchFlags(HLERequestContext& ctx) {
@@ -1014,7 +1134,7 @@ void ISystemSettingsServer::GetKeyboardLayout(HLERequestContext& ctx) {
1014} 1134}
1015 1135
1016void ISystemSettingsServer::GetDeviceTimeZoneLocationUpdatedTime(HLERequestContext& ctx) { 1136void ISystemSettingsServer::GetDeviceTimeZoneLocationUpdatedTime(HLERequestContext& ctx) {
1017 LOG_WARNING(Service_SET, "called."); 1137 LOG_INFO(Service_SET, "called");
1018 1138
1019 Service::Time::Clock::SteadyClockTimePoint time_point{}; 1139 Service::Time::Clock::SteadyClockTimePoint time_point{};
1020 auto res = GetDeviceTimeZoneLocationUpdatedTime(time_point); 1140 auto res = GetDeviceTimeZoneLocationUpdatedTime(time_point);
@@ -1025,7 +1145,7 @@ void ISystemSettingsServer::GetDeviceTimeZoneLocationUpdatedTime(HLERequestConte
1025} 1145}
1026 1146
1027void ISystemSettingsServer::SetDeviceTimeZoneLocationUpdatedTime(HLERequestContext& ctx) { 1147void ISystemSettingsServer::SetDeviceTimeZoneLocationUpdatedTime(HLERequestContext& ctx) {
1028 LOG_WARNING(Service_SET, "called."); 1148 LOG_INFO(Service_SET, "called");
1029 1149
1030 IPC::RequestParser rp{ctx}; 1150 IPC::RequestParser rp{ctx};
1031 auto time_point{rp.PopRaw<Service::Time::Clock::SteadyClockTimePoint>()}; 1151 auto time_point{rp.PopRaw<Service::Time::Clock::SteadyClockTimePoint>()};
@@ -1038,7 +1158,7 @@ void ISystemSettingsServer::SetDeviceTimeZoneLocationUpdatedTime(HLERequestConte
1038 1158
1039void ISystemSettingsServer::GetUserSystemClockAutomaticCorrectionUpdatedTime( 1159void ISystemSettingsServer::GetUserSystemClockAutomaticCorrectionUpdatedTime(
1040 HLERequestContext& ctx) { 1160 HLERequestContext& ctx) {
1041 LOG_WARNING(Service_SET, "called."); 1161 LOG_INFO(Service_SET, "called");
1042 1162
1043 Service::Time::Clock::SteadyClockTimePoint time_point{}; 1163 Service::Time::Clock::SteadyClockTimePoint time_point{};
1044 auto res = GetUserSystemClockAutomaticCorrectionUpdatedTime(time_point); 1164 auto res = GetUserSystemClockAutomaticCorrectionUpdatedTime(time_point);
@@ -1050,7 +1170,7 @@ void ISystemSettingsServer::GetUserSystemClockAutomaticCorrectionUpdatedTime(
1050 1170
1051void ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionUpdatedTime( 1171void ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionUpdatedTime(
1052 HLERequestContext& ctx) { 1172 HLERequestContext& ctx) {
1053 LOG_WARNING(Service_SET, "called."); 1173 LOG_INFO(Service_SET, "called");
1054 1174
1055 IPC::RequestParser rp{ctx}; 1175 IPC::RequestParser rp{ctx};
1056 auto time_point{rp.PopRaw<Service::Time::Clock::SteadyClockTimePoint>()}; 1176 auto time_point{rp.PopRaw<Service::Time::Clock::SteadyClockTimePoint>()};
@@ -1062,11 +1182,12 @@ void ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionUpdatedTime(
1062} 1182}
1063 1183
1064void ISystemSettingsServer::GetChineseTraditionalInputMethod(HLERequestContext& ctx) { 1184void ISystemSettingsServer::GetChineseTraditionalInputMethod(HLERequestContext& ctx) {
1065 LOG_WARNING(Service_SET, "(STUBBED) called"); 1185 LOG_INFO(Service_SET, "called, chinese_traditional_input_method={}",
1186 m_system_settings.chinese_traditional_input_method);
1066 1187
1067 IPC::ResponseBuilder rb{ctx, 3}; 1188 IPC::ResponseBuilder rb{ctx, 3};
1068 rb.Push(ResultSuccess); 1189 rb.Push(ResultSuccess);
1069 rb.PushEnum(ChineseTraditionalInputMethod::Unknown0); 1190 rb.PushEnum(m_system_settings.chinese_traditional_input_method);
1070} 1191}
1071 1192
1072void ISystemSettingsServer::GetHomeMenuScheme(HLERequestContext& ctx) { 1193void ISystemSettingsServer::GetHomeMenuScheme(HLERequestContext& ctx) {
@@ -1094,11 +1215,11 @@ void ISystemSettingsServer::GetHomeMenuSchemeModel(HLERequestContext& ctx) {
1094} 1215}
1095 1216
1096void ISystemSettingsServer::GetFieldTestingFlag(HLERequestContext& ctx) { 1217void ISystemSettingsServer::GetFieldTestingFlag(HLERequestContext& ctx) {
1097 LOG_WARNING(Service_SET, "(STUBBED) called"); 1218 LOG_INFO(Service_SET, "called, field_testing_flag={}", m_system_settings.field_testing_flag);
1098 1219
1099 IPC::ResponseBuilder rb{ctx, 3}; 1220 IPC::ResponseBuilder rb{ctx, 3};
1100 rb.Push(ResultSuccess); 1221 rb.Push(ResultSuccess);
1101 rb.Push<u8>(false); 1222 rb.Push(m_system_settings.field_testing_flag);
1102} 1223}
1103 1224
1104void ISystemSettingsServer::SetupSettings() { 1225void ISystemSettingsServer::SetupSettings() {
diff --git a/src/core/hle/service/set/system_settings_server.h b/src/core/hle/service/set/system_settings_server.h
index 6f587e0b3..32716f567 100644
--- a/src/core/hle/service/set/system_settings_server.h
+++ b/src/core/hle/service/set/system_settings_server.h
@@ -12,10 +12,11 @@
12#include "common/uuid.h" 12#include "common/uuid.h"
13#include "core/hle/result.h" 13#include "core/hle/result.h"
14#include "core/hle/service/service.h" 14#include "core/hle/service/service.h"
15#include "core/hle/service/set/appln_settings.h" 15#include "core/hle/service/set/setting_formats/appln_settings.h"
16#include "core/hle/service/set/device_settings.h" 16#include "core/hle/service/set/setting_formats/device_settings.h"
17#include "core/hle/service/set/private_settings.h" 17#include "core/hle/service/set/setting_formats/private_settings.h"
18#include "core/hle/service/set/system_settings.h" 18#include "core/hle/service/set/setting_formats/system_settings.h"
19#include "core/hle/service/set/settings_types.h"
19#include "core/hle/service/time/clock_types.h" 20#include "core/hle/service/time/clock_types.h"
20#include "core/hle/service/time/time_zone_types.h" 21#include "core/hle/service/time/time_zone_types.h"
21 22
@@ -24,25 +25,6 @@ class System;
24} 25}
25 26
26namespace Service::Set { 27namespace Service::Set {
27enum class GetFirmwareVersionType {
28 Version1,
29 Version2,
30};
31
32struct FirmwareVersionFormat {
33 u8 major;
34 u8 minor;
35 u8 micro;
36 INSERT_PADDING_BYTES(1);
37 u8 revision_major;
38 u8 revision_minor;
39 INSERT_PADDING_BYTES(2);
40 std::array<char, 0x20> platform;
41 std::array<u8, 0x40> version_hash;
42 std::array<char, 0x18> display_version;
43 std::array<char, 0x80> display_title;
44};
45static_assert(sizeof(FirmwareVersionFormat) == 0x100, "FirmwareVersionFormat is an invalid size");
46 28
47Result GetFirmwareVersionImpl(FirmwareVersionFormat& out_firmware, Core::System& system, 29Result GetFirmwareVersionImpl(FirmwareVersionFormat& out_firmware, Core::System& system,
48 GetFirmwareVersionType type); 30 GetFirmwareVersionType type);
@@ -55,6 +37,18 @@ public:
55 Result GetSettingsItemValue(std::vector<u8>& out_value, const std::string& category, 37 Result GetSettingsItemValue(std::vector<u8>& out_value, const std::string& category,
56 const std::string& name); 38 const std::string& name);
57 39
40 template <typename T>
41 Result GetSettingsItemValue(T& value, const std::string& category, const std::string& name) {
42 std::vector<u8> data;
43 const auto result = GetSettingsItemValue(data, category, name);
44 if (result.IsError()) {
45 return result;
46 }
47 ASSERT(data.size() >= sizeof(T));
48 std::memcpy(&value, data.data(), sizeof(T));
49 return result;
50 }
51
58 Result GetExternalSteadyClockSourceId(Common::UUID& out_id); 52 Result GetExternalSteadyClockSourceId(Common::UUID& out_id);
59 Result SetExternalSteadyClockSourceId(Common::UUID id); 53 Result SetExternalSteadyClockSourceId(Common::UUID id);
60 Result GetUserSystemClockContext(Service::Time::Clock::SystemClockContext& out_context); 54 Result GetUserSystemClockContext(Service::Time::Clock::SystemClockContext& out_context);
@@ -80,6 +74,8 @@ private:
80 void SetLanguageCode(HLERequestContext& ctx); 74 void SetLanguageCode(HLERequestContext& ctx);
81 void GetFirmwareVersion(HLERequestContext& ctx); 75 void GetFirmwareVersion(HLERequestContext& ctx);
82 void GetFirmwareVersion2(HLERequestContext& ctx); 76 void GetFirmwareVersion2(HLERequestContext& ctx);
77 void GetLockScreenFlag(HLERequestContext& ctx);
78 void SetLockScreenFlag(HLERequestContext& ctx);
83 void GetExternalSteadyClockSourceId(HLERequestContext& ctx); 79 void GetExternalSteadyClockSourceId(HLERequestContext& ctx);
84 void SetExternalSteadyClockSourceId(HLERequestContext& ctx); 80 void SetExternalSteadyClockSourceId(HLERequestContext& ctx);
85 void GetUserSystemClockContext(HLERequestContext& ctx); 81 void GetUserSystemClockContext(HLERequestContext& ctx);
@@ -108,13 +104,19 @@ private:
108 void IsUserSystemClockAutomaticCorrectionEnabled(HLERequestContext& ctx); 104 void IsUserSystemClockAutomaticCorrectionEnabled(HLERequestContext& ctx);
109 void SetUserSystemClockAutomaticCorrectionEnabled(HLERequestContext& ctx); 105 void SetUserSystemClockAutomaticCorrectionEnabled(HLERequestContext& ctx);
110 void GetPrimaryAlbumStorage(HLERequestContext& ctx); 106 void GetPrimaryAlbumStorage(HLERequestContext& ctx);
107 void GetNfcEnableFlag(HLERequestContext& ctx);
108 void SetNfcEnableFlag(HLERequestContext& ctx);
111 void GetSleepSettings(HLERequestContext& ctx); 109 void GetSleepSettings(HLERequestContext& ctx);
112 void SetSleepSettings(HLERequestContext& ctx); 110 void SetSleepSettings(HLERequestContext& ctx);
111 void GetWirelessLanEnableFlag(HLERequestContext& ctx);
112 void SetWirelessLanEnableFlag(HLERequestContext& ctx);
113 void GetInitialLaunchSettings(HLERequestContext& ctx); 113 void GetInitialLaunchSettings(HLERequestContext& ctx);
114 void SetInitialLaunchSettings(HLERequestContext& ctx); 114 void SetInitialLaunchSettings(HLERequestContext& ctx);
115 void GetDeviceNickName(HLERequestContext& ctx); 115 void GetDeviceNickName(HLERequestContext& ctx);
116 void SetDeviceNickName(HLERequestContext& ctx); 116 void SetDeviceNickName(HLERequestContext& ctx);
117 void GetProductModel(HLERequestContext& ctx); 117 void GetProductModel(HLERequestContext& ctx);
118 void GetBluetoothEnableFlag(HLERequestContext& ctx);
119 void SetBluetoothEnableFlag(HLERequestContext& ctx);
118 void GetMiiAuthorId(HLERequestContext& ctx); 120 void GetMiiAuthorId(HLERequestContext& ctx);
119 void GetAutoUpdateEnableFlag(HLERequestContext& ctx); 121 void GetAutoUpdateEnableFlag(HLERequestContext& ctx);
120 void GetBatteryPercentageFlag(HLERequestContext& ctx); 122 void GetBatteryPercentageFlag(HLERequestContext& ctx);
diff --git a/src/hid_core/resources/hid_firmware_settings.cpp b/src/hid_core/resources/hid_firmware_settings.cpp
index 9fa0db17e..00ceff7e6 100644
--- a/src/hid_core/resources/hid_firmware_settings.cpp
+++ b/src/hid_core/resources/hid_firmware_settings.cpp
@@ -1,11 +1,14 @@
1// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project 1// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-3.0-or-later 2// SPDX-License-Identifier: GPL-3.0-or-later
3 3
4#include "core/hle/service/set/system_settings_server.h"
5#include "core/hle/service/sm/sm.h"
4#include "hid_core/resources/hid_firmware_settings.h" 6#include "hid_core/resources/hid_firmware_settings.h"
5 7
6namespace Service::HID { 8namespace Service::HID {
7 9
8HidFirmwareSettings::HidFirmwareSettings() { 10HidFirmwareSettings::HidFirmwareSettings(Core::System& system) {
11 m_set_sys = system.ServiceManager().GetService<Service::Set::ISystemSettingsServer>("set:sys");
9 LoadSettings(true); 12 LoadSettings(true);
10} 13}
11 14
@@ -18,21 +21,25 @@ void HidFirmwareSettings::LoadSettings(bool reload_config) {
18 return; 21 return;
19 } 22 }
20 23
21 // TODO: Use nn::settings::fwdbg::GetSettingsItemValue to load config values 24 m_set_sys->GetSettingsItemValue<bool>(is_debug_pad_enabled, "hid_debug", "enables_debugpad");
22 25 m_set_sys->GetSettingsItemValue<bool>(is_device_managed, "hid_debug", "manages_devices");
23 is_debug_pad_enabled = true; 26 m_set_sys->GetSettingsItemValue<bool>(is_touch_i2c_managed, "hid_debug",
24 is_device_managed = true; 27 "manages_touch_ic_i2c");
25 is_touch_i2c_managed = is_device_managed; 28 m_set_sys->GetSettingsItemValue<bool>(is_future_devices_emulated, "hid_debug",
26 is_future_devices_emulated = false; 29 "emulate_future_device");
27 is_mcu_hardware_error_emulated = false; 30 m_set_sys->GetSettingsItemValue<bool>(is_mcu_hardware_error_emulated, "hid_debug",
28 is_rail_enabled = true; 31 "emulate_mcu_hardware_error");
29 is_firmware_update_failure_emulated = false; 32 m_set_sys->GetSettingsItemValue<bool>(is_rail_enabled, "hid_debug", "enables_rail");
33 m_set_sys->GetSettingsItemValue<bool>(is_firmware_update_failure_emulated, "hid_debug",
34 "emulate_firmware_update_failure");
30 is_firmware_update_failure = {}; 35 is_firmware_update_failure = {};
31 is_ble_disabled = false; 36 m_set_sys->GetSettingsItemValue<bool>(is_ble_disabled, "hid_debug", "ble_disabled");
32 is_dscale_disabled = false; 37 m_set_sys->GetSettingsItemValue<bool>(is_dscale_disabled, "hid_debug", "dscale_disabled");
33 is_handheld_forced = true; 38 m_set_sys->GetSettingsItemValue<bool>(is_handheld_forced, "hid_debug", "force_handheld");
34 features_per_id_disabled = {}; 39 features_per_id_disabled = {};
35 is_touch_firmware_auto_update_disabled = false; 40 m_set_sys->GetSettingsItemValue<bool>(is_touch_firmware_auto_update_disabled, "hid_debug",
41 "touch_firmware_auto_update_disabled");
42
36 is_initialized = true; 43 is_initialized = true;
37} 44}
38 45
diff --git a/src/hid_core/resources/hid_firmware_settings.h b/src/hid_core/resources/hid_firmware_settings.h
index 00201fd94..3694fa9a3 100644
--- a/src/hid_core/resources/hid_firmware_settings.h
+++ b/src/hid_core/resources/hid_firmware_settings.h
@@ -5,6 +5,14 @@
5 5
6#include "common/common_types.h" 6#include "common/common_types.h"
7 7
8namespace Core {
9class System;
10}
11
12namespace Service::Set {
13class ISystemSettingsServer;
14}
15
8namespace Service::HID { 16namespace Service::HID {
9 17
10/// Loads firmware config from nn::settings::fwdbg 18/// Loads firmware config from nn::settings::fwdbg
@@ -13,7 +21,7 @@ public:
13 using FirmwareSetting = std::array<u8, 4>; 21 using FirmwareSetting = std::array<u8, 4>;
14 using FeaturesPerId = std::array<bool, 0xA8>; 22 using FeaturesPerId = std::array<bool, 0xA8>;
15 23
16 HidFirmwareSettings(); 24 HidFirmwareSettings(Core::System& system);
17 25
18 void Reload(); 26 void Reload();
19 void LoadSettings(bool reload_config); 27 void LoadSettings(bool reload_config);
@@ -49,6 +57,8 @@ private:
49 bool is_touch_firmware_auto_update_disabled{}; 57 bool is_touch_firmware_auto_update_disabled{};
50 FirmwareSetting is_firmware_update_failure{}; 58 FirmwareSetting is_firmware_update_failure{};
51 FeaturesPerId features_per_id_disabled{}; 59 FeaturesPerId features_per_id_disabled{};
60
61 std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys;
52}; 62};
53 63
54} // namespace Service::HID 64} // namespace Service::HID
diff --git a/src/input_common/CMakeLists.txt b/src/input_common/CMakeLists.txt
index d2fbea488..d0a71a15b 100644
--- a/src/input_common/CMakeLists.txt
+++ b/src/input_common/CMakeLists.txt
@@ -2,6 +2,8 @@
2# SPDX-License-Identifier: GPL-2.0-or-later 2# SPDX-License-Identifier: GPL-2.0-or-later
3 3
4add_library(input_common STATIC 4add_library(input_common STATIC
5 drivers/android.cpp
6 drivers/android.h
5 drivers/camera.cpp 7 drivers/camera.cpp
6 drivers/camera.h 8 drivers/camera.h
7 drivers/keyboard.cpp 9 drivers/keyboard.cpp
diff --git a/src/input_common/drivers/android.cpp b/src/input_common/drivers/android.cpp
new file mode 100644
index 000000000..b6a03fdc0
--- /dev/null
+++ b/src/input_common/drivers/android.cpp
@@ -0,0 +1,48 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4#include "input_common/drivers/android.h"
5
6namespace InputCommon {
7
8Android::Android(std::string input_engine_) : InputEngine(std::move(input_engine_)) {}
9
10void Android::RegisterController(std::size_t controller_number) {
11 PreSetController(GetIdentifier(controller_number));
12}
13
14void Android::SetButtonState(std::size_t controller_number, int button_id, bool value) {
15 const auto identifier = GetIdentifier(controller_number);
16 SetButton(identifier, button_id, value);
17}
18
19void Android::SetAxisState(std::size_t controller_number, int axis_id, float value) {
20 const auto identifier = GetIdentifier(controller_number);
21 SetAxis(identifier, axis_id, value);
22}
23
24void Android::SetMotionState(std::size_t controller_number, u64 delta_timestamp, float gyro_x,
25 float gyro_y, float gyro_z, float accel_x, float accel_y,
26 float accel_z) {
27 const auto identifier = GetIdentifier(controller_number);
28 const BasicMotion motion_data{
29 .gyro_x = gyro_x,
30 .gyro_y = gyro_y,
31 .gyro_z = gyro_z,
32 .accel_x = accel_x,
33 .accel_y = accel_y,
34 .accel_z = accel_z,
35 .delta_timestamp = delta_timestamp,
36 };
37 SetMotion(identifier, 0, motion_data);
38}
39
40PadIdentifier Android::GetIdentifier(std::size_t controller_number) const {
41 return {
42 .guid = Common::UUID{},
43 .port = controller_number,
44 .pad = 0,
45 };
46}
47
48} // namespace InputCommon
diff --git a/src/input_common/drivers/android.h b/src/input_common/drivers/android.h
new file mode 100644
index 000000000..3f01817f6
--- /dev/null
+++ b/src/input_common/drivers/android.h
@@ -0,0 +1,54 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4#pragma once
5
6#include "input_common/input_engine.h"
7
8namespace InputCommon {
9
10/**
11 * A virtual controller that is always assigned to the game input
12 */
13class Android final : public InputEngine {
14public:
15 explicit Android(std::string input_engine_);
16
17 /**
18 * Registers controller number to accept new inputs
19 * @param controller_number the controller number that will take this action
20 */
21 void RegisterController(std::size_t controller_number);
22
23 /**
24 * Sets the status of all buttons bound with the key to pressed
25 * @param controller_number the controller number that will take this action
26 * @param button_id the id of the button
27 * @param value indicates if the button is pressed or not
28 */
29 void SetButtonState(std::size_t controller_number, int button_id, bool value);
30
31 /**
32 * Sets the status of a analog input to a specific player index
33 * @param controller_number the controller number that will take this action
34 * @param axis_id the id of the axis to move
35 * @param value the analog position of the axis
36 */
37 void SetAxisState(std::size_t controller_number, int axis_id, float value);
38
39 /**
40 * Sets the status of the motion sensor to a specific player index
41 * @param controller_number the controller number that will take this action
42 * @param delta_timestamp time passed since last reading
43 * @param gyro_x,gyro_y,gyro_z the gyro sensor readings
44 * @param accel_x,accel_y,accel_z the accelerometer reading
45 */
46 void SetMotionState(std::size_t controller_number, u64 delta_timestamp, float gyro_x,
47 float gyro_y, float gyro_z, float accel_x, float accel_y, float accel_z);
48
49private:
50 /// Returns the correct identifier corresponding to the player index
51 PadIdentifier GetIdentifier(std::size_t controller_number) const;
52};
53
54} // namespace InputCommon
diff --git a/src/input_common/input_mapping.cpp b/src/input_common/input_mapping.cpp
index 8c2ee4eb3..f1a1d7398 100644
--- a/src/input_common/input_mapping.cpp
+++ b/src/input_common/input_mapping.cpp
@@ -210,6 +210,9 @@ bool MappingFactory::IsDriverValid(const MappingData& data) const {
210 if (data.engine == "analog_from_button") { 210 if (data.engine == "analog_from_button") {
211 return false; 211 return false;
212 } 212 }
213 if (data.engine == "virtual_gamepad") {
214 return false;
215 }
213 return true; 216 return true;
214} 217}
215 218
diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp
index c77fc04ee..f8749ebbf 100644
--- a/src/input_common/main.cpp
+++ b/src/input_common/main.cpp
@@ -4,6 +4,7 @@
4#include <memory> 4#include <memory>
5#include "common/input.h" 5#include "common/input.h"
6#include "common/param_package.h" 6#include "common/param_package.h"
7#include "input_common/drivers/android.h"
7#include "input_common/drivers/camera.h" 8#include "input_common/drivers/camera.h"
8#include "input_common/drivers/keyboard.h" 9#include "input_common/drivers/keyboard.h"
9#include "input_common/drivers/mouse.h" 10#include "input_common/drivers/mouse.h"
@@ -78,6 +79,7 @@ struct InputSubsystem::Impl {
78 RegisterEngine("cemuhookudp", udp_client); 79 RegisterEngine("cemuhookudp", udp_client);
79 RegisterEngine("tas", tas_input); 80 RegisterEngine("tas", tas_input);
80 RegisterEngine("camera", camera); 81 RegisterEngine("camera", camera);
82 RegisterEngine("android", android);
81 RegisterEngine("virtual_amiibo", virtual_amiibo); 83 RegisterEngine("virtual_amiibo", virtual_amiibo);
82 RegisterEngine("virtual_gamepad", virtual_gamepad); 84 RegisterEngine("virtual_gamepad", virtual_gamepad);
83#ifdef HAVE_SDL2 85#ifdef HAVE_SDL2
@@ -109,6 +111,7 @@ struct InputSubsystem::Impl {
109 UnregisterEngine(udp_client); 111 UnregisterEngine(udp_client);
110 UnregisterEngine(tas_input); 112 UnregisterEngine(tas_input);
111 UnregisterEngine(camera); 113 UnregisterEngine(camera);
114 UnregisterEngine(android);
112 UnregisterEngine(virtual_amiibo); 115 UnregisterEngine(virtual_amiibo);
113 UnregisterEngine(virtual_gamepad); 116 UnregisterEngine(virtual_gamepad);
114#ifdef HAVE_SDL2 117#ifdef HAVE_SDL2
@@ -129,6 +132,8 @@ struct InputSubsystem::Impl {
129 devices.insert(devices.end(), keyboard_devices.begin(), keyboard_devices.end()); 132 devices.insert(devices.end(), keyboard_devices.begin(), keyboard_devices.end());
130 auto mouse_devices = mouse->GetInputDevices(); 133 auto mouse_devices = mouse->GetInputDevices();
131 devices.insert(devices.end(), mouse_devices.begin(), mouse_devices.end()); 134 devices.insert(devices.end(), mouse_devices.begin(), mouse_devices.end());
135 auto android_devices = android->GetInputDevices();
136 devices.insert(devices.end(), android_devices.begin(), android_devices.end());
132#ifdef HAVE_LIBUSB 137#ifdef HAVE_LIBUSB
133 auto gcadapter_devices = gcadapter->GetInputDevices(); 138 auto gcadapter_devices = gcadapter->GetInputDevices();
134 devices.insert(devices.end(), gcadapter_devices.begin(), gcadapter_devices.end()); 139 devices.insert(devices.end(), gcadapter_devices.begin(), gcadapter_devices.end());
@@ -157,6 +162,9 @@ struct InputSubsystem::Impl {
157 if (engine == mouse->GetEngineName()) { 162 if (engine == mouse->GetEngineName()) {
158 return mouse; 163 return mouse;
159 } 164 }
165 if (engine == android->GetEngineName()) {
166 return android;
167 }
160#ifdef HAVE_LIBUSB 168#ifdef HAVE_LIBUSB
161 if (engine == gcadapter->GetEngineName()) { 169 if (engine == gcadapter->GetEngineName()) {
162 return gcadapter; 170 return gcadapter;
@@ -237,6 +245,9 @@ struct InputSubsystem::Impl {
237 if (engine == mouse->GetEngineName()) { 245 if (engine == mouse->GetEngineName()) {
238 return true; 246 return true;
239 } 247 }
248 if (engine == android->GetEngineName()) {
249 return true;
250 }
240#ifdef HAVE_LIBUSB 251#ifdef HAVE_LIBUSB
241 if (engine == gcadapter->GetEngineName()) { 252 if (engine == gcadapter->GetEngineName()) {
242 return true; 253 return true;
@@ -265,6 +276,7 @@ struct InputSubsystem::Impl {
265 void BeginConfiguration() { 276 void BeginConfiguration() {
266 keyboard->BeginConfiguration(); 277 keyboard->BeginConfiguration();
267 mouse->BeginConfiguration(); 278 mouse->BeginConfiguration();
279 android->BeginConfiguration();
268#ifdef HAVE_LIBUSB 280#ifdef HAVE_LIBUSB
269 gcadapter->BeginConfiguration(); 281 gcadapter->BeginConfiguration();
270#endif 282#endif
@@ -278,6 +290,7 @@ struct InputSubsystem::Impl {
278 void EndConfiguration() { 290 void EndConfiguration() {
279 keyboard->EndConfiguration(); 291 keyboard->EndConfiguration();
280 mouse->EndConfiguration(); 292 mouse->EndConfiguration();
293 android->EndConfiguration();
281#ifdef HAVE_LIBUSB 294#ifdef HAVE_LIBUSB
282 gcadapter->EndConfiguration(); 295 gcadapter->EndConfiguration();
283#endif 296#endif
@@ -308,6 +321,7 @@ struct InputSubsystem::Impl {
308 std::shared_ptr<TasInput::Tas> tas_input; 321 std::shared_ptr<TasInput::Tas> tas_input;
309 std::shared_ptr<CemuhookUDP::UDPClient> udp_client; 322 std::shared_ptr<CemuhookUDP::UDPClient> udp_client;
310 std::shared_ptr<Camera> camera; 323 std::shared_ptr<Camera> camera;
324 std::shared_ptr<Android> android;
311 std::shared_ptr<VirtualAmiibo> virtual_amiibo; 325 std::shared_ptr<VirtualAmiibo> virtual_amiibo;
312 std::shared_ptr<VirtualGamepad> virtual_gamepad; 326 std::shared_ptr<VirtualGamepad> virtual_gamepad;
313 327
@@ -373,6 +387,14 @@ const Camera* InputSubsystem::GetCamera() const {
373 return impl->camera.get(); 387 return impl->camera.get();
374} 388}
375 389
390Android* InputSubsystem::GetAndroid() {
391 return impl->android.get();
392}
393
394const Android* InputSubsystem::GetAndroid() const {
395 return impl->android.get();
396}
397
376VirtualAmiibo* InputSubsystem::GetVirtualAmiibo() { 398VirtualAmiibo* InputSubsystem::GetVirtualAmiibo() {
377 return impl->virtual_amiibo.get(); 399 return impl->virtual_amiibo.get();
378} 400}
diff --git a/src/input_common/main.h b/src/input_common/main.h
index d64a6cb4c..1d19019ee 100644
--- a/src/input_common/main.h
+++ b/src/input_common/main.h
@@ -29,6 +29,7 @@ enum Values : int;
29} 29}
30 30
31namespace InputCommon { 31namespace InputCommon {
32class Android;
32class Camera; 33class Camera;
33class Keyboard; 34class Keyboard;
34class Mouse; 35class Mouse;
@@ -103,6 +104,12 @@ public:
103 /// Retrieves the underlying camera input device. 104 /// Retrieves the underlying camera input device.
104 [[nodiscard]] const Camera* GetCamera() const; 105 [[nodiscard]] const Camera* GetCamera() const;
105 106
107 /// Retrieves the underlying android input device.
108 [[nodiscard]] Android* GetAndroid();
109
110 /// Retrieves the underlying android input device.
111 [[nodiscard]] const Android* GetAndroid() const;
112
106 /// Retrieves the underlying virtual amiibo input device. 113 /// Retrieves the underlying virtual amiibo input device.
107 [[nodiscard]] VirtualAmiibo* GetVirtualAmiibo(); 114 [[nodiscard]] VirtualAmiibo* GetVirtualAmiibo();
108 115
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp
index 800754554..64a4e0e55 100644
--- a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp
+++ b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp
@@ -12,6 +12,11 @@ namespace Shader::Backend::SPIRV {
12namespace { 12namespace {
13class ImageOperands { 13class ImageOperands {
14public: 14public:
15 [[maybe_unused]] static constexpr bool ImageSampleOffsetAllowed = false;
16 [[maybe_unused]] static constexpr bool ImageGatherOffsetAllowed = true;
17 [[maybe_unused]] static constexpr bool ImageFetchOffsetAllowed = false;
18 [[maybe_unused]] static constexpr bool ImageGradientOffsetAllowed = false;
19
15 explicit ImageOperands(EmitContext& ctx, bool has_bias, bool has_lod, bool has_lod_clamp, 20 explicit ImageOperands(EmitContext& ctx, bool has_bias, bool has_lod, bool has_lod_clamp,
16 Id lod, const IR::Value& offset) { 21 Id lod, const IR::Value& offset) {
17 if (has_bias) { 22 if (has_bias) {
@@ -22,7 +27,7 @@ public:
22 const Id lod_value{has_lod_clamp ? ctx.OpCompositeExtract(ctx.F32[1], lod, 0) : lod}; 27 const Id lod_value{has_lod_clamp ? ctx.OpCompositeExtract(ctx.F32[1], lod, 0) : lod};
23 Add(spv::ImageOperandsMask::Lod, lod_value); 28 Add(spv::ImageOperandsMask::Lod, lod_value);
24 } 29 }
25 AddOffset(ctx, offset); 30 AddOffset(ctx, offset, ImageSampleOffsetAllowed);
26 if (has_lod_clamp) { 31 if (has_lod_clamp) {
27 const Id lod_clamp{has_bias ? ctx.OpCompositeExtract(ctx.F32[1], lod, 1) : lod}; 32 const Id lod_clamp{has_bias ? ctx.OpCompositeExtract(ctx.F32[1], lod, 1) : lod};
28 Add(spv::ImageOperandsMask::MinLod, lod_clamp); 33 Add(spv::ImageOperandsMask::MinLod, lod_clamp);
@@ -55,20 +60,17 @@ public:
55 Add(spv::ImageOperandsMask::ConstOffsets, offsets); 60 Add(spv::ImageOperandsMask::ConstOffsets, offsets);
56 } 61 }
57 62
58 explicit ImageOperands(Id offset, Id lod, Id ms) { 63 explicit ImageOperands(Id lod, Id ms) {
59 if (Sirit::ValidId(lod)) { 64 if (Sirit::ValidId(lod)) {
60 Add(spv::ImageOperandsMask::Lod, lod); 65 Add(spv::ImageOperandsMask::Lod, lod);
61 } 66 }
62 if (Sirit::ValidId(offset)) {
63 Add(spv::ImageOperandsMask::Offset, offset);
64 }
65 if (Sirit::ValidId(ms)) { 67 if (Sirit::ValidId(ms)) {
66 Add(spv::ImageOperandsMask::Sample, ms); 68 Add(spv::ImageOperandsMask::Sample, ms);
67 } 69 }
68 } 70 }
69 71
70 explicit ImageOperands(EmitContext& ctx, bool has_lod_clamp, Id derivatives, 72 explicit ImageOperands(EmitContext& ctx, bool has_lod_clamp, Id derivatives,
71 u32 num_derivatives, Id offset, Id lod_clamp) { 73 u32 num_derivatives, const IR::Value& offset, Id lod_clamp) {
72 if (!Sirit::ValidId(derivatives)) { 74 if (!Sirit::ValidId(derivatives)) {
73 throw LogicError("Derivatives must be present"); 75 throw LogicError("Derivatives must be present");
74 } 76 }
@@ -83,16 +85,14 @@ public:
83 const Id derivatives_Y{ctx.OpCompositeConstruct( 85 const Id derivatives_Y{ctx.OpCompositeConstruct(
84 ctx.F32[num_derivatives], std::span{deriv_y_accum.data(), deriv_y_accum.size()})}; 86 ctx.F32[num_derivatives], std::span{deriv_y_accum.data(), deriv_y_accum.size()})};
85 Add(spv::ImageOperandsMask::Grad, derivatives_X, derivatives_Y); 87 Add(spv::ImageOperandsMask::Grad, derivatives_X, derivatives_Y);
86 if (Sirit::ValidId(offset)) { 88 AddOffset(ctx, offset, ImageGradientOffsetAllowed);
87 Add(spv::ImageOperandsMask::Offset, offset);
88 }
89 if (has_lod_clamp) { 89 if (has_lod_clamp) {
90 Add(spv::ImageOperandsMask::MinLod, lod_clamp); 90 Add(spv::ImageOperandsMask::MinLod, lod_clamp);
91 } 91 }
92 } 92 }
93 93
94 explicit ImageOperands(EmitContext& ctx, bool has_lod_clamp, Id derivatives_1, Id derivatives_2, 94 explicit ImageOperands(EmitContext& ctx, bool has_lod_clamp, Id derivatives_1, Id derivatives_2,
95 Id offset, Id lod_clamp) { 95 const IR::Value& offset, Id lod_clamp) {
96 if (!Sirit::ValidId(derivatives_1) || !Sirit::ValidId(derivatives_2)) { 96 if (!Sirit::ValidId(derivatives_1) || !Sirit::ValidId(derivatives_2)) {
97 throw LogicError("Derivatives must be present"); 97 throw LogicError("Derivatives must be present");
98 } 98 }
@@ -111,9 +111,7 @@ public:
111 const Id derivatives_id2{ctx.OpCompositeConstruct( 111 const Id derivatives_id2{ctx.OpCompositeConstruct(
112 ctx.F32[3], std::span{deriv_2_accum.data(), deriv_2_accum.size()})}; 112 ctx.F32[3], std::span{deriv_2_accum.data(), deriv_2_accum.size()})};
113 Add(spv::ImageOperandsMask::Grad, derivatives_id1, derivatives_id2); 113 Add(spv::ImageOperandsMask::Grad, derivatives_id1, derivatives_id2);
114 if (Sirit::ValidId(offset)) { 114 AddOffset(ctx, offset, ImageGradientOffsetAllowed);
115 Add(spv::ImageOperandsMask::Offset, offset);
116 }
117 if (has_lod_clamp) { 115 if (has_lod_clamp) {
118 Add(spv::ImageOperandsMask::MinLod, lod_clamp); 116 Add(spv::ImageOperandsMask::MinLod, lod_clamp);
119 } 117 }
@@ -132,7 +130,7 @@ public:
132 } 130 }
133 131
134private: 132private:
135 void AddOffset(EmitContext& ctx, const IR::Value& offset) { 133 void AddOffset(EmitContext& ctx, const IR::Value& offset, bool runtime_offset_allowed) {
136 if (offset.IsEmpty()) { 134 if (offset.IsEmpty()) {
137 return; 135 return;
138 } 136 }
@@ -165,7 +163,9 @@ private:
165 break; 163 break;
166 } 164 }
167 } 165 }
168 Add(spv::ImageOperandsMask::Offset, ctx.Def(offset)); 166 if (runtime_offset_allowed) {
167 Add(spv::ImageOperandsMask::Offset, ctx.Def(offset));
168 }
169 } 169 }
170 170
171 void Add(spv::ImageOperandsMask new_mask, Id value) { 171 void Add(spv::ImageOperandsMask new_mask, Id value) {
@@ -311,6 +311,37 @@ Id ImageGatherSubpixelOffset(EmitContext& ctx, const IR::TextureInstInfo& info,
311 return coords; 311 return coords;
312 } 312 }
313} 313}
314
315void AddOffsetToCoordinates(EmitContext& ctx, const IR::TextureInstInfo& info, Id& coords,
316 Id offset) {
317 if (!Sirit::ValidId(offset)) {
318 return;
319 }
320
321 Id result_type{};
322 switch (info.type) {
323 case TextureType::Buffer:
324 case TextureType::Color1D:
325 case TextureType::ColorArray1D: {
326 result_type = ctx.U32[1];
327 break;
328 }
329 case TextureType::Color2D:
330 case TextureType::Color2DRect:
331 case TextureType::ColorArray2D: {
332 result_type = ctx.U32[2];
333 break;
334 }
335 case TextureType::Color3D: {
336 result_type = ctx.U32[3];
337 break;
338 }
339 case TextureType::ColorCube:
340 case TextureType::ColorArrayCube:
341 return;
342 }
343 coords = ctx.OpIAdd(result_type, coords, offset);
344}
314} // Anonymous namespace 345} // Anonymous namespace
315 346
316Id EmitBindlessImageSampleImplicitLod(EmitContext&) { 347Id EmitBindlessImageSampleImplicitLod(EmitContext&) {
@@ -496,6 +527,7 @@ Id EmitImageGatherDref(EmitContext& ctx, IR::Inst* inst, const IR::Value& index,
496Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, Id offset, 527Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, Id offset,
497 Id lod, Id ms) { 528 Id lod, Id ms) {
498 const auto info{inst->Flags<IR::TextureInstInfo>()}; 529 const auto info{inst->Flags<IR::TextureInstInfo>()};
530 AddOffsetToCoordinates(ctx, info, coords, offset);
499 if (info.type == TextureType::Buffer) { 531 if (info.type == TextureType::Buffer) {
500 lod = Id{}; 532 lod = Id{};
501 } 533 }
@@ -503,7 +535,7 @@ Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id c
503 // This image is multisampled, lod must be implicit 535 // This image is multisampled, lod must be implicit
504 lod = Id{}; 536 lod = Id{};
505 } 537 }
506 const ImageOperands operands(offset, lod, ms); 538 const ImageOperands operands(lod, ms);
507 return Emit(&EmitContext::OpImageSparseFetch, &EmitContext::OpImageFetch, ctx, inst, ctx.F32[4], 539 return Emit(&EmitContext::OpImageSparseFetch, &EmitContext::OpImageFetch, ctx, inst, ctx.F32[4],
508 TextureImage(ctx, info, index), coords, operands.MaskOptional(), operands.Span()); 540 TextureImage(ctx, info, index), coords, operands.MaskOptional(), operands.Span());
509} 541}
@@ -548,13 +580,13 @@ Id EmitImageQueryLod(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, I
548} 580}
549 581
550Id EmitImageGradient(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, 582Id EmitImageGradient(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords,
551 Id derivatives, Id offset, Id lod_clamp) { 583 Id derivatives, const IR::Value& offset, Id lod_clamp) {
552 const auto info{inst->Flags<IR::TextureInstInfo>()}; 584 const auto info{inst->Flags<IR::TextureInstInfo>()};
553 const auto operands = 585 const auto operands = info.num_derivatives == 3
554 info.num_derivatives == 3 586 ? ImageOperands(ctx, info.has_lod_clamp != 0, derivatives,
555 ? ImageOperands(ctx, info.has_lod_clamp != 0, derivatives, offset, {}, lod_clamp) 587 ctx.Def(offset), {}, lod_clamp)
556 : ImageOperands(ctx, info.has_lod_clamp != 0, derivatives, info.num_derivatives, offset, 588 : ImageOperands(ctx, info.has_lod_clamp != 0, derivatives,
557 lod_clamp); 589 info.num_derivatives, offset, lod_clamp);
558 return Emit(&EmitContext::OpImageSparseSampleExplicitLod, 590 return Emit(&EmitContext::OpImageSparseSampleExplicitLod,
559 &EmitContext::OpImageSampleExplicitLod, ctx, inst, ctx.F32[4], 591 &EmitContext::OpImageSampleExplicitLod, ctx, inst, ctx.F32[4],
560 Texture(ctx, info, index), coords, operands.Mask(), operands.Span()); 592 Texture(ctx, info, index), coords, operands.Mask(), operands.Span());
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h
index 7d34575c8..5c01b1012 100644
--- a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h
+++ b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h
@@ -543,7 +543,7 @@ Id EmitImageQueryDimensions(EmitContext& ctx, IR::Inst* inst, const IR::Value& i
543 const IR::Value& skip_mips); 543 const IR::Value& skip_mips);
544Id EmitImageQueryLod(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords); 544Id EmitImageQueryLod(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords);
545Id EmitImageGradient(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, 545Id EmitImageGradient(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords,
546 Id derivatives, Id offset, Id lod_clamp); 546 Id derivatives, const IR::Value& offset, Id lod_clamp);
547Id EmitImageRead(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords); 547Id EmitImageRead(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords);
548void EmitImageWrite(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, Id color); 548void EmitImageWrite(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, Id color);
549Id EmitIsTextureScaled(EmitContext& ctx, const IR::Value& index); 549Id EmitIsTextureScaled(EmitContext& ctx, const IR::Value& index);