diff --git a/app/src/main/cpp/skyline/services/settings/ISettingsServer.cpp b/app/src/main/cpp/skyline/services/settings/ISettingsServer.cpp index 7683245b..5483ea99 100644 --- a/app/src/main/cpp/skyline/services/settings/ISettingsServer.cpp +++ b/app/src/main/cpp/skyline/services/settings/ISettingsServer.cpp @@ -6,10 +6,12 @@ namespace skyline::service::settings { ISettingsServer::ISettingsServer(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager, Service::settings_ISettingsServer, "settings:ISettingsServer", { - {0x1, SFUNC(ISettingsServer::GetAvailableLanguageCodes)} + {0x1, SFUNC(ISettingsServer::GetAvailableLanguageCodes)}, + {0x2, SFUNC(ISettingsServer::MakeLanguageCode)}, + {0x5, SFUNC(ISettingsServer::GetAvailableLanguageCodes2)} }) {} - constexpr std::array LanguageCodeList = { + constexpr std::array LanguageCodeList = { util::MakeMagic("ja"), util::MakeMagic("en-US"), util::MakeMagic("fr"), @@ -24,12 +26,24 @@ namespace skyline::service::settings { util::MakeMagic("zh-TW"), util::MakeMagic("en-GB"), util::MakeMagic("fr-CA"), - util::MakeMagic("es-419") + util::MakeMagic("es-419"), + util::MakeMagic("zh-Hans"), + util::MakeMagic("zh-Hant"), }; void ISettingsServer::GetAvailableLanguageCodes(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - state.process->WriteMemory(LanguageCodeList.data(), request.outputBuf.at(0).address, LanguageCodeList.size() * sizeof(u64)); + state.process->WriteMemory(LanguageCodeList.data(), request.outputBuf.at(0).address, constant::OldLanguageCodeListSize * sizeof(u64)); - response.Push(LanguageCodeList.size()); + response.Push(constant::OldLanguageCodeListSize); + } + + void ISettingsServer::MakeLanguageCode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + response.Push(LanguageCodeList.at(request.Pop())); + } + + void ISettingsServer::GetAvailableLanguageCodes2(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + state.process->WriteMemory(LanguageCodeList.data(), request.outputBuf.at(0).address, constant::NewLanguageCodeListSize * sizeof(u64)); + + response.Push(constant::NewLanguageCodeListSize); } } diff --git a/app/src/main/cpp/skyline/services/settings/ISettingsServer.h b/app/src/main/cpp/skyline/services/settings/ISettingsServer.h index 568f72b4..69df0b47 100644 --- a/app/src/main/cpp/skyline/services/settings/ISettingsServer.h +++ b/app/src/main/cpp/skyline/services/settings/ISettingsServer.h @@ -6,17 +6,34 @@ #include #include -namespace skyline::service::settings { - /** - * @brief ISettingsServer or 'set' provides access to user settings (https://switchbrew.org/wiki/Settings_services#set) - */ - class ISettingsServer : public BaseService { - public: - ISettingsServer(const DeviceState &state, ServiceManager &manager); +namespace skyline::service { + namespace constant { + constexpr size_t OldLanguageCodeListSize = 15; //!< The size of the pre 4.0.0 language code list + constexpr size_t NewLanguageCodeListSize = 17; //!< The size of the post 4.0.0 language code list + } + namespace settings { /** - * @brief This reads the available language codes that an application can use + * @brief ISettingsServer or 'set' provides access to user settings (https://switchbrew.org/wiki/Settings_services#set) */ - void GetAvailableLanguageCodes(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); - }; + class ISettingsServer : public BaseService { + public: + ISettingsServer(const DeviceState &state, ServiceManager &manager); + + /** + * @brief This reads the available language codes that an application can use (pre 4.0.0) + */ + void GetAvailableLanguageCodes(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + /** + * @brief This converts a language code list index to it's corresponding language code + */ + void MakeLanguageCode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + + /** + * @brief This reads the available language codes that an application can use (post 4.0.0) + */ + void GetAvailableLanguageCodes2(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + }; + } }