From 89d6856090708dd6a67c33c7149e7f3d9665908b Mon Sep 17 00:00:00 2001 From: Narr the Reg Date: Sun, 14 Jan 2024 19:22:30 -0600 Subject: [PATCH 1/2] service: set: Refractor setting service --- src/core/CMakeLists.txt | 17 +- src/core/hle/service/set/private_settings.h | 72 --- .../{ => setting_formats}/appln_settings.cpp | 2 +- .../{ => setting_formats}/appln_settings.h | 17 +- .../{ => setting_formats}/device_settings.cpp | 2 +- .../{ => setting_formats}/device_settings.h | 16 +- .../private_settings.cpp | 2 +- .../set/setting_formats/private_settings.h | 39 ++ .../{ => setting_formats}/system_settings.cpp | 2 +- .../{ => setting_formats}/system_settings.h | 496 ++++-------------- src/core/hle/service/set/settings_server.h | 61 +-- src/core/hle/service/set/settings_types.h | 451 ++++++++++++++++ .../service/set/system_settings_server.cpp | 2 +- .../hle/service/set/system_settings_server.h | 28 +- 14 files changed, 619 insertions(+), 588 deletions(-) delete mode 100644 src/core/hle/service/set/private_settings.h rename src/core/hle/service/set/{ => setting_formats}/appln_settings.cpp (77%) rename src/core/hle/service/set/{ => setting_formats}/appln_settings.h (71%) rename src/core/hle/service/set/{ => setting_formats}/device_settings.cpp (77%) rename src/core/hle/service/set/{ => setting_formats}/device_settings.h (82%) rename src/core/hle/service/set/{ => setting_formats}/private_settings.cpp (77%) create mode 100644 src/core/hle/service/set/setting_formats/private_settings.h rename src/core/hle/service/set/{ => setting_formats}/system_settings.cpp (95%) rename src/core/hle/service/set/{ => setting_formats}/system_settings.h (53%) create mode 100644 src/core/hle/service/set/settings_types.h 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 hle/service/server_manager.h hle/service/service.cpp hle/service/service.h - hle/service/set/appln_settings.cpp - hle/service/set/appln_settings.h - hle/service/set/device_settings.cpp - hle/service/set/device_settings.h + hle/service/set/setting_formats/appln_settings.cpp + hle/service/set/setting_formats/appln_settings.h + hle/service/set/setting_formats/device_settings.cpp + hle/service/set/setting_formats/device_settings.h + hle/service/set/setting_formats/system_settings.cpp + hle/service/set/setting_formats/system_settings.h + hle/service/set/setting_formats/private_settings.cpp + hle/service/set/setting_formats/private_settings.h hle/service/set/factory_settings_server.cpp hle/service/set/factory_settings_server.h hle/service/set/firmware_debug_settings_server.cpp hle/service/set/firmware_debug_settings_server.h - hle/service/set/private_settings.cpp - hle/service/set/private_settings.h hle/service/set/settings.cpp hle/service/set/settings.h hle/service/set/settings_server.cpp hle/service/set/settings_server.h - hle/service/set/system_settings.cpp - hle/service/set/system_settings.h + hle/service/set/settings_types.h hle/service/set/system_settings_server.cpp hle/service/set/system_settings_server.h hle/service/sm/sm.cpp 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 @@ -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include - -#include "common/bit_field.h" -#include "common/common_funcs.h" -#include "common/common_types.h" -#include "common/uuid.h" -#include "core/hle/service/time/clock_types.h" - -namespace Service::Set { - -/// This is nn::settings::system::InitialLaunchFlag -struct InitialLaunchFlag { - union { - u32 raw{}; - - BitField<0, 1, u32> InitialLaunchCompletionFlag; - BitField<8, 1, u32> InitialLaunchUserAdditionFlag; - BitField<16, 1, u32> InitialLaunchTimestampFlag; - }; -}; -static_assert(sizeof(InitialLaunchFlag) == 4, "InitialLaunchFlag is an invalid size"); - -/// This is nn::settings::system::InitialLaunchSettings -struct InitialLaunchSettings { - InitialLaunchFlag flags; - INSERT_PADDING_BYTES(0x4); - Service::Time::Clock::SteadyClockTimePoint timestamp; -}; -static_assert(sizeof(InitialLaunchSettings) == 0x20, "InitialLaunchSettings is incorrect size"); - -#pragma pack(push, 4) -struct InitialLaunchSettingsPacked { - InitialLaunchFlag flags; - Service::Time::Clock::SteadyClockTimePoint timestamp; -}; -#pragma pack(pop) -static_assert(sizeof(InitialLaunchSettingsPacked) == 0x1C, - "InitialLaunchSettingsPacked is incorrect size"); - -struct PrivateSettings { - std::array reserved_00; - - // nn::settings::system::InitialLaunchSettings - InitialLaunchSettings initial_launch_settings; - - std::array reserved_30; - - Common::UUID external_clock_source_id; - s64 shutdown_rtc_value; - s64 external_steady_clock_internal_offset; - - std::array reserved_70; - - // nn::settings::system::PlatformRegion - std::array platform_region; - - std::array reserved_D4; -}; -static_assert(offsetof(PrivateSettings, initial_launch_settings) == 0x10); -static_assert(offsetof(PrivateSettings, external_clock_source_id) == 0x50); -static_assert(offsetof(PrivateSettings, reserved_70) == 0x70); -static_assert(offsetof(PrivateSettings, platform_region) == 0xD0); -static_assert(sizeof(PrivateSettings) == 0xD8, "PrivateSettings has the wrong size!"); - -PrivateSettings DefaultPrivateSettings(); - -} // 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 similarity index 77% rename from src/core/hle/service/set/appln_settings.cpp rename to src/core/hle/service/set/setting_formats/appln_settings.cpp index a5d802757..566ee1b13 100644 --- a/src/core/hle/service/set/appln_settings.cpp +++ b/src/core/hle/service/set/setting_formats/appln_settings.cpp @@ -1,7 +1,7 @@ // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include "core/hle/service/set/appln_settings.h" +#include "core/hle/service/set/setting_formats/appln_settings.h" 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 similarity index 71% rename from src/core/hle/service/set/appln_settings.h rename to 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 @@ #include #include "common/common_types.h" +#include "common/uuid.h" +#include "core/hle/service/set/settings_types.h" namespace Service::Set { struct ApplnSettings { - std::array reserved_000; + INSERT_PADDING_BYTES(0x10); // Reserved // nn::util::Uuid MiiAuthorId, copied from system settings 0x94B0 - std::array mii_author_id; - - std::array reserved_020; + Common::UUID mii_author_id; + INSERT_PADDING_BYTES(0x30); // Reserved // nn::settings::system::ServiceDiscoveryControlSettings - std::array service_discovery_control_settings; - - std::array reserved_054; + u32 service_discovery_control_settings; + INSERT_PADDING_BYTES(0x20); // Reserved bool in_repair_process_enable_flag; - - std::array pad_075; + INSERT_PADDING_BYTES(0x3); }; static_assert(offsetof(ApplnSettings, mii_author_id) == 0x10); static_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 similarity index 77% rename from src/core/hle/service/set/device_settings.cpp rename to 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 @@ // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include "core/hle/service/set/device_settings.h" +#include "core/hle/service/set/setting_formats/device_settings.h" namespace Service::Set { diff --git a/src/core/hle/service/set/device_settings.h b/src/core/hle/service/set/setting_formats/device_settings.h similarity index 82% rename from src/core/hle/service/set/device_settings.h rename to 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 @@ #include #include "common/common_types.h" +#include "common/vector_math.h" +#include "core/hle/service/set/settings_types.h" namespace Service::Set { struct DeviceSettings { - std::array reserved_000; + INSERT_PADDING_BYTES(0x10); // Reserved // nn::settings::BatteryLot std::array ptm_battery_lot; @@ -19,26 +21,24 @@ struct DeviceSettings { u8 ptm_battery_version; // nn::settings::system::PtmCycleCountReliability u32 ptm_cycle_count_reliability; - - std::array reserved_048; + INSERT_PADDING_BYTES(0x48); // Reserved // nn::settings::system::AnalogStickUserCalibration L std::array analog_user_stick_calibration_l; // nn::settings::system::AnalogStickUserCalibration R std::array analog_user_stick_calibration_r; - - std::array reserved_0B0; + INSERT_PADDING_BYTES(0x20); // Reserved // nn::settings::system::ConsoleSixAxisSensorAccelerationBias - std::array console_six_axis_sensor_acceleration_bias; + Common::Vec3 console_six_axis_sensor_acceleration_bias; // nn::settings::system::ConsoleSixAxisSensorAngularVelocityBias - std::array console_six_axis_sensor_angular_velocity_bias; + Common::Vec3 console_six_axis_sensor_angular_velocity_bias; // nn::settings::system::ConsoleSixAxisSensorAccelerationGain std::array console_six_axis_sensor_acceleration_gain; // nn::settings::system::ConsoleSixAxisSensorAngularVelocityGain std::array console_six_axis_sensor_angular_velocity_gain; // nn::settings::system::ConsoleSixAxisSensorAngularVelocityTimeBias - std::array console_six_axis_sensor_angular_velocity_time_bias; + Common::Vec3 console_six_axis_sensor_angular_velocity_time_bias; // nn::settings::system::ConsoleSixAxisSensorAngularAcceleration std::array console_six_axis_sensor_angular_acceleration; }; diff --git a/src/core/hle/service/set/private_settings.cpp b/src/core/hle/service/set/setting_formats/private_settings.cpp similarity index 77% rename from src/core/hle/service/set/private_settings.cpp rename to 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 @@ // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include "core/hle/service/set/private_settings.h" +#include "core/hle/service/set/setting_formats/private_settings.h" namespace Service::Set { 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 @@ +// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include + +#include "common/common_types.h" +#include "common/uuid.h" +#include "core/hle/service/set/settings_types.h" +#include "core/hle/service/time/clock_types.h" + +namespace Service::Set { + +struct PrivateSettings { + INSERT_PADDING_BYTES(0x10); // Reserved + + InitialLaunchSettings initial_launch_settings; + INSERT_PADDING_BYTES(0x20); // Reserved + + Common::UUID external_clock_source_id; + s64 shutdown_rtc_value; + s64 external_steady_clock_internal_offset; + INSERT_PADDING_BYTES(0x60); // Reserved + + // nn::settings::system::PlatformRegion + s32 platform_region; + INSERT_PADDING_BYTES(0x4); // Reserved +}; +static_assert(offsetof(PrivateSettings, initial_launch_settings) == 0x10); +static_assert(offsetof(PrivateSettings, external_clock_source_id) == 0x50); +static_assert(offsetof(PrivateSettings, shutdown_rtc_value) == 0x60); +static_assert(offsetof(PrivateSettings, external_steady_clock_internal_offset) == 0x68); +static_assert(offsetof(PrivateSettings, platform_region) == 0xD0); +static_assert(sizeof(PrivateSettings) == 0xD8, "PrivateSettings has the wrong size!"); + +PrivateSettings DefaultPrivateSettings(); + +} // 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 similarity index 95% rename from src/core/hle/service/set/system_settings.cpp rename to src/core/hle/service/set/setting_formats/system_settings.cpp index 5977429b2..4e524c0de 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 @@ // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include "core/hle/service/set/system_settings.h" +#include "core/hle/service/set/setting_formats/system_settings.h" namespace Service::Set { diff --git a/src/core/hle/service/set/system_settings.h b/src/core/hle/service/set/setting_formats/system_settings.h similarity index 53% rename from src/core/hle/service/set/system_settings.h rename to 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 @@ #include "common/bit_field.h" #include "common/common_funcs.h" #include "common/common_types.h" -#include "core/hle/service/set/private_settings.h" +#include "common/uuid.h" +#include "common/vector_math.h" +#include "core/hle/service/set/setting_formats/private_settings.h" +#include "core/hle/service/set/settings_types.h" #include "core/hle/service/time/clock_types.h" namespace Service::Set { -/// This is "nn::settings::LanguageCode", which is a NUL-terminated string stored in a u64. -enum class LanguageCode : u64 { - JA = 0x000000000000616A, - EN_US = 0x00000053552D6E65, - FR = 0x0000000000007266, - DE = 0x0000000000006564, - IT = 0x0000000000007469, - ES = 0x0000000000007365, - ZH_CN = 0x0000004E432D687A, - KO = 0x0000000000006F6B, - NL = 0x0000000000006C6E, - PT = 0x0000000000007470, - RU = 0x0000000000007572, - ZH_TW = 0x00000057542D687A, - EN_GB = 0x00000042472D6E65, - FR_CA = 0x00000041432D7266, - ES_419 = 0x00003931342D7365, - ZH_HANS = 0x00736E61482D687A, - ZH_HANT = 0x00746E61482D687A, - PT_BR = 0x00000052422D7470, -}; - -/// This is nn::settings::system::ErrorReportSharePermission -enum class ErrorReportSharePermission : u32 { - NotConfirmed, - Granted, - Denied, -}; - -/// This is nn::settings::system::ChineseTraditionalInputMethod -enum class ChineseTraditionalInputMethod : u32 { - Unknown0 = 0, - Unknown1 = 1, - Unknown2 = 2, -}; - -/// This is nn::settings::system::HomeMenuScheme -struct HomeMenuScheme { - u32 main; - u32 back; - u32 sub; - u32 bezel; - u32 extra; -}; -static_assert(sizeof(HomeMenuScheme) == 0x14, "HomeMenuScheme is incorrect size"); - -/// Indicates the current theme set by the system settings -enum class ColorSet : u32 { - BasicWhite = 0, - BasicBlack = 1, -}; - -/// Indicates the current console is a retail or kiosk unit -enum class QuestFlag : u8 { - Retail = 0, - Kiosk = 1, -}; - -/// This is nn::settings::system::RegionCode -enum class RegionCode : u32 { - Japan, - Usa, - Europe, - Australia, - HongKongTaiwanKorea, - China, -}; - -/// This is nn::settings::system::AccountSettings -struct AccountSettings { - u32 flags; -}; -static_assert(sizeof(AccountSettings) == 4, "AccountSettings is an invalid size"); - -/// This is nn::settings::system::NotificationVolume -enum class NotificationVolume : u32 { - Mute, - Low, - High, -}; - -/// This is nn::settings::system::NotificationFlag -struct NotificationFlag { - union { - u32 raw{}; - - BitField<0, 1, u32> RingtoneFlag; - BitField<1, 1, u32> DownloadCompletionFlag; - BitField<8, 1, u32> EnablesNews; - BitField<9, 1, u32> IncomingLampFlag; - }; -}; -static_assert(sizeof(NotificationFlag) == 4, "NotificationFlag is an invalid size"); - -/// This is nn::settings::system::NotificationTime -struct NotificationTime { - u32 hour; - u32 minute; -}; -static_assert(sizeof(NotificationTime) == 0x8, "NotificationTime is an invalid size"); - -/// This is nn::settings::system::NotificationSettings -struct NotificationSettings { - NotificationFlag flags; - NotificationVolume volume; - NotificationTime start_time; - NotificationTime stop_time; -}; -static_assert(sizeof(NotificationSettings) == 0x18, "NotificationSettings is an invalid size"); - -/// This is nn::settings::system::AccountNotificationFlag -struct AccountNotificationFlag { - union { - u32 raw{}; - - BitField<0, 1, u32> FriendOnlineFlag; - BitField<1, 1, u32> FriendRequestFlag; - BitField<8, 1, u32> CoralInvitationFlag; - }; -}; -static_assert(sizeof(AccountNotificationFlag) == 4, "AccountNotificationFlag is an invalid size"); - -/// This is nn::settings::system::FriendPresenceOverlayPermission -enum class FriendPresenceOverlayPermission : u8 { - NotConfirmed, - NoDisplay, - FavoriteFriends, - Friends, -}; - -/// This is nn::settings::system::AccountNotificationSettings -struct AccountNotificationSettings { - Common::UUID uid; - AccountNotificationFlag flags; - FriendPresenceOverlayPermission friend_presence_permission; - FriendPresenceOverlayPermission friend_invitation_permission; - INSERT_PADDING_BYTES(0x2); -}; -static_assert(sizeof(AccountNotificationSettings) == 0x18, - "AccountNotificationSettings is an invalid size"); - -/// This is nn::settings::system::TvFlag -struct TvFlag { - union { - u32 raw{}; - - BitField<0, 1, u32> Allows4k; - BitField<1, 1, u32> Allows3d; - BitField<2, 1, u32> AllowsCec; - BitField<3, 1, u32> PreventsScreenBurnIn; - }; -}; -static_assert(sizeof(TvFlag) == 4, "TvFlag is an invalid size"); - -/// This is nn::settings::system::TvResolution -enum class TvResolution : u32 { - Auto, - Resolution1080p, - Resolution720p, - Resolution480p, -}; - -/// This is nn::settings::system::HdmiContentType -enum class HdmiContentType : u32 { - None, - Graphics, - Cinema, - Photo, - Game, -}; - -/// This is nn::settings::system::RgbRange -enum class RgbRange : u32 { - Auto, - Full, - Limited, -}; - -/// This is nn::settings::system::CmuMode -enum class CmuMode : u32 { - None, - ColorInvert, - HighContrast, - GrayScale, -}; - -/// This is nn::settings::system::TvSettings -struct TvSettings { - TvFlag flags; - TvResolution tv_resolution; - HdmiContentType hdmi_content_type; - RgbRange rgb_range; - CmuMode cmu_mode; - u32 tv_underscan; - f32 tv_gama; - f32 contrast_ratio; -}; -static_assert(sizeof(TvSettings) == 0x20, "TvSettings is an invalid size"); - -/// This is nn::settings::system::PrimaryAlbumStorage -enum class PrimaryAlbumStorage : u32 { - Nand, - SdCard, -}; - -/// This is nn::settings::system::HandheldSleepPlan -enum class HandheldSleepPlan : u32 { - Sleep1Min, - Sleep3Min, - Sleep5Min, - Sleep10Min, - Sleep30Min, - Never, -}; - -/// This is nn::settings::system::ConsoleSleepPlan -enum class ConsoleSleepPlan : u32 { - Sleep1Hour, - Sleep2Hour, - Sleep3Hour, - Sleep6Hour, - Sleep12Hour, - Never, -}; - -/// This is nn::settings::system::SleepFlag -struct SleepFlag { - union { - u32 raw{}; - - BitField<0, 1, u32> SleepsWhilePlayingMedia; - BitField<1, 1, u32> WakesAtPowerStateChange; - }; -}; -static_assert(sizeof(SleepFlag) == 4, "TvFlag is an invalid size"); - -/// This is nn::settings::system::SleepSettings -struct SleepSettings { - SleepFlag flags; - HandheldSleepPlan handheld_sleep_plan; - ConsoleSleepPlan console_sleep_plan; -}; -static_assert(sizeof(SleepSettings) == 0xc, "SleepSettings is incorrect size"); - -/// This is nn::settings::system::EulaVersionClockType -enum class EulaVersionClockType : u32 { - NetworkSystemClock, - SteadyClock, -}; - -/// This is nn::settings::system::EulaVersion -struct EulaVersion { - u32 version; - RegionCode region_code; - EulaVersionClockType clock_type; - INSERT_PADDING_BYTES(0x4); - s64 posix_time; - Time::Clock::SteadyClockTimePoint timestamp; -}; -static_assert(sizeof(EulaVersion) == 0x30, "EulaVersion is incorrect size"); - struct SystemSettings { // 0/unwritten (1.0.0), 0x20000 (2.0.0), 0x30000 (3.0.0-3.0.1), 0x40001 (4.0.0-4.1.0), 0x50000 // (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 { // 0/unwritten (1.0.0), 1 (6.0.0-8.1.0), 2 (8.1.1), 7 (9.0.0+). // if (flags & 2), defaults are written for AnalogStickUserCalibration u32 flags; + INSERT_PADDING_BYTES(0x8); // Reserved - std::array reserved_00008; - - // nn::settings::LanguageCode LanguageCode language_code; - - std::array reserved_00018; + INSERT_PADDING_BYTES(0x38); // Reserved // nn::settings::system::NetworkSettings u32 network_setting_count; bool wireless_lan_enable_flag; - std::array pad_00055; - - std::array reserved_00058; + INSERT_PADDING_BYTES(0x3); + INSERT_PADDING_BYTES(0x8); // Reserved // nn::settings::system::NetworkSettings std::array, 32> network_settings_1B0; @@ -304,161 +42,142 @@ struct SystemSettings { // nn::settings::system::BluetoothDevicesSettings std::array bluetooth_device_settings_count; bool bluetooth_enable_flag; - std::array pad_08065; + INSERT_PADDING_BYTES(0x3); bool bluetooth_afh_enable_flag; - std::array pad_08069; + INSERT_PADDING_BYTES(0x3); bool bluetooth_boost_enable_flag; - std::array pad_0806D; + INSERT_PADDING_BYTES(0x3); std::array, 10> bluetooth_device_settings_first_10; s32 ldn_channel; - - std::array reserved_09474; + INSERT_PADDING_BYTES(0x3C); // Reserved // nn::util::Uuid MiiAuthorId - std::array mii_author_id; + Common::UUID mii_author_id; - std::array reserved_094C0; + INSERT_PADDING_BYTES(0x30); // Reserved // nn::settings::system::NxControllerSettings u32 nx_controller_settings_count; - std::array reserved_094F4; + INSERT_PADDING_BYTES(0xC); // Reserved // nn::settings::system::NxControllerSettings, // nn::settings::system::NxControllerLegacySettings on 13.0.0+ std::array, 10> nx_controller_legacy_settings; - - std::array reserved_09780; + INSERT_PADDING_BYTES(0x170); // Reserved bool external_rtc_reset_flag; - std::array pad_098F1; - - std::array reserved_098F4; + INSERT_PADDING_BYTES(0x3); + INSERT_PADDING_BYTES(0x3C); // Reserved s32 push_notification_activity_mode_on_sleep; + INSERT_PADDING_BYTES(0x3C); // Reserved - std::array reserved_09934; - - // nn::settings::system::ErrorReportSharePermission ErrorReportSharePermission error_report_share_permission; + INSERT_PADDING_BYTES(0x3C); // Reserved - std::array reserved_09974; - - // nn::settings::KeyboardLayout - std::array keyboard_layout; - - std::array reserved_099B4; + KeyboardLayout keyboard_layout; + INSERT_PADDING_BYTES(0x3C); // Reserved bool web_inspector_flag; - std::array pad_099F1; + INSERT_PADDING_BYTES(0x3); // nn::settings::system::AllowedSslHost u32 allowed_ssl_host_count; bool memory_usage_rate_flag; - std::array pad_099F9; - - std::array reserved_099FC; + INSERT_PADDING_BYTES(0x3); + INSERT_PADDING_BYTES(0x34); // Reserved // nn::settings::system::HostFsMountPoint std::array host_fs_mount_point; // nn::settings::system::AllowedSslHost std::array, 8> allowed_ssl_hosts; - - std::array reserved_0A330; + INSERT_PADDING_BYTES(0x6C0); // Reserved // nn::settings::system::BlePairingSettings u32 ble_pairing_settings_count; - std::array reserved_0A9F4; + INSERT_PADDING_BYTES(0xC); // Reserved std::array, 10> ble_pairing_settings; // nn::settings::system::AccountOnlineStorageSettings u32 account_online_storage_settings_count; - std::array reserved_0AF04; + INSERT_PADDING_BYTES(0xC); // Reserved std::array, 8> account_online_storage_settings; bool pctl_ready_flag; - std::array pad_0B111; - - std::array reserved_0B114; + INSERT_PADDING_BYTES(0x3); + INSERT_PADDING_BYTES(0x3C); // Reserved // nn::settings::system::ThemeId std::array theme_id_type0; std::array theme_id_type1; + INSERT_PADDING_BYTES(0x100); // Reserved - std::array reserved_0B250; - - // nn::settings::ChineseTraditionalInputMethod ChineseTraditionalInputMethod chinese_traditional_input_method; - - std::array reserved_0B354; + INSERT_PADDING_BYTES(0x3C); // Reserved bool zoom_flag; - std::array pad_0B391; - - std::array reserved_0B394; + INSERT_PADDING_BYTES(0x3); + INSERT_PADDING_BYTES(0x3C); // Reserved // nn::settings::system::ButtonConfigRegisteredSettings u32 button_config_registered_settings_count; - std::array reserved_0B3D4; + INSERT_PADDING_BYTES(0xC); // Reserved // nn::settings::system::ButtonConfigSettings u32 button_config_settings_count; - std::array reserved_0B3E4; + INSERT_PADDING_BYTES(0x4); // Reserved std::array, 5> button_config_settings; - std::array reserved_0D030; + INSERT_PADDING_BYTES(0x13B0); // Reserved u32 button_config_settings_embedded_count; - std::array reserved_0E3E4; + INSERT_PADDING_BYTES(0x4); // Reserved std::array, 5> button_config_settings_embedded; - std::array reserved_10030; + INSERT_PADDING_BYTES(0x13B0); // Reserved u32 button_config_settings_left_count; - std::array reserved_113E4; + INSERT_PADDING_BYTES(0x4); // Reserved std::array, 5> button_config_settings_left; - std::array reserved_13030; + INSERT_PADDING_BYTES(0x13B0); // Reserved u32 button_config_settings_right_count; - std::array reserved_143E4; + INSERT_PADDING_BYTES(0x4); // Reserved std::array, 5> button_config_settings_right; - std::array reserved_16030; + INSERT_PADDING_BYTES(0x73B0); // Reserved // nn::settings::system::ButtonConfigRegisteredSettings std::array button_config_registered_settings_embedded; std::array, 10> button_config_registered_settings; - - std::array reserved_21378; + INSERT_PADDING_BYTES(0x7FF8); // Reserved // nn::settings::system::ConsoleSixAxisSensorAccelerationBias - std::array console_six_axis_sensor_acceleration_bias; + Common::Vec3 console_six_axis_sensor_acceleration_bias; // nn::settings::system::ConsoleSixAxisSensorAngularVelocityBias - std::array console_six_axis_sensor_angular_velocity_bias; + Common::Vec3 console_six_axis_sensor_angular_velocity_bias; // nn::settings::system::ConsoleSixAxisSensorAccelerationGain std::array console_six_axis_sensor_acceleration_gain; // nn::settings::system::ConsoleSixAxisSensorAngularVelocityGain std::array console_six_axis_sensor_angular_velocity_gain; // nn::settings::system::ConsoleSixAxisSensorAngularVelocityTimeBias - std::array console_six_axis_sensor_angular_velocity_time_bias; + Common::Vec3 console_six_axis_sensor_angular_velocity_time_bias; // nn::settings::system::ConsoleSixAxisSensorAngularAcceleration std::array console_six_axis_sensor_angular_velocity_acceleration; - - std::array reserved_29400; + INSERT_PADDING_BYTES(0x70); // Reserved bool lock_screen_flag; - std::array pad_29471; - - std::array reserved_249274; + INSERT_PADDING_BYTES(0x3); + INSERT_PADDING_BYTES(0x4); // Reserved ColorSet color_set_id; QuestFlag quest_flag; - // nn::settings::system::RegionCode - RegionCode region_code; + SystemRegionCode region_code; // Different to nn::settings::system::InitialLaunchSettings? InitialLaunchSettingsPacked initial_launch_settings_packed; bool battery_percentage_flag; - std::array pad_294A1; + INSERT_PADDING_BYTES(0x3); // BitFlagSet<32, nn::settings::system::AppletLaunchFlag> u32 applet_launch_flag; @@ -469,33 +188,26 @@ struct SystemSettings { std::array theme_key; bool field_testing_flag; - std::array pad_294C1; + INSERT_PADDING_BYTES(0x3); s32 panel_crc_mode; - - std::array reserved_294C8; + INSERT_PADDING_BYTES(0x28); // Reserved // nn::settings::system::BacklightSettings std::array backlight_settings_mixed_up; + INSERT_PADDING_BYTES(0x64); // Reserved - std::array reserved_2951C; - - // nn::time::SystemClockContext Service::Time::Clock::SystemClockContext user_system_clock_context; Service::Time::Clock::SystemClockContext network_system_clock_context; bool user_system_clock_automatic_correction_enabled; - std::array pad_295C1; - std::array reserved_295C4; - // nn::time::SteadyClockTimePoint + INSERT_PADDING_BYTES(0x3); + INSERT_PADDING_BYTES(0x4); // Reserved Service::Time::Clock::SteadyClockTimePoint user_system_clock_automatic_correction_updated_time_point; + INSERT_PADDING_BYTES(0x10); // Reserved - std::array reserved_295E0; - - // nn::settings::system::AccountSettings AccountSettings account_settings; - - std::array reserved_295F4; + INSERT_PADDING_BYTES(0xFC); // Reserved // nn::settings::system::AudioVolume std::array audio_volume_type0; @@ -505,47 +217,42 @@ struct SystemSettings { s32 audio_output_mode_type1; s32 audio_output_mode_type2; bool force_mute_on_headphone_removed; - std::array pad_2970D; + INSERT_PADDING_BYTES(0x3); s32 headphone_volume_warning_count; bool heaphone_volume_update_flag; - std::array pad_29715; + INSERT_PADDING_BYTES(0x3); // nn::settings::system::AudioVolume std::array audio_volume_type2; // nn::settings::system::AudioOutputMode s32 audio_output_mode_type3; s32 audio_output_mode_type4; bool hearing_protection_safeguard_flag; - std::array pad_29729; - std::array reserved_2972C; + INSERT_PADDING_BYTES(0x3); + INSERT_PADDING_BYTES(0x4); // Reserved s64 hearing_protection_safeguard_remaining_time; - std::array reserved_29738; + INSERT_PADDING_BYTES(0x38); // Reserved bool console_information_upload_flag; - std::array pad_29771; - - std::array reserved_29774; + INSERT_PADDING_BYTES(0x3); + INSERT_PADDING_BYTES(0x3C); // Reserved bool automatic_application_download_flag; - std::array pad_297B1; + INSERT_PADDING_BYTES(0x3); + INSERT_PADDING_BYTES(0x4); // Reserved - std::array reserved_297B4; - - // nn::settings::system::NotificationSettings NotificationSettings notification_settings; - - std::array reserved_297D0; + INSERT_PADDING_BYTES(0x60); // Reserved // nn::settings::system::AccountNotificationSettings u32 account_notification_settings_count; - std::array reserved_29834; + INSERT_PADDING_BYTES(0xC); // Reserved std::array account_notification_settings; - - std::array reserved_29900; + INSERT_PADDING_BYTES(0x140); // Reserved f32 vibration_master_volume; bool usb_full_key_enable_flag; - std::array pad_29A45; + INSERT_PADDING_BYTES(0x3); // nn::settings::system::AnalogStickUserCalibration std::array analog_stick_user_calibration_left; @@ -553,85 +260,68 @@ struct SystemSettings { // nn::settings::system::TouchScreenMode s32 touch_screen_mode; + INSERT_PADDING_BYTES(0x14); // Reserved - std::array reserved_29A6C; - - // nn::settings::system::TvSettings TvSettings tv_settings; // nn::settings::system::Edid std::array edid; - - std::array reserved_29BA0; + INSERT_PADDING_BYTES(0x2E0); // Reserved // nn::settings::system::DataDeletionSettings std::array data_deletion_settings; - - std::array reserved_29E88; + INSERT_PADDING_BYTES(0x38); // Reserved // nn::ncm::ProgramId std::array initial_system_applet_program_id; std::array overlay_disp_program_id; - - std::array reserved_29ED0; + INSERT_PADDING_BYTES(0x4); // Reserved bool requires_run_repair_time_reviser; + INSERT_PADDING_BYTES(0x6B); // Reserved - std::array reserved_29ED5; - - // nn::time::LocationName Service::Time::TimeZone::LocationName device_time_zone_location_name; - std::array reserved_29F64; - // nn::time::SteadyClockTimePoint + INSERT_PADDING_BYTES(0x4); // Reserved Service::Time::Clock::SteadyClockTimePoint device_time_zone_location_updated_time; - - std::array reserved_29F80; + INSERT_PADDING_BYTES(0xC0); // Reserved // nn::settings::system::PrimaryAlbumStorage PrimaryAlbumStorage primary_album_storage; - - std::array reserved_2A044; + INSERT_PADDING_BYTES(0x3C); // Reserved bool usb_30_enable_flag; - std::array pad_2A081; + INSERT_PADDING_BYTES(0x3); bool usb_30_host_enable_flag; - std::array pad_2A085; + INSERT_PADDING_BYTES(0x3); bool usb_30_device_enable_flag; - std::array pad_2A089; - - std::array reserved_2A08C; + INSERT_PADDING_BYTES(0x3); + INSERT_PADDING_BYTES(0x34); // Reserved bool nfc_enable_flag; - std::array pad_2A0C1; - - std::array reserved_2A0C4; + INSERT_PADDING_BYTES(0x3); + INSERT_PADDING_BYTES(0x3C); // Reserved // nn::settings::system::SleepSettings SleepSettings sleep_settings; - - std::array reserved_2A10C; + INSERT_PADDING_BYTES(0x34); // Reserved // nn::settings::system::EulaVersion u32 eula_version_count; - std::array reserved_2A144; + INSERT_PADDING_BYTES(0xC); // Reserved std::array eula_versions; - - std::array reserved_2A750; + INSERT_PADDING_BYTES(0x200); // Reserved // nn::settings::system::DeviceNickName std::array device_nick_name; - - std::array reserved_2A9D0; + INSERT_PADDING_BYTES(0x80); // Reserved bool auto_update_enable_flag; - std::array pad_2AA51; - - std::array reserved_2AA54; + INSERT_PADDING_BYTES(0x3); + INSERT_PADDING_BYTES(0x4C); // Reserved // nn::settings::system::BluetoothDevicesSettings std::array, 14> bluetooth_device_settings_last_14; - - std::array reserved_2C6A0; + INSERT_PADDING_BYTES(0x2000); // Reserved // nn::settings::system::NxControllerSettings std::array, 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 @@ #pragma once #include "core/hle/service/service.h" -#include "core/hle/service/set/system_settings.h" +#include "core/hle/service/set/settings_types.h" namespace Core { class System; } namespace Service::Set { -enum class KeyboardLayout : u64 { - Japanese = 0, - EnglishUs = 1, - EnglishUsInternational = 2, - EnglishUk = 3, - French = 4, - FrenchCa = 5, - Spanish = 6, - SpanishLatin = 7, - German = 8, - Italian = 9, - Portuguese = 10, - Russian = 11, - Korean = 12, - ChineseSimplified = 13, - ChineseTraditional = 14, -}; - -constexpr std::array available_language_codes = {{ - LanguageCode::JA, - LanguageCode::EN_US, - LanguageCode::FR, - LanguageCode::DE, - LanguageCode::IT, - LanguageCode::ES, - LanguageCode::ZH_CN, - LanguageCode::KO, - LanguageCode::NL, - LanguageCode::PT, - LanguageCode::RU, - LanguageCode::ZH_TW, - LanguageCode::EN_GB, - LanguageCode::FR_CA, - LanguageCode::ES_419, - LanguageCode::ZH_HANS, - LanguageCode::ZH_HANT, - LanguageCode::PT_BR, -}}; - -static constexpr std::array, 18> language_to_layout{{ - {LanguageCode::JA, KeyboardLayout::Japanese}, - {LanguageCode::EN_US, KeyboardLayout::EnglishUs}, - {LanguageCode::FR, KeyboardLayout::French}, - {LanguageCode::DE, KeyboardLayout::German}, - {LanguageCode::IT, KeyboardLayout::Italian}, - {LanguageCode::ES, KeyboardLayout::Spanish}, - {LanguageCode::ZH_CN, KeyboardLayout::ChineseSimplified}, - {LanguageCode::KO, KeyboardLayout::Korean}, - {LanguageCode::NL, KeyboardLayout::EnglishUsInternational}, - {LanguageCode::PT, KeyboardLayout::Portuguese}, - {LanguageCode::RU, KeyboardLayout::Russian}, - {LanguageCode::ZH_TW, KeyboardLayout::ChineseTraditional}, - {LanguageCode::EN_GB, KeyboardLayout::EnglishUk}, - {LanguageCode::FR_CA, KeyboardLayout::FrenchCa}, - {LanguageCode::ES_419, KeyboardLayout::SpanishLatin}, - {LanguageCode::ZH_HANS, KeyboardLayout::ChineseSimplified}, - {LanguageCode::ZH_HANT, KeyboardLayout::ChineseTraditional}, - {LanguageCode::PT_BR, KeyboardLayout::Portuguese}, -}}; LanguageCode GetLanguageCodeFromIndex(std::size_t idx); 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..ae2a884bc --- /dev/null +++ b/src/core/hle/service/set/settings_types.h @@ -0,0 +1,451 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#pragma once + +#include + +#include "common/bit_field.h" +#include "common/common_funcs.h" +#include "common/common_types.h" +#include "common/uuid.h" +#include "core/hle/service/time/clock_types.h" + +namespace Service::Set { + +/// This is nn::settings::system::AudioOutputMode +enum class AudioOutputMode : u32 { + ch_1, + ch_2, + ch_5_1, + ch_7_1, +}; + +/// This is nn::settings::system::AudioOutputModeTarget +enum class AudioOutputModeTarget : u32 { + Hdmi, + Speaker, + Headphone, +}; + +/// This is nn::settings::system::AudioVolumeTarget +enum class AudioVolumeTarget : u32 { + Speaker, + Headphone, +}; + +/// This is nn::settings::system::ClockSourceId +enum class ClockSourceId : u32 { + NetworkSystemClock, + SteadyClock, +}; + +/// This is nn::settings::system::CmuMode +enum class CmuMode : u32 { + None, + ColorInvert, + HighContrast, + GrayScale, +}; + +/// This is nn::settings::system::ChineseTraditionalInputMethod +enum class ChineseTraditionalInputMethod : u32 { + Unknown0 = 0, + Unknown1 = 1, + Unknown2 = 2, +}; + +/// Indicates the current theme set by the system settings +enum class ColorSet : u32 { + BasicWhite = 0, + BasicBlack = 1, +}; + +/// This is nn::settings::system::ConsoleSleepPlan +enum class ConsoleSleepPlan : u32 { + Sleep1Hour, + Sleep2Hour, + Sleep3Hour, + Sleep6Hour, + Sleep12Hour, + Never, +}; + +/// This is nn::settings::system::ErrorReportSharePermission +enum class ErrorReportSharePermission : u32 { + NotConfirmed, + Granted, + Denied, +}; + +/// This is nn::settings::system::EulaVersionClockType +enum class EulaVersionClockType : u32 { + NetworkSystemClock, + SteadyClock, +}; + +/// This is nn::settings::factory::RegionCode +enum class FactoryRegionCode : u32 { + Japan, + Usa, + Europe, + Australia, + China, + Korea, + Taiwan, +}; + +/// This is nn::settings::system::FriendPresenceOverlayPermission +enum class FriendPresenceOverlayPermission : u8 { + NotConfirmed, + NoDisplay, + FavoriteFriends, + Friends, +}; + +enum class GetFirmwareVersionType { + Version1, + Version2, +}; + +/// This is nn::settings::system::HandheldSleepPlan +enum class HandheldSleepPlan : u32 { + Sleep1Min, + Sleep3Min, + Sleep5Min, + Sleep10Min, + Sleep30Min, + Never, +}; + +/// This is nn::settings::system::HdmiContentType +enum class HdmiContentType : u32 { + None, + Graphics, + Cinema, + Photo, + Game, +}; + +enum class KeyboardLayout : u32 { + Japanese = 0, + EnglishUs = 1, + EnglishUsInternational = 2, + EnglishUk = 3, + French = 4, + FrenchCa = 5, + Spanish = 6, + SpanishLatin = 7, + German = 8, + Italian = 9, + Portuguese = 10, + Russian = 11, + Korean = 12, + ChineseSimplified = 13, + ChineseTraditional = 14, +}; + +/// This is "nn::settings::LanguageCode", which is a NUL-terminated string stored in a u64. +enum class LanguageCode : u64 { + JA = 0x000000000000616A, + EN_US = 0x00000053552D6E65, + FR = 0x0000000000007266, + DE = 0x0000000000006564, + IT = 0x0000000000007469, + ES = 0x0000000000007365, + ZH_CN = 0x0000004E432D687A, + KO = 0x0000000000006F6B, + NL = 0x0000000000006C6E, + PT = 0x0000000000007470, + RU = 0x0000000000007572, + ZH_TW = 0x00000057542D687A, + EN_GB = 0x00000042472D6E65, + FR_CA = 0x00000041432D7266, + ES_419 = 0x00003931342D7365, + ZH_HANS = 0x00736E61482D687A, + ZH_HANT = 0x00746E61482D687A, + PT_BR = 0x00000052422D7470, +}; + +/// This is nn::settings::system::NotificationVolume +enum class NotificationVolume : u32 { + Mute, + Low, + High, +}; + +/// This is nn::settings::system::PrimaryAlbumStorage +enum class PrimaryAlbumStorage : u32 { + Nand, + SdCard, +}; + +/// Indicates the current console is a retail or kiosk unit +enum class QuestFlag : u8 { + Retail = 0, + Kiosk = 1, +}; + +/// This is nn::settings::system::RgbRange +enum class RgbRange : u32 { + Auto, + Full, + Limited, +}; + +/// This is nn::settings::system::RegionCode +enum class SystemRegionCode : u32 { + Japan, + Usa, + Europe, + Australia, + HongKongTaiwanKorea, + China, +}; + +/// This is nn::settings::system::TouchScreenMode +enum class TouchScreenMode : u32 { + Stylus, + Standard, +}; + +/// This is nn::settings::system::TvResolution +enum class TvResolution : u32 { + Auto, + Resolution1080p, + Resolution720p, + Resolution480p, +}; + +constexpr std::array available_language_codes = {{ + LanguageCode::JA, + LanguageCode::EN_US, + LanguageCode::FR, + LanguageCode::DE, + LanguageCode::IT, + LanguageCode::ES, + LanguageCode::ZH_CN, + LanguageCode::KO, + LanguageCode::NL, + LanguageCode::PT, + LanguageCode::RU, + LanguageCode::ZH_TW, + LanguageCode::EN_GB, + LanguageCode::FR_CA, + LanguageCode::ES_419, + LanguageCode::ZH_HANS, + LanguageCode::ZH_HANT, + LanguageCode::PT_BR, +}}; + +static constexpr std::array, 18> language_to_layout{{ + {LanguageCode::JA, KeyboardLayout::Japanese}, + {LanguageCode::EN_US, KeyboardLayout::EnglishUs}, + {LanguageCode::FR, KeyboardLayout::French}, + {LanguageCode::DE, KeyboardLayout::German}, + {LanguageCode::IT, KeyboardLayout::Italian}, + {LanguageCode::ES, KeyboardLayout::Spanish}, + {LanguageCode::ZH_CN, KeyboardLayout::ChineseSimplified}, + {LanguageCode::KO, KeyboardLayout::Korean}, + {LanguageCode::NL, KeyboardLayout::EnglishUsInternational}, + {LanguageCode::PT, KeyboardLayout::Portuguese}, + {LanguageCode::RU, KeyboardLayout::Russian}, + {LanguageCode::ZH_TW, KeyboardLayout::ChineseTraditional}, + {LanguageCode::EN_GB, KeyboardLayout::EnglishUk}, + {LanguageCode::FR_CA, KeyboardLayout::FrenchCa}, + {LanguageCode::ES_419, KeyboardLayout::SpanishLatin}, + {LanguageCode::ZH_HANS, KeyboardLayout::ChineseSimplified}, + {LanguageCode::ZH_HANT, KeyboardLayout::ChineseTraditional}, + {LanguageCode::PT_BR, KeyboardLayout::Portuguese}, +}}; + +/// This is nn::settings::system::AccountNotificationFlag +struct AccountNotificationFlag { + union { + u32 raw{}; + + BitField<0, 1, u32> FriendOnlineFlag; + BitField<1, 1, u32> FriendRequestFlag; + BitField<8, 1, u32> CoralInvitationFlag; + }; +}; +static_assert(sizeof(AccountNotificationFlag) == 4, "AccountNotificationFlag is an invalid size"); + +/// This is nn::settings::system::AccountSettings +struct AccountSettings { + u32 flags; +}; +static_assert(sizeof(AccountSettings) == 4, "AccountSettings is an invalid size"); + +/// This is nn::settings::system::DataDeletionFlag +struct DataDeletionFlag { + union { + u32 raw{}; + + BitField<0, 1, u32> AutomaticDeletionFlag; + }; +}; +static_assert(sizeof(DataDeletionFlag) == 4, "DataDeletionFlag is an invalid size"); + +/// This is nn::settings::system::InitialLaunchFlag +struct InitialLaunchFlag { + union { + u32 raw{}; + + BitField<0, 1, u32> InitialLaunchCompletionFlag; + BitField<8, 1, u32> InitialLaunchUserAdditionFlag; + BitField<16, 1, u32> InitialLaunchTimestampFlag; + }; +}; +static_assert(sizeof(InitialLaunchFlag) == 4, "InitialLaunchFlag is an invalid size"); + +/// This is nn::settings::system::SleepFlag +struct SleepFlag { + union { + u32 raw{}; + + BitField<0, 1, u32> SleepsWhilePlayingMedia; + BitField<1, 1, u32> WakesAtPowerStateChange; + }; +}; +static_assert(sizeof(SleepFlag) == 4, "TvFlag is an invalid size"); + +/// This is nn::settings::system::NotificationFlag +struct NotificationFlag { + union { + u32 raw{}; + + BitField<0, 1, u32> RingtoneFlag; + BitField<1, 1, u32> DownloadCompletionFlag; + BitField<8, 1, u32> EnablesNews; + BitField<9, 1, u32> IncomingLampFlag; + }; +}; +static_assert(sizeof(NotificationFlag) == 4, "NotificationFlag is an invalid size"); + +/// This is nn::settings::system::TvFlag +struct TvFlag { + union { + u32 raw{}; + + BitField<0, 1, u32> Allows4k; + BitField<1, 1, u32> Allows3d; + BitField<2, 1, u32> AllowsCec; + BitField<3, 1, u32> PreventsScreenBurnIn; + }; +}; +static_assert(sizeof(TvFlag) == 4, "TvFlag is an invalid size"); + +/// This is nn::settings::system::UserSelectorFlag +struct UserSelectorFlag { + union { + u32 raw{}; + + BitField<0, 1, u32> SkipIfSingleUser; + BitField<31, 1, u32> Uknown; + }; +}; +static_assert(sizeof(UserSelectorFlag) == 4, "UserSelectorFlag is an invalid size"); + +/// This is nn::settings::system::AccountNotificationSettings +struct AccountNotificationSettings { + Common::UUID uid; + AccountNotificationFlag flags; + FriendPresenceOverlayPermission friend_presence_permission; + FriendPresenceOverlayPermission friend_invitation_permission; + INSERT_PADDING_BYTES(0x2); +}; +static_assert(sizeof(AccountNotificationSettings) == 0x18, + "AccountNotificationSettings is an invalid size"); + +/// This is nn::settings::system::EulaVersion +struct EulaVersion { + u32 version; + SystemRegionCode region_code; + EulaVersionClockType clock_type; + INSERT_PADDING_BYTES(0x4); + s64 posix_time; + Time::Clock::SteadyClockTimePoint timestamp; +}; +static_assert(sizeof(EulaVersion) == 0x30, "EulaVersion is incorrect size"); + +struct FirmwareVersionFormat { + u8 major; + u8 minor; + u8 micro; + INSERT_PADDING_BYTES(1); + u8 revision_major; + u8 revision_minor; + INSERT_PADDING_BYTES(2); + std::array platform; + std::array version_hash; + std::array display_version; + std::array display_title; +}; +static_assert(sizeof(FirmwareVersionFormat) == 0x100, "FirmwareVersionFormat is an invalid size"); + +/// This is nn::settings::system::HomeMenuScheme +struct HomeMenuScheme { + u32 main; + u32 back; + u32 sub; + u32 bezel; + u32 extra; +}; +static_assert(sizeof(HomeMenuScheme) == 0x14, "HomeMenuScheme is incorrect size"); + +/// This is nn::settings::system::InitialLaunchSettings +struct InitialLaunchSettings { + InitialLaunchFlag flags; + INSERT_PADDING_BYTES(0x4); + Service::Time::Clock::SteadyClockTimePoint timestamp; +}; +static_assert(sizeof(InitialLaunchSettings) == 0x20, "InitialLaunchSettings is incorrect size"); + +#pragma pack(push, 4) +struct InitialLaunchSettingsPacked { + InitialLaunchFlag flags; + Service::Time::Clock::SteadyClockTimePoint timestamp; +}; +#pragma pack(pop) +static_assert(sizeof(InitialLaunchSettingsPacked) == 0x1C, + "InitialLaunchSettingsPacked is incorrect size"); + +/// This is nn::settings::system::NotificationTime +struct NotificationTime { + u32 hour; + u32 minute; +}; +static_assert(sizeof(NotificationTime) == 0x8, "NotificationTime is an invalid size"); + +/// This is nn::settings::system::NotificationSettings +struct NotificationSettings { + NotificationFlag flags; + NotificationVolume volume; + NotificationTime start_time; + NotificationTime stop_time; +}; +static_assert(sizeof(NotificationSettings) == 0x18, "NotificationSettings is an invalid size"); + +/// This is nn::settings::system::SleepSettings +struct SleepSettings { + SleepFlag flags; + HandheldSleepPlan handheld_sleep_plan; + ConsoleSleepPlan console_sleep_plan; +}; +static_assert(sizeof(SleepSettings) == 0xc, "SleepSettings is incorrect size"); + +/// This is nn::settings::system::TvSettings +struct TvSettings { + TvFlag flags; + TvResolution tv_resolution; + HdmiContentType hdmi_content_type; + RgbRange rgb_range; + CmuMode cmu_mode; + u32 tv_underscan; + f32 tv_gama; + f32 contrast_ratio; +}; +static_assert(sizeof(TvSettings) == 0x20, "TvSettings is an invalid size"); + +} // 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..122b915c5 100644 --- a/src/core/hle/service/set/system_settings_server.cpp +++ b/src/core/hle/service/set/system_settings_server.cpp @@ -775,7 +775,7 @@ void ISystemSettingsServer::SetDeviceTimeZoneLocationName(HLERequestContext& ctx void ISystemSettingsServer::SetRegionCode(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; - m_system_settings.region_code = rp.PopEnum(); + m_system_settings.region_code = rp.PopEnum(); SetSaveNeeded(); LOG_INFO(Service_SET, "called, region_code={}", m_system_settings.region_code); diff --git a/src/core/hle/service/set/system_settings_server.h b/src/core/hle/service/set/system_settings_server.h index 6f587e0b3..bab913615 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 @@ #include "common/uuid.h" #include "core/hle/result.h" #include "core/hle/service/service.h" -#include "core/hle/service/set/appln_settings.h" -#include "core/hle/service/set/device_settings.h" -#include "core/hle/service/set/private_settings.h" -#include "core/hle/service/set/system_settings.h" +#include "core/hle/service/set/setting_formats/appln_settings.h" +#include "core/hle/service/set/setting_formats/device_settings.h" +#include "core/hle/service/set/setting_formats/private_settings.h" +#include "core/hle/service/set/setting_formats/system_settings.h" +#include "core/hle/service/set/settings_types.h" #include "core/hle/service/time/clock_types.h" #include "core/hle/service/time/time_zone_types.h" @@ -24,25 +25,6 @@ class System; } namespace Service::Set { -enum class GetFirmwareVersionType { - Version1, - Version2, -}; - -struct FirmwareVersionFormat { - u8 major; - u8 minor; - u8 micro; - INSERT_PADDING_BYTES(1); - u8 revision_major; - u8 revision_minor; - INSERT_PADDING_BYTES(2); - std::array platform; - std::array version_hash; - std::array display_version; - std::array display_title; -}; -static_assert(sizeof(FirmwareVersionFormat) == 0x100, "FirmwareVersionFormat is an invalid size"); Result GetFirmwareVersionImpl(FirmwareVersionFormat& out_firmware, Core::System& system, GetFirmwareVersionType type); From 7f5adf8982e12b0629b6c3a90b2b783209ef09cc Mon Sep 17 00:00:00 2001 From: Narr the Reg Date: Sun, 14 Jan 2024 21:04:02 -0600 Subject: [PATCH 2/2] service: set: Implement stubbed functions --- src/core/hle/service/hid/hid.cpp | 2 +- .../set/setting_formats/appln_settings.cpp | 6 +- .../set/setting_formats/system_settings.cpp | 6 + src/core/hle/service/set/settings_types.h | 2 +- .../service/set/system_settings_server.cpp | 213 ++++++++++++++---- .../hle/service/set/system_settings_server.h | 20 ++ .../resources/hid_firmware_settings.cpp | 35 +-- .../resources/hid_firmware_settings.h | 12 +- 8 files changed, 232 insertions(+), 64 deletions(-) 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) { auto server_manager = std::make_unique(system); std::shared_ptr resource_manager = std::make_shared(system); std::shared_ptr firmware_settings = - std::make_shared(); + std::make_shared(system); // TODO: Remove this hack when am is emulated properly. resource_manager->Initialize(); diff --git a/src/core/hle/service/set/setting_formats/appln_settings.cpp b/src/core/hle/service/set/setting_formats/appln_settings.cpp index 566ee1b13..f7c7d5b91 100644 --- a/src/core/hle/service/set/setting_formats/appln_settings.cpp +++ b/src/core/hle/service/set/setting_formats/appln_settings.cpp @@ -6,7 +6,11 @@ namespace Service::Set { ApplnSettings DefaultApplnSettings() { - return {}; + ApplnSettings settings{}; + + settings.mii_author_id = Common::UUID::MakeDefault(); + + return settings; } } // namespace Service::Set diff --git a/src/core/hle/service/set/setting_formats/system_settings.cpp b/src/core/hle/service/set/setting_formats/system_settings.cpp index 4e524c0de..66e57651e 100644 --- a/src/core/hle/service/set/setting_formats/system_settings.cpp +++ b/src/core/hle/service/set/setting_formats/system_settings.cpp @@ -11,6 +11,8 @@ SystemSettings DefaultSystemSettings() { settings.version = 0x140000; settings.flags = 7; + settings.mii_author_id = Common::UUID::MakeDefault(); + settings.color_set_id = ColorSet::BasicWhite; settings.notification_settings = { @@ -45,6 +47,10 @@ SystemSettings DefaultSystemSettings() { settings.device_time_zone_location_name = {"UTC"}; settings.user_system_clock_automatic_correction_enabled = false; + settings.primary_album_storage = PrimaryAlbumStorage::SdCard; + settings.battery_percentage_flag = true; + settings.chinese_traditional_input_method = ChineseTraditionalInputMethod::Unknown0; + return settings; } diff --git a/src/core/hle/service/set/settings_types.h b/src/core/hle/service/set/settings_types.h index ae2a884bc..4dee202d7 100644 --- a/src/core/hle/service/set/settings_types.h +++ b/src/core/hle/service/set/settings_types.h @@ -342,7 +342,7 @@ struct UserSelectorFlag { u32 raw{}; BitField<0, 1, u32> SkipIfSingleUser; - BitField<31, 1, u32> Uknown; + BitField<31, 1, u32> Unknown; }; }; static_assert(sizeof(UserSelectorFlag) == 4, "UserSelectorFlag is an invalid size"); diff --git a/src/core/hle/service/set/system_settings_server.cpp b/src/core/hle/service/set/system_settings_server.cpp index 122b915c5..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_) {3, &ISystemSettingsServer::GetFirmwareVersion, "GetFirmwareVersion"}, {4, &ISystemSettingsServer::GetFirmwareVersion2, "GetFirmwareVersion2"}, {5, nullptr, "GetFirmwareVersionDigest"}, - {7, nullptr, "GetLockScreenFlag"}, - {8, nullptr, "SetLockScreenFlag"}, + {7, &ISystemSettingsServer::GetLockScreenFlag, "GetLockScreenFlag"}, + {8, &ISystemSettingsServer::SetLockScreenFlag, "SetLockScreenFlag"}, {9, nullptr, "GetBacklightSettings"}, {10, nullptr, "SetBacklightSettings"}, {11, nullptr, "SetBluetoothDevicesSettings"}, @@ -157,12 +157,12 @@ ISystemSettingsServer::ISystemSettingsServer(Core::System& system_) {66, nullptr, "SetUsb30EnableFlag"}, {67, nullptr, "GetBatteryLot"}, {68, nullptr, "GetSerialNumber"}, - {69, nullptr, "GetNfcEnableFlag"}, - {70, nullptr, "SetNfcEnableFlag"}, + {69, &ISystemSettingsServer::GetNfcEnableFlag, "GetNfcEnableFlag"}, + {70, &ISystemSettingsServer::SetNfcEnableFlag, "SetNfcEnableFlag"}, {71, &ISystemSettingsServer::GetSleepSettings, "GetSleepSettings"}, {72, &ISystemSettingsServer::SetSleepSettings, "SetSleepSettings"}, - {73, nullptr, "GetWirelessLanEnableFlag"}, - {74, nullptr, "SetWirelessLanEnableFlag"}, + {73, &ISystemSettingsServer::GetWirelessLanEnableFlag, "GetWirelessLanEnableFlag"}, + {74, &ISystemSettingsServer::SetWirelessLanEnableFlag, "SetWirelessLanEnableFlag"}, {75, &ISystemSettingsServer::GetInitialLaunchSettings, "GetInitialLaunchSettings"}, {76, &ISystemSettingsServer::SetInitialLaunchSettings, "SetInitialLaunchSettings"}, {77, &ISystemSettingsServer::GetDeviceNickName, "GetDeviceNickName"}, @@ -176,8 +176,8 @@ ISystemSettingsServer::ISystemSettingsServer(Core::System& system_) {85, nullptr, "SetPtmBatteryLot"}, {86, nullptr, "GetPtmFuelGaugeParameter"}, {87, nullptr, "SetPtmFuelGaugeParameter"}, - {88, nullptr, "GetBluetoothEnableFlag"}, - {89, nullptr, "SetBluetoothEnableFlag"}, + {88, &ISystemSettingsServer::GetBluetoothEnableFlag, "GetBluetoothEnableFlag"}, + {89, &ISystemSettingsServer::SetBluetoothEnableFlag, "SetBluetoothEnableFlag"}, {90, &ISystemSettingsServer::GetMiiAuthorId, "GetMiiAuthorId"}, {91, nullptr, "SetShutdownRtcValue"}, {92, nullptr, "GetShutdownRtcValue"}, @@ -510,6 +510,25 @@ void ISystemSettingsServer::SetUserSystemClockContext(HLERequestContext& ctx) { rb.Push(res); } +void ISystemSettingsServer::GetLockScreenFlag(HLERequestContext& ctx) { + LOG_INFO(Service_SET, "called, lock_screen_flag={}", m_system_settings.lock_screen_flag); + + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(ResultSuccess); + rb.Push(m_system_settings.lock_screen_flag); +} + +void ISystemSettingsServer::SetLockScreenFlag(HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + m_system_settings.lock_screen_flag = rp.Pop(); + SetSaveNeeded(); + + LOG_INFO(Service_SET, "called, lock_screen_flag={}", m_system_settings.lock_screen_flag); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); +} + void ISystemSettingsServer::GetAccountSettings(HLERequestContext& ctx) { LOG_INFO(Service_SET, "called"); @@ -531,7 +550,7 @@ void ISystemSettingsServer::SetAccountSettings(HLERequestContext& ctx) { } void ISystemSettingsServer::GetEulaVersions(HLERequestContext& ctx) { - LOG_INFO(Service_SET, "called"); + LOG_INFO(Service_SET, "called, elements={}", m_system_settings.eula_version_count); ctx.WriteBuffer(m_system_settings.eula_versions); @@ -557,7 +576,7 @@ void ISystemSettingsServer::SetEulaVersions(HLERequestContext& ctx) { } void ISystemSettingsServer::GetColorSetId(HLERequestContext& ctx) { - LOG_DEBUG(Service_SET, "called"); + LOG_DEBUG(Service_SET, "called, color_set=", m_system_settings.color_set_id); IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); @@ -576,7 +595,13 @@ void ISystemSettingsServer::SetColorSetId(HLERequestContext& ctx) { } void ISystemSettingsServer::GetNotificationSettings(HLERequestContext& ctx) { - LOG_INFO(Service_SET, "called"); + LOG_INFO(Service_SET, "called, flags={}, volume={}, head_time={}:{}, tailt_time={}:{}", + m_system_settings.notification_settings.flags.raw, + m_system_settings.notification_settings.volume, + m_system_settings.notification_settings.start_time.hour, + m_system_settings.notification_settings.start_time.minute, + m_system_settings.notification_settings.stop_time.hour, + m_system_settings.notification_settings.stop_time.minute); IPC::ResponseBuilder rb{ctx, 8}; rb.Push(ResultSuccess); @@ -601,7 +626,8 @@ void ISystemSettingsServer::SetNotificationSettings(HLERequestContext& ctx) { } void ISystemSettingsServer::GetAccountNotificationSettings(HLERequestContext& ctx) { - LOG_INFO(Service_SET, "called"); + LOG_INFO(Service_SET, "called, elements={}", + m_system_settings.account_notification_settings_count); ctx.WriteBuffer(m_system_settings.account_notification_settings); @@ -645,6 +671,7 @@ using Settings = static Settings GetSettings() { Settings ret; + // AM ret["hbloader"]["applet_heap_size"] = ToBytes(u64{0x0}); ret["hbloader"]["applet_heap_reservation_size"] = ToBytes(u64{0x8600000}); @@ -656,6 +683,24 @@ static Settings GetSettings() { ret["time"]["standard_steady_clock_test_offset_minutes"] = ToBytes(s32{0}); ret["time"]["standard_user_clock_initial_year"] = ToBytes(s32{2023}); + // HID + ret["hid_debug"]["enables_debugpad"] = ToBytes(bool{true}); + ret["hid_debug"]["manages_devices"] = ToBytes(bool{true}); + ret["hid_debug"]["manages_touch_ic_i2c"] = ToBytes(bool{true}); + ret["hid_debug"]["emulate_future_device"] = ToBytes(bool{false}); + ret["hid_debug"]["emulate_mcu_hardware_error"] = ToBytes(bool{false}); + ret["hid_debug"]["enables_rail"] = ToBytes(bool{true}); + ret["hid_debug"]["emulate_firmware_update_failure"] = ToBytes(bool{false}); + ret["hid_debug"]["failure_firmware_update"] = ToBytes(s32{0}); + ret["hid_debug"]["ble_disabled"] = ToBytes(bool{false}); + ret["hid_debug"]["dscale_disabled"] = ToBytes(bool{false}); + ret["hid_debug"]["force_handheld"] = ToBytes(bool{true}); + ret["hid_debug"]["disabled_features_per_id"] = std::vector(0xa8); + ret["hid_debug"]["touch_firmware_auto_update_disabled"] = ToBytes(bool{false}); + + // Settings + ret["settings_debug"]["is_debug_mode_enabled"] = ToBytes(bool{false}); + return ret; } @@ -708,7 +753,15 @@ void ISystemSettingsServer::GetSettingsItemValue(HLERequestContext& ctx) { } void ISystemSettingsServer::GetTvSettings(HLERequestContext& ctx) { - LOG_INFO(Service_SET, "called"); + LOG_INFO(Service_SET, + "called, flags={}, cmu_mode={}, contrast_ratio={}, hdmi_content_type={}, " + "rgb_range={}, tv_gama={}, tv_resolution={}, tv_underscan={}", + m_system_settings.tv_settings.flags.raw, m_system_settings.tv_settings.cmu_mode, + m_system_settings.tv_settings.contrast_ratio, + m_system_settings.tv_settings.hdmi_content_type, + m_system_settings.tv_settings.rgb_range, m_system_settings.tv_settings.tv_gama, + m_system_settings.tv_settings.tv_resolution, + m_system_settings.tv_settings.tv_underscan); IPC::ResponseBuilder rb{ctx, 10}; rb.Push(ResultSuccess); @@ -735,23 +788,26 @@ void ISystemSettingsServer::SetTvSettings(HLERequestContext& ctx) { } void ISystemSettingsServer::GetDebugModeFlag(HLERequestContext& ctx) { - LOG_DEBUG(Service_SET, "called"); + bool is_debug_mode_enabled = false; + GetSettingsItemValue(is_debug_mode_enabled, "settings_debug", "is_debug_mode_enabled"); + + LOG_DEBUG(Service_SET, "called, is_debug_mode_enabled={}", is_debug_mode_enabled); IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); - rb.Push(0); + rb.Push(is_debug_mode_enabled); } void ISystemSettingsServer::GetQuestFlag(HLERequestContext& ctx) { - LOG_WARNING(Service_SET, "(STUBBED) called"); + LOG_INFO(Service_SET, "called, quest_flag={}", m_system_settings.quest_flag); IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); - rb.PushEnum(QuestFlag::Retail); + rb.PushEnum(m_system_settings.quest_flag); } void ISystemSettingsServer::GetDeviceTimeZoneLocationName(HLERequestContext& ctx) { - LOG_WARNING(Service_SET, "called"); + LOG_INFO(Service_SET, "called"); Service::Time::TimeZone::LocationName name{}; auto res = GetDeviceTimeZoneLocationName(name); @@ -762,7 +818,7 @@ void ISystemSettingsServer::GetDeviceTimeZoneLocationName(HLERequestContext& ctx } void ISystemSettingsServer::SetDeviceTimeZoneLocationName(HLERequestContext& ctx) { - LOG_WARNING(Service_SET, "called"); + LOG_INFO(Service_SET, "called"); IPC::RequestParser rp{ctx}; auto name{rp.PopRaw()}; @@ -832,15 +888,38 @@ void ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionEnabled(HLERequ } void ISystemSettingsServer::GetPrimaryAlbumStorage(HLERequestContext& ctx) { - LOG_WARNING(Service_SET, "(STUBBED) called"); + LOG_INFO(Service_SET, "called, primary_album_storage={}", + m_system_settings.primary_album_storage); IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); - rb.PushEnum(PrimaryAlbumStorage::SdCard); + rb.PushEnum(m_system_settings.primary_album_storage); +} + +void ISystemSettingsServer::GetNfcEnableFlag(HLERequestContext& ctx) { + LOG_INFO(Service_SET, "called, nfc_enable_flag={}", m_system_settings.nfc_enable_flag); + + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(ResultSuccess); + rb.Push(m_system_settings.nfc_enable_flag); +} + +void ISystemSettingsServer::SetNfcEnableFlag(HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + m_system_settings.nfc_enable_flag = rp.Pop(); + SetSaveNeeded(); + + LOG_INFO(Service_SET, "called, nfc_enable_flag={}", m_system_settings.nfc_enable_flag); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); } void ISystemSettingsServer::GetSleepSettings(HLERequestContext& ctx) { - LOG_INFO(Service_SET, "called"); + LOG_INFO(Service_SET, "called, flags={}, handheld_sleep_plan={}, console_sleep_plan={}", + m_system_settings.sleep_settings.flags.raw, + m_system_settings.sleep_settings.handheld_sleep_plan, + m_system_settings.sleep_settings.console_sleep_plan); IPC::ResponseBuilder rb{ctx, 5}; rb.Push(ResultSuccess); @@ -861,8 +940,32 @@ void ISystemSettingsServer::SetSleepSettings(HLERequestContext& ctx) { rb.Push(ResultSuccess); } +void ISystemSettingsServer::GetWirelessLanEnableFlag(HLERequestContext& ctx) { + LOG_INFO(Service_SET, "called, wireless_lan_enable_flag={}", + m_system_settings.wireless_lan_enable_flag); + + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(ResultSuccess); + rb.Push(m_system_settings.wireless_lan_enable_flag); +} + +void ISystemSettingsServer::SetWirelessLanEnableFlag(HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + m_system_settings.wireless_lan_enable_flag = rp.Pop(); + SetSaveNeeded(); + + LOG_INFO(Service_SET, "called, wireless_lan_enable_flag={}", + m_system_settings.wireless_lan_enable_flag); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); +} + void ISystemSettingsServer::GetInitialLaunchSettings(HLERequestContext& ctx) { - LOG_INFO(Service_SET, "called"); + LOG_INFO(Service_SET, "called, flags={}, timestamp={}", + m_system_settings.initial_launch_settings_packed.flags.raw, + m_system_settings.initial_launch_settings_packed.timestamp.time_point); + IPC::ResponseBuilder rb{ctx, 10}; rb.Push(ResultSuccess); rb.PushRaw(m_system_settings.initial_launch_settings_packed); @@ -913,35 +1016,51 @@ void ISystemSettingsServer::GetProductModel(HLERequestContext& ctx) { rb.Push(product_model); } -void ISystemSettingsServer::GetMiiAuthorId(HLERequestContext& ctx) { - const auto author_id = Common::UUID::MakeDefault(); +void ISystemSettingsServer::GetBluetoothEnableFlag(HLERequestContext& ctx) { + LOG_INFO(Service_SET, "called, bluetooth_enable_flag={}", + m_system_settings.bluetooth_enable_flag); - LOG_WARNING(Service_SET, "(STUBBED) called, author_id={}", author_id.FormattedString()); + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(ResultSuccess); + rb.Push(m_system_settings.bluetooth_enable_flag); +} + +void ISystemSettingsServer::SetBluetoothEnableFlag(HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + m_system_settings.bluetooth_enable_flag = rp.Pop(); + SetSaveNeeded(); + + LOG_INFO(Service_SET, "called, bluetooth_enable_flag={}", + m_system_settings.bluetooth_enable_flag); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); +} + +void ISystemSettingsServer::GetMiiAuthorId(HLERequestContext& ctx) { + LOG_INFO(Service_SET, "called, author_id={}", + m_system_settings.mii_author_id.FormattedString()); IPC::ResponseBuilder rb{ctx, 6}; rb.Push(ResultSuccess); - rb.PushRaw(author_id); + rb.PushRaw(m_system_settings.mii_author_id); } void ISystemSettingsServer::GetAutoUpdateEnableFlag(HLERequestContext& ctx) { - u8 auto_update_flag{}; - - LOG_WARNING(Service_SET, "(STUBBED) called, auto_update_flag={}", auto_update_flag); + LOG_INFO(Service_SET, "called, auto_update_flag={}", m_system_settings.auto_update_enable_flag); IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); - rb.Push(auto_update_flag); + rb.Push(m_system_settings.auto_update_enable_flag); } void ISystemSettingsServer::GetBatteryPercentageFlag(HLERequestContext& ctx) { - u8 battery_percentage_flag{1}; - - LOG_WARNING(Service_SET, "(STUBBED) called, battery_percentage_flag={}", - battery_percentage_flag); + LOG_DEBUG(Service_SET, "called, battery_percentage_flag={}", + m_system_settings.battery_percentage_flag); IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); - rb.Push(battery_percentage_flag); + rb.Push(m_system_settings.battery_percentage_flag); } void ISystemSettingsServer::SetExternalSteadyClockInternalOffset(HLERequestContext& ctx) { @@ -968,11 +1087,12 @@ void ISystemSettingsServer::GetExternalSteadyClockInternalOffset(HLERequestConte } void ISystemSettingsServer::GetErrorReportSharePermission(HLERequestContext& ctx) { - LOG_WARNING(Service_SET, "(STUBBED) called"); + LOG_INFO(Service_SET, "called, error_report_share_permission={}", + m_system_settings.error_report_share_permission); IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); - rb.PushEnum(ErrorReportSharePermission::Denied); + rb.PushEnum(m_system_settings.error_report_share_permission); } void ISystemSettingsServer::GetAppletLaunchFlags(HLERequestContext& ctx) { @@ -1014,7 +1134,7 @@ void ISystemSettingsServer::GetKeyboardLayout(HLERequestContext& ctx) { } void ISystemSettingsServer::GetDeviceTimeZoneLocationUpdatedTime(HLERequestContext& ctx) { - LOG_WARNING(Service_SET, "called."); + LOG_INFO(Service_SET, "called"); Service::Time::Clock::SteadyClockTimePoint time_point{}; auto res = GetDeviceTimeZoneLocationUpdatedTime(time_point); @@ -1025,7 +1145,7 @@ void ISystemSettingsServer::GetDeviceTimeZoneLocationUpdatedTime(HLERequestConte } void ISystemSettingsServer::SetDeviceTimeZoneLocationUpdatedTime(HLERequestContext& ctx) { - LOG_WARNING(Service_SET, "called."); + LOG_INFO(Service_SET, "called"); IPC::RequestParser rp{ctx}; auto time_point{rp.PopRaw()}; @@ -1038,7 +1158,7 @@ void ISystemSettingsServer::SetDeviceTimeZoneLocationUpdatedTime(HLERequestConte void ISystemSettingsServer::GetUserSystemClockAutomaticCorrectionUpdatedTime( HLERequestContext& ctx) { - LOG_WARNING(Service_SET, "called."); + LOG_INFO(Service_SET, "called"); Service::Time::Clock::SteadyClockTimePoint time_point{}; auto res = GetUserSystemClockAutomaticCorrectionUpdatedTime(time_point); @@ -1050,7 +1170,7 @@ void ISystemSettingsServer::GetUserSystemClockAutomaticCorrectionUpdatedTime( void ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionUpdatedTime( HLERequestContext& ctx) { - LOG_WARNING(Service_SET, "called."); + LOG_INFO(Service_SET, "called"); IPC::RequestParser rp{ctx}; auto time_point{rp.PopRaw()}; @@ -1062,11 +1182,12 @@ void ISystemSettingsServer::SetUserSystemClockAutomaticCorrectionUpdatedTime( } void ISystemSettingsServer::GetChineseTraditionalInputMethod(HLERequestContext& ctx) { - LOG_WARNING(Service_SET, "(STUBBED) called"); + LOG_INFO(Service_SET, "called, chinese_traditional_input_method={}", + m_system_settings.chinese_traditional_input_method); IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); - rb.PushEnum(ChineseTraditionalInputMethod::Unknown0); + rb.PushEnum(m_system_settings.chinese_traditional_input_method); } void ISystemSettingsServer::GetHomeMenuScheme(HLERequestContext& ctx) { @@ -1094,11 +1215,11 @@ void ISystemSettingsServer::GetHomeMenuSchemeModel(HLERequestContext& ctx) { } void ISystemSettingsServer::GetFieldTestingFlag(HLERequestContext& ctx) { - LOG_WARNING(Service_SET, "(STUBBED) called"); + LOG_INFO(Service_SET, "called, field_testing_flag={}", m_system_settings.field_testing_flag); IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); - rb.Push(false); + rb.Push(m_system_settings.field_testing_flag); } void 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 bab913615..32716f567 100644 --- a/src/core/hle/service/set/system_settings_server.h +++ b/src/core/hle/service/set/system_settings_server.h @@ -37,6 +37,18 @@ public: Result GetSettingsItemValue(std::vector& out_value, const std::string& category, const std::string& name); + template + Result GetSettingsItemValue(T& value, const std::string& category, const std::string& name) { + std::vector data; + const auto result = GetSettingsItemValue(data, category, name); + if (result.IsError()) { + return result; + } + ASSERT(data.size() >= sizeof(T)); + std::memcpy(&value, data.data(), sizeof(T)); + return result; + } + Result GetExternalSteadyClockSourceId(Common::UUID& out_id); Result SetExternalSteadyClockSourceId(Common::UUID id); Result GetUserSystemClockContext(Service::Time::Clock::SystemClockContext& out_context); @@ -62,6 +74,8 @@ private: void SetLanguageCode(HLERequestContext& ctx); void GetFirmwareVersion(HLERequestContext& ctx); void GetFirmwareVersion2(HLERequestContext& ctx); + void GetLockScreenFlag(HLERequestContext& ctx); + void SetLockScreenFlag(HLERequestContext& ctx); void GetExternalSteadyClockSourceId(HLERequestContext& ctx); void SetExternalSteadyClockSourceId(HLERequestContext& ctx); void GetUserSystemClockContext(HLERequestContext& ctx); @@ -90,13 +104,19 @@ private: void IsUserSystemClockAutomaticCorrectionEnabled(HLERequestContext& ctx); void SetUserSystemClockAutomaticCorrectionEnabled(HLERequestContext& ctx); void GetPrimaryAlbumStorage(HLERequestContext& ctx); + void GetNfcEnableFlag(HLERequestContext& ctx); + void SetNfcEnableFlag(HLERequestContext& ctx); void GetSleepSettings(HLERequestContext& ctx); void SetSleepSettings(HLERequestContext& ctx); + void GetWirelessLanEnableFlag(HLERequestContext& ctx); + void SetWirelessLanEnableFlag(HLERequestContext& ctx); void GetInitialLaunchSettings(HLERequestContext& ctx); void SetInitialLaunchSettings(HLERequestContext& ctx); void GetDeviceNickName(HLERequestContext& ctx); void SetDeviceNickName(HLERequestContext& ctx); void GetProductModel(HLERequestContext& ctx); + void GetBluetoothEnableFlag(HLERequestContext& ctx); + void SetBluetoothEnableFlag(HLERequestContext& ctx); void GetMiiAuthorId(HLERequestContext& ctx); void GetAutoUpdateEnableFlag(HLERequestContext& ctx); 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 @@ // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later +#include "core/hle/service/set/system_settings_server.h" +#include "core/hle/service/sm/sm.h" #include "hid_core/resources/hid_firmware_settings.h" namespace Service::HID { -HidFirmwareSettings::HidFirmwareSettings() { +HidFirmwareSettings::HidFirmwareSettings(Core::System& system) { + m_set_sys = system.ServiceManager().GetService("set:sys"); LoadSettings(true); } @@ -18,21 +21,25 @@ void HidFirmwareSettings::LoadSettings(bool reload_config) { return; } - // TODO: Use nn::settings::fwdbg::GetSettingsItemValue to load config values - - is_debug_pad_enabled = true; - is_device_managed = true; - is_touch_i2c_managed = is_device_managed; - is_future_devices_emulated = false; - is_mcu_hardware_error_emulated = false; - is_rail_enabled = true; - is_firmware_update_failure_emulated = false; + m_set_sys->GetSettingsItemValue(is_debug_pad_enabled, "hid_debug", "enables_debugpad"); + m_set_sys->GetSettingsItemValue(is_device_managed, "hid_debug", "manages_devices"); + m_set_sys->GetSettingsItemValue(is_touch_i2c_managed, "hid_debug", + "manages_touch_ic_i2c"); + m_set_sys->GetSettingsItemValue(is_future_devices_emulated, "hid_debug", + "emulate_future_device"); + m_set_sys->GetSettingsItemValue(is_mcu_hardware_error_emulated, "hid_debug", + "emulate_mcu_hardware_error"); + m_set_sys->GetSettingsItemValue(is_rail_enabled, "hid_debug", "enables_rail"); + m_set_sys->GetSettingsItemValue(is_firmware_update_failure_emulated, "hid_debug", + "emulate_firmware_update_failure"); is_firmware_update_failure = {}; - is_ble_disabled = false; - is_dscale_disabled = false; - is_handheld_forced = true; + m_set_sys->GetSettingsItemValue(is_ble_disabled, "hid_debug", "ble_disabled"); + m_set_sys->GetSettingsItemValue(is_dscale_disabled, "hid_debug", "dscale_disabled"); + m_set_sys->GetSettingsItemValue(is_handheld_forced, "hid_debug", "force_handheld"); features_per_id_disabled = {}; - is_touch_firmware_auto_update_disabled = false; + m_set_sys->GetSettingsItemValue(is_touch_firmware_auto_update_disabled, "hid_debug", + "touch_firmware_auto_update_disabled"); + is_initialized = true; } 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 @@ #include "common/common_types.h" +namespace Core { +class System; +} + +namespace Service::Set { +class ISystemSettingsServer; +} + namespace Service::HID { /// Loads firmware config from nn::settings::fwdbg @@ -13,7 +21,7 @@ public: using FirmwareSetting = std::array; using FeaturesPerId = std::array; - HidFirmwareSettings(); + HidFirmwareSettings(Core::System& system); void Reload(); void LoadSettings(bool reload_config); @@ -49,6 +57,8 @@ private: bool is_touch_firmware_auto_update_disabled{}; FirmwareSetting is_firmware_update_failure{}; FeaturesPerId features_per_id_disabled{}; + + std::shared_ptr m_set_sys; }; } // namespace Service::HID