Update to latest ams libs, this implied several rewrites

This commit is contained in:
XorTroll 2021-10-17 19:52:50 +02:00
parent 4a6fe41127
commit 21dcf8ec22
25 changed files with 864 additions and 881 deletions

@ -1 +1 @@
Subproject commit dc52a32285c62fbb68e701393ec3b4efdc452343
Subproject commit cf765c0946cc5c828364ae6bfccddc4041304f28

View file

@ -10,32 +10,32 @@ namespace ipc {
using ObjectFactory = ams::sf::ObjectFactory<ams::sf::ExpHeapAllocator::Policy>;
struct ServerOptions {
static const size_t PointerBufferSize = 0x800;
static const size_t MaxDomains = 0x40;
static const size_t MaxDomainObjects = 0x100;
static constexpr size_t PointerBufferSize = 0x800;
static constexpr size_t MaxDomains = 0x40;
static constexpr size_t MaxDomainObjects = 0x100;
static constexpr bool CanDeferInvokeRequest = false;
static constexpr bool CanManageMitmServers = false;
};
enum PortIndex {
PortIndex_PrivateService,
/*
PortIndex_PublicService,
*/
enum Port {
Port_PrivateService,
/* Port_PublicService, */
PortIndex_Count
Port_Count
};
constexpr size_t MaxPrivateSessions = 1;
constexpr ams::sm::ServiceName PrivateServiceName = ams::sm::ServiceName::Encode(AM_DAEMON_PRIVATE_SERVICE_NAME);
constexpr ams::sm::ServiceName PrivateServiceName = ams::sm::ServiceName::Encode(::PrivateServiceName);
/*
constexpr size_t MaxPublicSessions = 0x20;
constexpr ams::sm::ServiceName PublicServiceName = ams::sm::ServiceName::Encode(AM_DAEMON_PUBLIC_SERVICE_NAME);
constexpr ams::sm::ServiceName PublicServiceName = ams::sm::ServiceName::Encode(::PublicServiceName);
*/
constexpr size_t MaxEcsExtraSessions = 5;
constexpr size_t MaxSessions = MaxPrivateSessions + MaxEcsExtraSessions;
class ServerManager final : public ams::sf::hipc::ServerManager<PortIndex_Count, ServerOptions, MaxSessions> {
class ServerManager final : public ams::sf::hipc::ServerManager<Port_Count, ServerOptions, MaxSessions> {
private:
virtual ams::Result OnNeedsToAccept(int port_index, Server *server) override;
};

File diff suppressed because it is too large Load diff

View file

@ -10,7 +10,7 @@ namespace {
ams::os::Mutex g_ServerAllocatorLock(false);
void GlobalManagerThread(void*) {
UL_AMS_ASSERT(g_GlobalManager.RegisterServer(ipc::PortIndex_PrivateService, ipc::PrivateServiceName, ipc::MaxPrivateSessions));
UL_AMS_ASSERT(g_GlobalManager.RegisterServer(ipc::Port_PrivateService, ipc::PrivateServiceName, ipc::MaxPrivateSessions));
// UL_ASSERT(g_GlobalManager.RegisterServer<ipc::IPublicService>(PublicServiceName, MaxPublicSessions).GetValue());
g_GlobalManager.LoopProcess();
@ -31,7 +31,7 @@ namespace ipc {
ams::Result ServerManager::OnNeedsToAccept(int port_index, Server *server) {
switch(port_index) {
case PortIndex_PrivateService: {
case Port_PrivateService: {
return this->AcceptImpl(server, MakeShared<ams::sf::ul::IPrivateService, ipc::PrivateService>());
}
AMS_UNREACHABLE_DEFAULT_CASE();

View file

@ -16,24 +16,24 @@ namespace ipc {
// If Menu hasn't been launched it's program ID will be 0 (invalid), thus a single (program_id != last_menu_program_id) check isn't enough
// If any of the IDs is invalid, something unexpected is happening...
if((last_menu_program_id == 0) || (program_id == 0) || (program_id != last_menu_program_id)) {
return RES_VALUE(Daemon, PrivateServiceInvalidProcess);
return ipc::ResultInvalidProcess;
}
this->initialized = true;
}
return ams::ResultSuccess();
return ResultSuccess;
}
ams::Result PrivateService::GetMessage(ams::sf::Out<dmi::MenuMessage> out_msg) {
if(!this->initialized) {
return RES_VALUE(Daemon, PrivateServiceInvalidProcess);
return ipc::ResultInvalidProcess;
}
std::scoped_lock lk(g_LastMenuMessageLock);
out_msg.SetValue(g_LastMenuMessage);
g_LastMenuMessage = dmi::MenuMessage::Invalid;
return ams::ResultSuccess();
return ResultSuccess;
}
}

View file

@ -15,7 +15,7 @@ namespace am {
AccountUid uid;
u8 unk2[0x3E8];
static inline constexpr ApplicationSelectedUserArgument Create(AccountUid uid) {
static inline constexpr ApplicationSelectedUserArgument Create(const AccountUid uid) {
ApplicationSelectedUserArgument arg = {};
arg.magic = SelectedUserMagic;
arg.unk_1 = 1;
@ -28,12 +28,12 @@ namespace am {
bool ApplicationIsActive();
void ApplicationTerminate();
Result ApplicationStart(u64 app_id, bool system, AccountUid user_id, void *data = nullptr, size_t size = 0);
Result ApplicationStart(const u64 app_id, const bool system, const AccountUid user_id, const void *data = nullptr, const size_t size = 0);
bool ApplicationHasForeground();
Result ApplicationSetForeground();
Result ApplicationSend(void *data, size_t size, AppletLaunchParameterKind kind = AppletLaunchParameterKind_UserChannel);
Result ApplicationSend(const void *data, const size_t size, const AppletLaunchParameterKind kind = AppletLaunchParameterKind_UserChannel);
u64 ApplicationGetId();
bool ApplicationNeedsUser(u64 app_id);
bool ApplicationNeedsUser(const u64 app_id);
}

View file

@ -5,13 +5,13 @@
namespace am {
bool LibraryAppletIsActive();
void LibraryAppletSetMenuAppletId(AppletId id);
void LibraryAppletSetMenuAppletId(const AppletId id);
AppletId LibraryAppletGetMenuAppletId();
bool LibraryAppletIsMenu();
void LibraryAppletTerminate();
Result LibraryAppletStart(AppletId id, u32 la_version, void *in_data, size_t in_size);
Result LibraryAppletSend(void *data, size_t size);
Result LibraryAppletRead(void *data, size_t size);
Result LibraryAppletStart(const AppletId id, const u32 la_version, const void *in_data, const size_t in_size);
Result LibraryAppletSend(const void *data, const size_t size);
Result LibraryAppletRead(void *data, const size_t size);
Result LibraryAppletPush(AppletStorage *st);
Result LibraryAppletPop(AppletStorage *st);
@ -19,8 +19,8 @@ namespace am {
return LibraryAppletStart(AppletId_LibraryAppletWeb, web->version, &web->arg, sizeof(web->arg));
}
u64 LibraryAppletGetProgramIdForAppletId(AppletId id);
AppletId LibraryAppletGetAppletIdForProgramId(u64 id);
u64 LibraryAppletGetProgramIdForAppletId(const AppletId id);
AppletId LibraryAppletGetAppletIdForProgramId(const u64 id);
AppletId LibraryAppletGetId();

View file

@ -3,8 +3,8 @@
#include <ul_Include.hpp>
#include <hb/hb_Target.hpp>
#define AM_DAEMON_PRIVATE_SERVICE_NAME "qdmnsrv"
#define AM_DAEMON_PUBLIC_SERVICE_NAME "ulaunch"
constexpr const char PrivateServiceName[] = "ulsf:p";
/* constexpr const char PublicServiceName[] = "ulsf:u"; */
namespace dmi {
@ -205,7 +205,7 @@ namespace dmi {
}
namespace daemon {
namespace dmn {
Result PopStorage(AppletStorage *st, bool wait);
Result PushStorage(AppletStorage *st);

View file

@ -24,8 +24,27 @@ namespace os {
TraditionalChinese
};
std::string GetLanguageName(u32 idx);
const std::vector<std::string> &GetLanguageNameList();
constexpr const char *LanguageNameList[] = {
"Japanese",
"American English",
"Français",
"Deutsch",
"Italiano",
"Español",
"Chinese",
"Korean",
"Nederlands",
"Português",
"Русский",
"Taiwanese",
"British English",
"Français canadien",
"Español latino",
"Chinese (simplified)",
"Chinese (traditional)",
"Português brasileiro"
};
constexpr size_t LanguageNameCount = sizeof(LanguageNameList) / sizeof(const char*);
u32 GetBatteryLevel();
bool IsConsoleCharging();

View file

@ -36,25 +36,12 @@ using JSON = nlohmann::json;
static constexpr size_t RawRGBAScreenBufferSize = 1280 * 720 * 4;
#ifndef R_TRY
#define R_TRY(res_expr) ({ \
const auto _tmp_r_try_rc = static_cast<Result>(res_expr); \
if (R_FAILED(_tmp_r_try_rc)) { \
return _tmp_r_try_rc; \
} \
})
#endif
#define STL_FIND_IF(stl_item, var_name, cond) std::find_if(stl_item.begin(), stl_item.end(), [&](const auto &var_name){ return (cond); })
#define STL_FOUND(stl_item, find_ret) (find_ret != stl_item.end())
#define STL_UNWRAP(find_ret) (*find_ret)
#define STL_REMOVE_IF(stl_item, var_name, cond) stl_item.erase(std::remove_if(stl_item.begin(), stl_item.end(), [&](const auto &var_name){ return (cond); }), stl_item.end())
constexpr Result ResultSuccess = 0;
#include <ul_Results.hpp>
#include <ul_Result.hpp>
inline constexpr size_t operator ""_KB(unsigned long long n) {
return n * 0x400;

View file

@ -0,0 +1,64 @@
#include <switch.h>
#include <string>
// All 2380-**** results are from us
constexpr u32 Module = 380;
constexpr u32 SubmoduleOffset = 100;
#define RES_DEFINE_SUBMODULE(val) constexpr u32 Submodule = val
#define RES_DEFINE(name, val) constexpr Result Result ## name = MAKERESULT(Module + Submodule * SubmoduleOffset, val)
#ifndef R_TRY
#define R_TRY(res_expr) ({ \
const auto _tmp_r_try_rc = static_cast<Result>(res_expr); \
if (R_FAILED(_tmp_r_try_rc)) { \
return _tmp_r_try_rc; \
} \
})
#endif
constexpr Result ResultSuccess = 0;
namespace misc {
RES_DEFINE_SUBMODULE(0);
RES_DEFINE(InvalidJsonFile, 1);
}
namespace dmn {
RES_DEFINE_SUBMODULE(1);
RES_DEFINE(ApplicationActive, 1);
RES_DEFINE(InvalidSelectedUser, 2);
RES_DEFINE(AlreadyQueued, 3);
RES_DEFINE(ApplicationNotActive, 4);
}
namespace menu {
RES_DEFINE_SUBMODULE(2);
RES_DEFINE(RomfsFileNotFound, 1);
}
namespace ipc {
RES_DEFINE_SUBMODULE(3);
RES_DEFINE(InvalidProcess, 1);
}
namespace res {
Result GetResultByModuleAndName(const std::string &mod, const std::string &name);
std::string GetModuleByResult(const Result rc);
std::string GetNameByResult(const Result rc);
}

View file

@ -1,18 +0,0 @@
#include <switch.h>
#include <string>
// Result-making macros
#define RES_VALUE(module, name) res::GetResultByModuleAndName(#module, #name)
#define RES_DESCRIPTION(rc) res::GetDescriptionByResult(rc)
namespace res {
// All 2380-**** results are from uLaunch!
static constexpr u32 Module = 380;
Result GetResultByModuleAndName(std::string mod, std::string name);
std::string GetDescriptionByResult(Result rc);
}

View file

@ -4,15 +4,15 @@
namespace util {
std::string Format128NintendoStyle(AccountUid value);
std::string Format128NintendoStyle(const AccountUid value);
inline u64 Get64FromString(const std::string &val) {
return strtoull(val.c_str(), nullptr, 16);
}
std::string FormatApplicationId(u64 app_id);
std::string FormatResultDisplay(Result rc);
std::string FormatResultHex(Result rc);
std::string FormatResult(Result rc);
std::string FormatApplicationId(const u64 app_id);
std::string FormatResultDisplay(const Result rc);
std::string FormatResultHex(const Result rc);
std::string FormatResult(const Result rc);
}

View file

@ -33,7 +33,7 @@ namespace am {
g_DaemonHasFocus = true;
}
Result ApplicationStart(u64 app_id, bool system, AccountUid user_id, void *data, size_t size) {
Result ApplicationStart(const u64 app_id, const bool system, const AccountUid user_id, const void *data, const size_t size) {
appletApplicationClose(&g_ApplicationHolder);
if(system) {
@ -70,7 +70,7 @@ namespace am {
return ResultSuccess;
}
Result ApplicationSend(void *data, size_t size, AppletLaunchParameterKind kind) {
Result ApplicationSend(const void *data, const size_t size, const AppletLaunchParameterKind kind) {
AppletStorage st;
R_TRY(appletCreateStorage(&st, size));
UL_ON_SCOPE_EXIT({
@ -85,7 +85,7 @@ namespace am {
return g_LastApplicationId;
}
bool ApplicationNeedsUser(u64 app_id) {
bool ApplicationNeedsUser(const u64 app_id) {
NsApplicationControlData ctdata = {};
nsGetApplicationControlData(NsApplicationControlSource_Storage, app_id, &ctdata, sizeof(ctdata), nullptr);
return ctdata.nacp.startup_user_account > 0;

View file

@ -8,7 +8,12 @@ namespace am {
AppletId g_MenuAppletId = AppletId_None;
AppletId g_LastAppletId = AppletId_None;
const std::map<u64, AppletId> g_AppletIdTable = {
struct AppletInfo {
u64 program_id;
AppletId applet_id;
};
constexpr AppletInfo g_AppletTable[] = {
{ 0x0100000000001001, AppletId_LibraryAppletAuth },
{ 0x0100000000001002, AppletId_LibraryAppletCabinet },
{ 0x0100000000001003, AppletId_LibraryAppletController },
@ -27,6 +32,7 @@ namespace am {
{ 0x0100000000001011, AppletId_LibraryAppletWifiWebAuth },
{ 0x0100000000001013, AppletId_LibraryAppletMyPage }
};
constexpr size_t AppletCount = sizeof(g_AppletTable) / sizeof(AppletInfo);
}
@ -57,7 +63,7 @@ namespace am {
appletHolderRequestExitOrTerminate(&g_AppletHolder, 15'000'000'000ul);
}
Result LibraryAppletStart(AppletId id, u32 la_version, void *in_data, size_t in_size) {
Result LibraryAppletStart(const AppletId id, const u32 la_version, const void *in_data, const size_t in_size) {
if(LibraryAppletIsActive()) {
LibraryAppletTerminate();
}
@ -74,11 +80,11 @@ namespace am {
return ResultSuccess;
}
Result LibraryAppletSend(void *data, size_t size) {
Result LibraryAppletSend(const void *data, const size_t size) {
return libappletPushInData(&g_AppletHolder, data, size);
}
Result LibraryAppletRead(void *data, size_t size) {
Result LibraryAppletRead(void *data, const size_t size) {
return libappletPopOutData(&g_AppletHolder, data, size, nullptr);
}
@ -90,46 +96,25 @@ namespace am {
return appletHolderPopOutData(&g_AppletHolder, st);
}
Result LibraryAppletDaemonLaunchWith(AppletId id, u32 la_version, std::function<void(AppletHolder*)> on_prepare, std::function<void(AppletHolder*)> on_finish, std::function<bool()> on_wait) {
if(LibraryAppletIsActive()) {
LibraryAppletTerminate();
}
appletHolderClose(&g_AppletHolder);
LibAppletArgs largs;
libappletArgsCreate(&largs, la_version);
R_TRY(appletCreateLibraryApplet(&g_AppletHolder, id, LibAppletMode_AllForeground));
R_TRY(libappletArgsPush(&largs, &g_AppletHolder));
on_prepare(&g_AppletHolder);
R_TRY(appletHolderStart(&g_AppletHolder));
while(true) {
if(!LibraryAppletIsActive()) {
break;
u64 LibraryAppletGetProgramIdForAppletId(const AppletId id) {
for(u32 i = 0; i < AppletCount; i++) {
const auto info = g_AppletTable[i];
if(info.applet_id == id) {
return info.program_id;
}
if(!on_wait()) {
LibraryAppletTerminate();
break;
}
svcSleepThread(10'000'000ul);
}
on_finish(&g_AppletHolder);
appletHolderClose(&g_AppletHolder);
return ResultSuccess;
}
u64 LibraryAppletGetProgramIdForAppletId(AppletId id) {
for(auto &[program_id, applet_id] : g_AppletIdTable) {
if(applet_id == id) {
return program_id;
}
}
return 0;
}
AppletId LibraryAppletGetAppletIdForProgramId(u64 id) {
auto it = g_AppletIdTable.find(id);
if(it != g_AppletIdTable.end()) {
return it->second;
AppletId LibraryAppletGetAppletIdForProgramId(const u64 id) {
for(u32 i = 0; i < AppletCount; i++) {
const auto info = g_AppletTable[i];
if(info.program_id == id) {
return info.applet_id;
}
}
return AppletId_None;
}

View file

@ -34,7 +34,7 @@ namespace dmi {
}
namespace daemon {
namespace dmn {
Result PushStorage(AppletStorage *st) {
return LoopWait(&am::LibraryAppletPush, st, false);

View file

@ -3,42 +3,6 @@
namespace os {
namespace {
const std::vector<std::string> g_LanguageNameList = {
"Japanese",
"American English",
"Français",
"Deutsch",
"Italiano",
"Español",
"Chinese",
"Korean",
"Nederlands",
"Português",
"Русский",
"Taiwanese",
"British English",
"Français canadien",
"Español latino",
"Chinese (simplified)",
"Chinese (traditional)",
"Português brasileiro"
};
}
std::string GetLanguageName(u32 idx) {
if(idx >= g_LanguageNameList.size()) {
return "";
}
return g_LanguageNameList[idx];
}
const std::vector<std::string> &GetLanguageNameList() {
return g_LanguageNameList;
}
u32 GetBatteryLevel() {
u32 lvl = 0;
psmGetBatteryChargePercentage(&lvl);

View file

@ -0,0 +1,70 @@
#include <ul_Result.hpp>
namespace res {
namespace {
struct ResultInfoImpl {
Result rc;
const char *mod;
const char *name;
};
#define _RES_INFO_DEFINE(mod, name) { mod::Result ## name, #mod, #name }
static ResultInfoImpl g_ResultInfoTableImpl[] = {
_RES_INFO_DEFINE(misc, InvalidJsonFile),
_RES_INFO_DEFINE(dmn, ApplicationActive),
_RES_INFO_DEFINE(dmn, InvalidSelectedUser),
_RES_INFO_DEFINE(dmn, AlreadyQueued),
_RES_INFO_DEFINE(dmn, ApplicationNotActive),
_RES_INFO_DEFINE(menu, RomfsFileNotFound),
_RES_INFO_DEFINE(ipc, InvalidProcess),
};
constexpr size_t ResultInfoTableImplCount = sizeof(g_ResultInfoTableImpl) / sizeof(ResultInfoImpl);
inline constexpr ResultInfoImpl &GetResultInfo(const u32 idx) {
return g_ResultInfoTableImpl[idx];
}
}
Result GetResultByModuleAndName(const std::string &mod, const std::string &name) {
for(u32 i = 0; i < ResultInfoTableImplCount; i++) {
const auto rc_info = GetResultInfo(i);
if((mod == rc_info.mod) && (name == rc_info.name)) {
return rc_info.rc;
}
}
// TODO: proper return value?
return 0;
}
std::string GetModuleByResult(const Result rc) {
for(u32 i = 0; i < ResultInfoTableImplCount; i++) {
const auto rc_info = GetResultInfo(i);
if(rc == rc_info.rc) {
return rc_info.mod;
}
}
return "Unknown module";
}
std::string GetNameByResult(const Result rc) {
for(u32 i = 0; i < ResultInfoTableImplCount; i++) {
const auto rc_info = GetResultInfo(i);
if(rc == rc_info.rc) {
return rc_info.name;
}
}
return "Unknown name";
}
}

View file

@ -1,74 +0,0 @@
#include <ul_Results.hpp>
#include <vector>
// Result-making macros
#define RES_BLOCK_BEGIN static std::vector<ResultModuleImpl> g_result_impl_table = {
#define RES_MODULE_BEGIN(name, val) { val * 100, #name, {
#define RES_DEFINE(name, desc) { desc, #name },
#define RES_MODULE_END } },
#define RES_BLOCK_END };
namespace res {
struct ResultImpl {
u32 res_desc;
std::string res_name;
};
struct ResultModuleImpl {
u32 mod_val;
std::string mod_name;
std::vector<ResultImpl> results;
};
RES_BLOCK_BEGIN
RES_MODULE_BEGIN(Misc, 1)
RES_DEFINE(InvalidJSONFile, 1)
RES_MODULE_END
RES_MODULE_BEGIN(Daemon, 2)
RES_DEFINE(ApplicationActive, 1)
RES_DEFINE(InvalidSelectedUser, 2)
RES_DEFINE(AlreadyQueued, 3)
RES_DEFINE(ApplicationNotActive, 4)
RES_DEFINE(PrivateServiceInvalidProcess, 5)
RES_MODULE_END
RES_MODULE_BEGIN(Menu, 3)
RES_DEFINE(RomfsBinNotFound, 1)
RES_MODULE_END
RES_BLOCK_END
Result GetResultByModuleAndName(std::string mod, std::string name) {
for(auto &module: g_result_impl_table) {
if(module.mod_name == mod) {
for(auto &res: module.results) {
if(res.res_name == name) {
return MAKERESULT(Module, module.mod_val + res.res_desc);
}
}
}
}
return 0;
}
std::string GetDescriptionByResult(Result rc) {
for(auto &module: g_result_impl_table) {
for(auto &res: module.results) {
if(rc == MAKERESULT(Module, module.mod_val + res.res_desc)) {
return module.mod_name + " - " + res.res_name;
}
}
}
return "Unknown result";
}
}

View file

@ -1,67 +1,64 @@
#include <util/util_Convert.hpp>
namespace util
{
std::string Format128NintendoStyle(AccountUid value) {
auto bytes_v = reinterpret_cast<u8*>(value.uid);
namespace util {
std::string Format128NintendoStyle(const AccountUid value) {
auto bytes_v = reinterpret_cast<const u8*>(value.uid);
std::stringstream strm;
#define _UL_TMP_PRINT(idx) strm << std::hex << std::setw(2) << std::setfill('0') << std::nouppercase << static_cast<u32>(bytes_v[idx]);
#define _UL_TMP_DASH strm << "-";
#define _UL_UTIL_PRINT(idx) strm << std::hex << std::setw(2) << std::setfill('0') << std::nouppercase << static_cast<const u32>(bytes_v[idx]);
#define _UL_UTIL_DASH strm << "-";
_UL_TMP_PRINT(3)
_UL_TMP_PRINT(2)
_UL_TMP_PRINT(1)
_UL_TMP_PRINT(0)
_UL_TMP_DASH
_UL_TMP_PRINT(5)
_UL_TMP_PRINT(4)
_UL_TMP_DASH
_UL_TMP_PRINT(7)
_UL_TMP_PRINT(6)
_UL_TMP_DASH
_UL_TMP_PRINT(9)
_UL_TMP_PRINT(8)
_UL_TMP_DASH
_UL_TMP_PRINT(15)
_UL_TMP_PRINT(14)
_UL_TMP_PRINT(13)
_UL_TMP_PRINT(12)
_UL_TMP_PRINT(11)
_UL_TMP_PRINT(10)
_UL_UTIL_PRINT(3)
_UL_UTIL_PRINT(2)
_UL_UTIL_PRINT(1)
_UL_UTIL_PRINT(0)
_UL_UTIL_DASH
_UL_UTIL_PRINT(5)
_UL_UTIL_PRINT(4)
_UL_UTIL_DASH
_UL_UTIL_PRINT(7)
_UL_UTIL_PRINT(6)
_UL_UTIL_DASH
_UL_UTIL_PRINT(9)
_UL_UTIL_PRINT(8)
_UL_UTIL_DASH
_UL_UTIL_PRINT(15)
_UL_UTIL_PRINT(14)
_UL_UTIL_PRINT(13)
_UL_UTIL_PRINT(12)
_UL_UTIL_PRINT(11)
_UL_UTIL_PRINT(10)
#undef _UL_TMP_DASH
#undef _UL_TMP_PRINT
#undef _UL_UTIL_DASH
#undef _UL_UTIL_PRINT
return strm.str();
}
std::string FormatApplicationId(u64 app_id) {
std::string FormatApplicationId(const u64 app_id) {
std::stringstream strm;
strm << std::uppercase << std::setfill('0') << std::setw(16) << std::hex << app_id;
return strm.str();
}
std::string FormatResultDisplay(Result rc) {
std::string FormatResultDisplay(const Result rc) {
char res[0x20] = {};
sprintf(res, "%04d-%04d", R_MODULE(rc) + 2000, R_DESCRIPTION(rc));
return res;
}
std::string FormatResultHex(Result rc) {
std::string FormatResultHex(const Result rc) {
char res[0x20] = {};
sprintf(res, "0x%X", rc);
return res;
}
std::string FormatResult(Result rc) {
auto desc = RES_DESCRIPTION(rc);
auto fmt = "(" + FormatResultDisplay(rc) + ")";
if(!desc.empty()) {
fmt += " ";
fmt += desc;
}
return fmt;
std::string FormatResult(const Result rc) {
const auto rc_mod = res::GetModuleByResult(rc);
const auto rc_name = res::GetNameByResult(rc);
const auto rc_fmt = FormatResultDisplay(rc);
return rc_mod + " - " + rc_name + " (" + rc_fmt + ")";
}
}

View file

@ -1,8 +1,8 @@
#include <util/util_Misc.hpp>
#include <fs/fs_Stdio.hpp>
namespace util
{
namespace util {
Result LoadJSONFromFile(JSON &out_json, const std::string &path) {
if(fs::ExistsFile(path)) {
try {
@ -12,7 +12,8 @@ namespace util
}
catch(...) {}
}
return RES_VALUE(Misc, InvalidJSONFile);
return misc::ResultInvalidJsonFile;
}
}

View file

@ -88,7 +88,7 @@ int main() {
// Check if our RomFs data exists...
if(!fs::ExistsFile(UL_MENU_ROMFS_BIN)) {
UL_ASSERT(RES_VALUE(Menu, RomfsBinNotFound));
UL_ASSERT(menu::ResultRomfsFileNotFound);
}
// Try to mount it

View file

@ -20,7 +20,7 @@ namespace {
return ResultSuccess;
}
R_TRY(smGetService(&g_DaemonPrivateService, AM_DAEMON_PRIVATE_SERVICE_NAME));
R_TRY(smGetService(&g_DaemonPrivateService, PrivateServiceName));
R_TRY(daemonPrivateInitialize(&g_DaemonPrivateService));
return ResultSuccess;

View file

@ -62,17 +62,15 @@ namespace ui {
setGetLanguageCode(&lcode);
setMakeLanguage(lcode, &ilang);
u32 idx = 0;
for(auto &lang: os::GetLanguageNameList()) {
auto name = lang;
if(static_cast<u32>(ilang) == idx) {
for(u32 i = 0; i < os::LanguageNameCount; i++) {
std::string name = os::LanguageNameList[i];
if(static_cast<u32>(ilang) == i) {
name += " " + GetLanguageString("lang_selected");
}
auto litm = pu::ui::elm::MenuItem::New(name);
litm->SetColor(textclr);
litm->AddOnClick(std::bind(&LanguagesMenuLayout::lang_Click, this, idx));
litm->AddOnClick(std::bind(&LanguagesMenuLayout::lang_Click, this, i));
this->langsMenu->AddItem(litm);
idx++;
}
}

View file

@ -96,7 +96,7 @@ namespace ui {
auto ilang = SetLanguage_ENUS;
setGetLanguageCode(&lcode);
setMakeLanguage(lcode, &ilang);
this->PushSettingItem(GetLanguageString("set_console_lang"), EncodeForSettings(os::GetLanguageName(ilang)), 3);
this->PushSettingItem(GetLanguageString("set_console_lang"), EncodeForSettings(os::LanguageNameList[ilang]), 3);
bool console_info_upload = false;
setsysGetConsoleInformationUploadFlag(&console_info_upload);
this->PushSettingItem(GetLanguageString("set_console_info_upload"), EncodeForSettings(console_info_upload), 4);