From 4bd4a95d84baf1756f7f9b3d9601a3160fa96917 Mon Sep 17 00:00:00 2001 From: Narr the Reg Date: Wed, 2 Aug 2023 19:42:45 -0600 Subject: service: set: Implement system settings for Qlaunch --- src/core/hle/service/set/set_sys.h | 284 ++++++++++++++++++++++++++++++++++++- 1 file changed, 282 insertions(+), 2 deletions(-) (limited to 'src/core/hle/service/set/set_sys.h') diff --git a/src/core/hle/service/set/set_sys.h b/src/core/hle/service/set/set_sys.h index 1efbcc97a..16624d3fd 100644 --- a/src/core/hle/service/set/set_sys.h +++ b/src/core/hle/service/set/set_sys.h @@ -3,7 +3,9 @@ #pragma once +#include "common/uuid.h" #include "core/hle/service/service.h" +#include "core/hle/service/time/clock_types.h" namespace Core { class System; @@ -23,15 +25,293 @@ private: BasicBlack = 1, }; - void GetSettingsItemValueSize(HLERequestContext& ctx); - void GetSettingsItemValue(HLERequestContext& ctx); + /// Indicates the current console is a retail or kiosk unit + enum class QuestFlag : u8 { + Retail = 0, + Kiosk = 1, + }; + + /// 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::PrimaryAlbumStorage + enum class PrimaryAlbumStorage : u32 { + Nand, + SdCard, + }; + + /// This is nn::settings::system::NotificationVolume + enum class NotificationVolume : u32 { + Mute, + Low, + High, + }; + + /// This is nn::settings::system::ChineseTraditionalInputMethod + enum class ChineseTraditionalInputMethod : u32 { + Unknown0 = 0, + Unknown1 = 1, + Unknown2 = 2, + }; + + /// This is nn::settings::system::ErrorReportSharePermission + enum class ErrorReportSharePermission : u32 { + NotConfirmed, + Granted, + Denied, + }; + + /// This is nn::settings::system::FriendPresenceOverlayPermission + enum class FriendPresenceOverlayPermission : u8 { + NotConfirmed, + NoDisplay, + FavoriteFriends, + Friends, + }; + + /// 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::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::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::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::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::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 constrast_ratio; + }; + static_assert(sizeof(TvSettings) == 0x20, "TvSettings 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::AccountSettings + struct AccountSettings { + u32 flags; + }; + static_assert(sizeof(AccountSettings) == 0x4, "AccountSettings 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::InitialLaunchSettings + 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::InitialLaunchSettings + struct InitialLaunchSettings { + InitialLaunchFlag flags; + INSERT_PADDING_BYTES(0x4); + Time::Clock::SteadyClockTimePoint timestamp; + }; + static_assert(sizeof(InitialLaunchSettings) == 0x20, "InitialLaunchSettings is incorrect size"); + void GetFirmwareVersion(HLERequestContext& ctx); void GetFirmwareVersion2(HLERequestContext& ctx); + void GetAccountSettings(HLERequestContext& ctx); + void SetAccountSettings(HLERequestContext& ctx); void GetColorSetId(HLERequestContext& ctx); void SetColorSetId(HLERequestContext& ctx); + void GetNotificationSettings(HLERequestContext& ctx); + void SetNotificationSettings(HLERequestContext& ctx); + void GetAccountNotificationSettings(HLERequestContext& ctx); + void SetAccountNotificationSettings(HLERequestContext& ctx); + void GetSettingsItemValueSize(HLERequestContext& ctx); + void GetSettingsItemValue(HLERequestContext& ctx); + void GetTvSettings(HLERequestContext& ctx); + void SetTvSettings(HLERequestContext& ctx); + void GetQuestFlag(HLERequestContext& ctx); + void GetPrimaryAlbumStorage(HLERequestContext& ctx); + void GetSleepSettings(HLERequestContext& ctx); + void SetSleepSettings(HLERequestContext& ctx); + void GetInitialLaunchSettings(HLERequestContext& ctx); + void SetInitialLaunchSettings(HLERequestContext& ctx); void GetDeviceNickName(HLERequestContext& ctx); + void SetDeviceNickName(HLERequestContext& ctx); + void GetProductModel(HLERequestContext& ctx); + void GetMiiAuthorId(HLERequestContext& ctx); + void GetAutoUpdateEnableFlag(HLERequestContext& ctx); + void GetBatteryPercentageFlag(HLERequestContext& ctx); + void GetErrorReportSharePermission(HLERequestContext& ctx); + void GetAppletLaunchFlags(HLERequestContext& ctx); + void SetAppletLaunchFlags(HLERequestContext& ctx); + void GetKeyboardLayout(HLERequestContext& ctx); + void GetChineseTraditionalInputMethod(HLERequestContext& ctx); + + AccountSettings account_settings{ + .flags = {}, + }; ColorSet color_set = ColorSet::BasicWhite; + + NotificationSettings notification_settings{ + .flags = {0x300}, + .volume = NotificationVolume::High, + .start_time = {.hour = 9, .minute = 0}, + .stop_time = {.hour = 21, .minute = 0}, + }; + + std::vector account_notifications{}; + + TvSettings tv_settings{ + .flags = {0xc}, + .tv_resolution = TvResolution::Auto, + .hdmi_content_type = HdmiContentType::Game, + .rgb_range = RgbRange::Auto, + .cmu_mode = CmuMode::None, + .tv_underscan = {}, + .tv_gama = 1.0f, + .constrast_ratio = 0.5f, + }; + + InitialLaunchSettings launch_settings{ + .flags = {0x10001}, + .timestamp = {}, + }; + + SleepSettings sleep_settings{ + .flags = {0x3}, + .handheld_sleep_plan = HandheldSleepPlan::Sleep10Min, + .console_sleep_plan = ConsoleSleepPlan::Sleep1Hour, + }; + + u32 applet_launch_flag{}; }; } // namespace Service::Set -- cgit v1.2.3 From 7707768f80be477fce20131530731295420bb3f1 Mon Sep 17 00:00:00 2001 From: Narr the Reg Date: Fri, 4 Aug 2023 12:50:38 -0600 Subject: service: set: Add more system settings and address comments --- src/core/hle/service/set/set_sys.cpp | 69 ++++++++++++++++++++++++++++++++---- src/core/hle/service/set/set_sys.h | 38 ++++++++++++++++++++ 2 files changed, 100 insertions(+), 7 deletions(-) (limited to 'src/core/hle/service/set/set_sys.h') diff --git a/src/core/hle/service/set/set_sys.cpp b/src/core/hle/service/set/set_sys.cpp index 297e78379..165b97dad 100644 --- a/src/core/hle/service/set/set_sys.cpp +++ b/src/core/hle/service/set/set_sys.cpp @@ -75,6 +75,16 @@ void GetFirmwareVersionImpl(HLERequestContext& ctx, GetFirmwareVersionType type) } } // Anonymous namespace +void SET_SYS::SetLanguageCode(HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + language_code_setting = rp.PopEnum(); + + LOG_INFO(Service_SET, "called, language_code={}", language_code_setting); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); +} + void SET_SYS::GetFirmwareVersion(HLERequestContext& ctx) { LOG_DEBUG(Service_SET, "called"); GetFirmwareVersionImpl(ctx, GetFirmwareVersionType::Version1); @@ -103,6 +113,33 @@ void SET_SYS::SetAccountSettings(HLERequestContext& ctx) { rb.Push(ResultSuccess); } +void SET_SYS::GetEulaVersions(HLERequestContext& ctx) { + LOG_INFO(Service_SET, "called"); + + ctx.WriteBuffer(eula_versions); + + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(ResultSuccess); + rb.Push(static_cast(eula_versions.size())); +} + +void SET_SYS::SetEulaVersions(HLERequestContext& ctx) { + const auto elements = ctx.GetReadBufferNumElements(); + const auto buffer_data = ctx.ReadBuffer(); + + LOG_INFO(Service_SET, "called, elements={}", elements); + + eula_versions.resize(elements); + for (std::size_t index = 0; index < elements; index++) { + const std::size_t start_index = index * sizeof(EulaVersion); + memcpy(eula_versions.data() + start_index, buffer_data.data() + start_index, + sizeof(EulaVersion)); + } + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); +} + void SET_SYS::GetColorSetId(HLERequestContext& ctx) { LOG_DEBUG(Service_SET, "called"); @@ -149,7 +186,7 @@ void SET_SYS::GetAccountNotificationSettings(HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); - rb.Push(account_notifications.size()); + rb.Push(static_cast(account_notifications.size())); } void SET_SYS::SetAccountNotificationSettings(HLERequestContext& ctx) { @@ -275,6 +312,16 @@ void SET_SYS::GetQuestFlag(HLERequestContext& ctx) { rb.PushEnum(QuestFlag::Retail); } +void SET_SYS::SetRegionCode(HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + region_code = rp.PopEnum(); + + LOG_INFO(Service_SET, "called, region_code={}", region_code); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); +} + void SET_SYS::GetPrimaryAlbumStorage(HLERequestContext& ctx) { LOG_WARNING(Service_SET, "(STUBBED) called"); @@ -286,7 +333,7 @@ void SET_SYS::GetPrimaryAlbumStorage(HLERequestContext& ctx) { void SET_SYS::GetSleepSettings(HLERequestContext& ctx) { LOG_INFO(Service_SET, "called"); - IPC::ResponseBuilder rb{ctx, 7}; + IPC::ResponseBuilder rb{ctx, 5}; rb.Push(ResultSuccess); rb.PushRaw(sleep_settings); } @@ -434,10 +481,18 @@ void SET_SYS::GetChineseTraditionalInputMethod(HLERequestContext& ctx) { rb.PushEnum(ChineseTraditionalInputMethod::Unknown0); } +void SET_SYS::GetFieldTestingFlag(HLERequestContext& ctx) { + LOG_WARNING(Service_SET, "(STUBBED) called"); + + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(ResultSuccess); + rb.Push(false); +} + SET_SYS::SET_SYS(Core::System& system_) : ServiceFramework{system_, "set:sys"} { // clang-format off static const FunctionInfo functions[] = { - {0, nullptr, "SetLanguageCode"}, + {0, &SET_SYS::SetLanguageCode, "SetLanguageCode"}, {1, nullptr, "SetNetworkSettings"}, {2, nullptr, "GetNetworkSettings"}, {3, &SET_SYS::GetFirmwareVersion, "GetFirmwareVersion"}, @@ -457,8 +512,8 @@ SET_SYS::SET_SYS(Core::System& system_) : ServiceFramework{system_, "set:sys"} { {18, &SET_SYS::SetAccountSettings, "SetAccountSettings"}, {19, nullptr, "GetAudioVolume"}, {20, nullptr, "SetAudioVolume"}, - {21, nullptr, "GetEulaVersions"}, - {22, nullptr, "SetEulaVersions"}, + {21, &SET_SYS::GetEulaVersions, "GetEulaVersions"}, + {22, &SET_SYS::SetEulaVersions, "SetEulaVersions"}, {23, &SET_SYS::GetColorSetId, "GetColorSetId"}, {24, &SET_SYS::SetColorSetId, "SetColorSetId"}, {25, nullptr, "GetConsoleInformationUploadFlag"}, @@ -491,7 +546,7 @@ SET_SYS::SET_SYS(Core::System& system_) : ServiceFramework{system_, "set:sys"} { {54, nullptr, "SetDeviceTimeZoneLocationName"}, {55, nullptr, "GetWirelessCertificationFileSize"}, {56, nullptr, "GetWirelessCertificationFile"}, - {57, nullptr, "SetRegionCode"}, + {57, &SET_SYS::SetRegionCode, "SetRegionCode"}, {58, nullptr, "GetNetworkSystemClockContext"}, {59, nullptr, "SetNetworkSystemClockContext"}, {60, nullptr, "IsUserSystemClockAutomaticCorrectionEnabled"}, @@ -635,7 +690,7 @@ SET_SYS::SET_SYS(Core::System& system_) : ServiceFramework{system_, "set:sys"} { {198, nullptr, "SetButtonConfigRegisteredSettingsEmbedded"}, {199, nullptr, "GetButtonConfigRegisteredSettings"}, {200, nullptr, "SetButtonConfigRegisteredSettings"}, - {201, nullptr, "GetFieldTestingFlag"}, + {201, &SET_SYS::GetFieldTestingFlag, "GetFieldTestingFlag"}, {202, nullptr, "SetFieldTestingFlag"}, {203, nullptr, "GetPanelCrcMode"}, {204, nullptr, "SetPanelCrcMode"}, diff --git a/src/core/hle/service/set/set_sys.h b/src/core/hle/service/set/set_sys.h index 16624d3fd..c7dba2a9e 100644 --- a/src/core/hle/service/set/set_sys.h +++ b/src/core/hle/service/set/set_sys.h @@ -118,6 +118,22 @@ private: Never, }; + /// This is nn::settings::system::RegionCode + enum class RegionCode : u32 { + Japan, + Usa, + Europe, + Australia, + HongKongTaiwanKorea, + China, + }; + + /// This is nn::settings::system::EulaVersionClockType + enum class EulaVersionClockType : u32 { + NetworkSystemClock, + SteadyClock, + }; + /// This is nn::settings::system::SleepFlag struct SleepFlag { union { @@ -242,10 +258,24 @@ private: }; static_assert(sizeof(InitialLaunchSettings) == 0x20, "InitialLaunchSettings is incorrect size"); + /// This is nn::settings::system::InitialLaunchSettings + 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"); + + void SetLanguageCode(HLERequestContext& ctx); void GetFirmwareVersion(HLERequestContext& ctx); void GetFirmwareVersion2(HLERequestContext& ctx); void GetAccountSettings(HLERequestContext& ctx); void SetAccountSettings(HLERequestContext& ctx); + void GetEulaVersions(HLERequestContext& ctx); + void SetEulaVersions(HLERequestContext& ctx); void GetColorSetId(HLERequestContext& ctx); void SetColorSetId(HLERequestContext& ctx); void GetNotificationSettings(HLERequestContext& ctx); @@ -257,6 +287,7 @@ private: void GetTvSettings(HLERequestContext& ctx); void SetTvSettings(HLERequestContext& ctx); void GetQuestFlag(HLERequestContext& ctx); + void SetRegionCode(HLERequestContext& ctx); void GetPrimaryAlbumStorage(HLERequestContext& ctx); void GetSleepSettings(HLERequestContext& ctx); void SetSleepSettings(HLERequestContext& ctx); @@ -273,6 +304,7 @@ private: void SetAppletLaunchFlags(HLERequestContext& ctx); void GetKeyboardLayout(HLERequestContext& ctx); void GetChineseTraditionalInputMethod(HLERequestContext& ctx); + void GetFieldTestingFlag(HLERequestContext& ctx); AccountSettings account_settings{ .flags = {}, @@ -312,6 +344,12 @@ private: }; u32 applet_launch_flag{}; + + std::vector eula_versions{}; + + RegionCode region_code; + + LanguageCode language_code_setting; }; } // namespace Service::Set -- cgit v1.2.3