From bbb1494c17510c31287967e6a188d7f774193ad5 Mon Sep 17 00:00:00 2001 From: XorTroll Date: Sun, 27 Oct 2019 13:09:49 +0100 Subject: [PATCH] Custom entry name/author/version, 8MB daemon --- Common/Include/cfg/cfg_Config.hpp | 7 ++++++- Common/Source/cfg/cfg_Config.cpp | 29 ++++++++++++++++++++++++++--- SystemAppletQDaemon/Source/Main.cpp | 9 ++++++--- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/Common/Include/cfg/cfg_Config.hpp b/Common/Include/cfg/cfg_Config.hpp index d534cc0..41507bd 100644 --- a/Common/Include/cfg/cfg_Config.hpp +++ b/Common/Include/cfg/cfg_Config.hpp @@ -21,6 +21,11 @@ namespace cfg u64 app_id; // TitleType::Installed hb::TargetInput nro_target; // TitleType::Homebrew + + // Optional NACP params + std::string name; + std::string author; + std::string version; }; struct TitleFolder @@ -79,7 +84,7 @@ namespace cfg { std::string theme_name; bool system_title_override_enabled; - + bool viewer_usb_enabled; }; static constexpr u32 CurrentThemeFormatVersion = 0; diff --git a/Common/Source/cfg/cfg_Config.cpp b/Common/Source/cfg/cfg_Config.cpp index f04bc7c..6c3adb2 100644 --- a/Common/Source/cfg/cfg_Config.cpp +++ b/Common/Source/cfg/cfg_Config.cpp @@ -114,6 +114,15 @@ namespace cfg nsGetApplicationControlData(1, record.app_id, &cdata, sizeof(cdata), NULL); memcpy(&info.nacp, &cdata.nacp, sizeof(cdata.nacp)); } + if(!record.name.empty()) + { + for(u32 i = 0; i < 0x10; i++) strcpy(info.nacp.lang[i].name, record.name.c_str()); + } + if(!record.author.empty()) + { + for(u32 i = 0; i < 0x10; i++) strcpy(info.nacp.lang[i].author, record.author.c_str()); + } + if(!record.version.empty()) strcpy(info.nacp.version, record.version.c_str()); return info; } @@ -204,6 +213,7 @@ namespace cfg { Config cfg = {}; cfg.system_title_override_enabled = false; // Due to ban risk, have it disabled by default. + cfg.viewer_usb_enabled = false; // Do not enable this by default due to conflicts with USB homebrew SaveConfig(cfg); return cfg; } @@ -216,6 +226,7 @@ namespace cfg { cfg.theme_name = cfgjson.value("theme_name", ""); cfg.system_title_override_enabled = cfgjson.value("system_title_override_enabled", false); + cfg.viewer_usb_enabled = cfgjson.value("viewer_usb_enabled", false); } return cfg; } @@ -231,8 +242,10 @@ namespace cfg fs::DeleteFile(CFG_CONFIG_JSON); JSON j = JSON::object(); j["theme_name"] = cfg.theme_name; + j["system_title_override_enabled"] = cfg.system_title_override_enabled; + j["viewer_usb_enabled"] = cfg.viewer_usb_enabled; std::ofstream ofs(CFG_CONFIG_JSON); - ofs << j; + ofs << std::setw(4) << j; ofs.close(); } @@ -242,6 +255,10 @@ namespace cfg entry["type"] = record.title_type; entry["folder"] = record.sub_folder; + if(!record.name.empty()) entry["name"] = record.name; + if(!record.author.empty()) entry["author"] = record.author; + if(!record.version.empty()) entry["version"] = record.version; + // Prepare JSON path std::string basepath = Q_ENTRIES_PATH; std::string json = basepath; @@ -268,9 +285,8 @@ namespace cfg if(!record.json_name.empty()) json = basepath + "/" + record.json_name; if(fs::ExistsFile(json)) fs::DeleteFile(json); - std::ofstream ofs(json); - ofs << entry; + ofs << std::setw(4) << entry; ofs.close(); } @@ -568,6 +584,9 @@ namespace cfg rec.json_name = name; rec.app_id = appid; rec.title_type = (u32)TitleType::Installed; + rec.name = entry.value("name", ""); + rec.author = entry.value("author", ""); + rec.version = entry.value("version", ""); auto find = STL_FIND_IF(list.root.titles, tit, (tit.app_id == appid)); if(STL_FOUND(list.root.titles, find)) @@ -599,6 +618,10 @@ namespace cfg TitleRecord rec = {}; rec.json_name = name; rec.title_type = (u32)type; + rec.name = entry.value("name", ""); + rec.author = entry.value("author", ""); + rec.version = entry.value("version", ""); + std::string argv = nropath; auto tmpargv = entry.value("nro_argv", ""); if(!tmpargv.empty()) argv += " " + tmpargv; diff --git a/SystemAppletQDaemon/Source/Main.cpp b/SystemAppletQDaemon/Source/Main.cpp index 059a67a..e1c751d 100644 --- a/SystemAppletQDaemon/Source/Main.cpp +++ b/SystemAppletQDaemon/Source/Main.cpp @@ -9,14 +9,15 @@ #include #include #include +#include extern "C" { u32 __nx_applet_type = AppletType_SystemApplet; #ifdef Q_DEV - size_t __nx_heap_size = 0x3000000; // Dev uses 3x heap (48MB, still pretty low) for debug console + size_t __nx_heap_size = 0x3000000; // Dev 48MB (still lower than official qlaunch) for debug console #else - size_t __nx_heap_size = 0x1000000; + size_t __nx_heap_size = 0x800000;// 8MB - while official qlaunch uses 56MB! That's 48 extra MB for other applets #endif } @@ -472,7 +473,9 @@ int main() { qdaemon::Initialize(); qdaemon::LaunchDaemonServiceThread(); - qdaemon::LaunchForegroundThread(); + + auto config = cfg::EnsureConfig(); + if(config.viewer_usb_enabled) qdaemon::LaunchForegroundThread(); am::QDaemon_LaunchQMenu(am::QMenuStartMode::StartupScreen);