mirror of
https://github.com/cemu-project/Cemu.git
synced 2026-06-25 21:24:59 -06:00
Add command line parameters to make Cemu more useful for running tests (#1959)
This commit is contained in:
parent
f3d5788f0c
commit
a3d6395ed7
@ -685,6 +685,22 @@ namespace CafeSystem
|
||||
fsc_unmount("/cemuBossStorage/", FSC_PRIORITY_BASE);
|
||||
}
|
||||
|
||||
void MountExtras()
|
||||
{
|
||||
for (const auto& [host_path, emulatedPath] : LaunchSettings::CosMounts())
|
||||
{
|
||||
FSCDeviceHostFS_Mount(boost::nowide::narrow(emulatedPath), _pathToUtf8(host_path), FSC_PRIORITY_BASE);
|
||||
}
|
||||
}
|
||||
|
||||
void UnmountExtras()
|
||||
{
|
||||
for (const auto& [_, emulatedPath] : LaunchSettings::CosMounts())
|
||||
{
|
||||
fsc_unmount(boost::nowide::narrow(emulatedPath), FSC_PRIORITY_BASE);
|
||||
}
|
||||
}
|
||||
|
||||
PREPARE_STATUS_CODE LoadAndMountForegroundTitle(TitleId titleId)
|
||||
{
|
||||
cemuLog_log(LogType::Force, "Mounting title {:016x}", (uint64)titleId);
|
||||
@ -838,6 +854,7 @@ namespace CafeSystem
|
||||
if (r != PREPARE_STATUS_CODE::SUCCESS)
|
||||
return r;
|
||||
InitVirtualMlcStorage();
|
||||
MountExtras();
|
||||
return PREPARE_STATUS_CODE::SUCCESS;
|
||||
}
|
||||
|
||||
@ -881,6 +898,7 @@ namespace CafeSystem
|
||||
// load executable
|
||||
PrepareExecutable();
|
||||
InitVirtualMlcStorage();
|
||||
MountExtras();
|
||||
return PREPARE_STATUS_CODE::SUCCESS;
|
||||
}
|
||||
|
||||
@ -960,6 +978,9 @@ namespace CafeSystem
|
||||
|
||||
std::string GetForegroundTitleArgStr()
|
||||
{
|
||||
auto optional_arguments = LaunchSettings::CosArgstr();
|
||||
if (optional_arguments.has_value())
|
||||
return *optional_arguments;
|
||||
if (sLaunchModeIsStandalone)
|
||||
return "";
|
||||
auto& update = sGameInfo_ForegroundTitle.GetUpdate();
|
||||
@ -1044,24 +1065,26 @@ namespace CafeSystem
|
||||
{
|
||||
if(!sSystemRunning)
|
||||
return;
|
||||
coreinit::OSSchedulerEnd();
|
||||
Latte_Stop();
|
||||
// reset Cafe OS userspace modules
|
||||
snd_core::reset();
|
||||
coreinit::OSAlarm_Shutdown();
|
||||
GX2::_GX2DriverReset();
|
||||
nn::save::ResetToDefaultState();
|
||||
coreinit::__OSDeleteAllActivePPCThreads();
|
||||
RPLLoader_UnloadAll();
|
||||
coreinit::OSSchedulerEnd();
|
||||
Latte_Stop();
|
||||
// reset Cafe OS userspace modules
|
||||
snd_core::reset();
|
||||
coreinit::OSAlarm_Shutdown();
|
||||
GX2::_GX2DriverReset();
|
||||
nn::save::ResetToDefaultState();
|
||||
coreinit::__OSDeleteAllActivePPCThreads();
|
||||
RPLLoader_UnloadAll();
|
||||
for(auto it = s_iosuModules.rbegin(); it != s_iosuModules.rend(); ++it)
|
||||
(*it)->TitleStop();
|
||||
// reset Cemu subsystems
|
||||
PPCRecompiler_Shutdown();
|
||||
GraphicPack2::Reset();
|
||||
UnmountCurrentTitle();
|
||||
MlcStorageUnmountAllTitles();
|
||||
UnmountBaseDirectories();
|
||||
DestroyMemorySpace();
|
||||
// reset Cemu subsystems
|
||||
PPCRecompiler_Shutdown();
|
||||
GraphicPack2::Reset();
|
||||
UnmountCurrentTitle();
|
||||
UnmountExtras();
|
||||
MlcStorageUnmountAllTitles();
|
||||
UnmountBaseDirectories();
|
||||
DestroyMemorySpace();
|
||||
LaunchSettings::ClearCosArgstr();
|
||||
sSystemRunning = false;
|
||||
}
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include "Cafe/OS/libs/coreinit/coreinit_OSScreen.h"
|
||||
#include "Cafe/CafeSystem.h"
|
||||
#include "Cafe/Filesystem/fsc.h"
|
||||
#include "config/LaunchSettings.h"
|
||||
#include <pugixml.hpp>
|
||||
|
||||
namespace coreinit
|
||||
@ -544,6 +545,7 @@ namespace coreinit
|
||||
}
|
||||
|
||||
std::mutex sCafeConsoleMutex;
|
||||
bool s_forwardConsoleLogs;
|
||||
|
||||
void WriteCafeConsole(CafeLogType cafeLogType, const char* msg, sint32 len)
|
||||
{
|
||||
@ -556,6 +558,13 @@ namespace coreinit
|
||||
cafeLogBuffer.lineLength = 0;
|
||||
};
|
||||
|
||||
if (s_forwardConsoleLogs) {
|
||||
if (cafeLogType == CafeLogType::OSCONSOLE) {
|
||||
fwrite(msg, 1, len, stdout);
|
||||
} else {
|
||||
fwrite(msg, 1, len, stderr);
|
||||
}
|
||||
}
|
||||
while (len)
|
||||
{
|
||||
char c = *msg;
|
||||
@ -846,6 +855,7 @@ namespace coreinit
|
||||
{
|
||||
s_currentTitleId = CafeSystem::GetForegroundTitleId();
|
||||
s_sdkVersion = CafeSystem::GetForegroundTitleSDKVersion();
|
||||
s_forwardConsoleLogs = LaunchSettings::ForwardConsoleLogging();
|
||||
s_transitionToBackground = false;
|
||||
s_transitionToForeground = false;
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ bool LaunchSettings::HandleCommandline(const std::vector<std::wstring>& args)
|
||||
#endif
|
||||
|
||||
("game,g", po::wvalue<std::wstring>(), "Path of game to launch")
|
||||
("title-id,t", po::value<std::string>(), "Title ID of the title to be launched (overridden by --game)")
|
||||
("title-id,t", po::value<std::string>(), "Title ID of the title to be launched (overridden by --game)")
|
||||
("mlc,m", po::wvalue<std::wstring>(), "Custom mlc folder location")
|
||||
|
||||
("fullscreen,f", po::value<bool>()->implicit_value(true), "Launch games in fullscreen mode")
|
||||
@ -71,6 +71,10 @@ bool LaunchSettings::HandleCommandline(const std::vector<std::wstring>& args)
|
||||
|
||||
("account,a", po::value<std::string>(), "Persistent id of account")
|
||||
|
||||
("cos-mounts", po::wvalue<std::vector<std::wstring>>()->composing(), "A series of mounts in the form of: (path on host:path within emulated system, e.g. `/tmp:/vol/temporary/`)")
|
||||
("forward-console-logging", "Forward OSReport, OSConsoleWrite, etc. to stdout/stderr.")
|
||||
("cos-argstr", po::value<std::string>(), "A custom argstr used to override to the arguments to the first RPX that is launched, will be unset after the first launch.")
|
||||
|
||||
("force-interpreter", po::value<bool>()->implicit_value(true), "Force interpreter CPU emulation, disables recompiler. Useful for debugging purposes where you want to get accurate memory accesses and stack traces.")
|
||||
("force-multicore-interpreter", po::value<bool>()->implicit_value(true), "Force multi-core interpreter CPU emulation, disables recompiler. Only useful for getting stack traces, but slightly faster than the single-core interpreter mode.")
|
||||
("enable-gdbstub", po::value<bool>()->implicit_value(true), "Enable GDB stub to debug executables inside Cemu using an external debugger");
|
||||
@ -189,6 +193,30 @@ bool LaunchSettings::HandleCommandline(const std::vector<std::wstring>& args)
|
||||
if (vm.count("enable-gdbstub"))
|
||||
s_enable_gdbstub = vm["enable-gdbstub"].as<bool>();
|
||||
|
||||
if (vm.count("forward-console-logging"))
|
||||
{
|
||||
requireConsole();
|
||||
s_forward_console_logging = true;
|
||||
}
|
||||
|
||||
if (vm.count("cos-argstr"))
|
||||
s_cos_argstr = vm["cos-argstr"].as<std::string>();
|
||||
|
||||
if (vm.count("cos-mounts"))
|
||||
{
|
||||
for (const auto& argument : vm["cos-mounts"].as<std::vector<std::wstring>>())
|
||||
{
|
||||
size_t colon_location = argument.find(L':');
|
||||
if (colon_location == std::wstring::npos)
|
||||
{
|
||||
std::cerr << "Argument for a mount expects to be in the format: `path on host:path in emulated system`, was not: `" << boost::nowide::narrow(argument) << "`\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
s_cos_mounts[argument.substr(0, colon_location)] = argument.substr(colon_location + 1);
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring extract_path, log_path;
|
||||
std::string output_path;
|
||||
if (vm.count("extract"))
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
class LaunchSettings
|
||||
{
|
||||
@ -16,7 +17,7 @@ public:
|
||||
static bool HandleCommandline(const std::vector<std::wstring>& args);
|
||||
|
||||
static std::optional<fs::path> GetLoadFile() { return s_load_game_file; }
|
||||
static std::optional<uint64> GetLoadTitleID() {return s_load_title_id;}
|
||||
static std::optional<uint64> GetLoadTitleID() {return s_load_title_id;}
|
||||
static std::optional<fs::path> GetMLCPath() { return s_mlc_path; }
|
||||
|
||||
static std::optional<bool> RenderUpsideDownEnabled() { return s_render_upside_down; }
|
||||
@ -24,6 +25,11 @@ public:
|
||||
|
||||
static bool Verbose() { return s_verbose; }
|
||||
|
||||
static bool ForwardConsoleLogging() { return s_forward_console_logging; }
|
||||
static std::optional<std::string> CosArgstr() { return s_cos_argstr; }
|
||||
static void ClearCosArgstr() { s_cos_argstr.reset(); }
|
||||
static std::unordered_map<fs::path, std::wstring>& CosMounts() { return s_cos_mounts; }
|
||||
|
||||
static bool GDBStubEnabled() { return s_enable_gdbstub; }
|
||||
static bool NSightModeEnabled() { return s_nsight_mode; }
|
||||
|
||||
@ -37,14 +43,18 @@ public:
|
||||
|
||||
private:
|
||||
inline static std::optional<fs::path> s_load_game_file{};
|
||||
inline static std::optional<uint64> s_load_title_id{};
|
||||
inline static std::optional<uint64> s_load_title_id{};
|
||||
inline static std::optional<fs::path> s_mlc_path{};
|
||||
|
||||
inline static std::optional<bool> s_render_upside_down{};
|
||||
inline static std::optional<bool> s_fullscreen{};
|
||||
|
||||
inline static bool s_verbose = false;
|
||||
|
||||
|
||||
inline static bool s_forward_console_logging = false;
|
||||
inline static std::optional<std::string> s_cos_argstr{};
|
||||
inline static std::unordered_map<fs::path, std::wstring> s_cos_mounts{};
|
||||
|
||||
inline static bool s_enable_gdbstub = false;
|
||||
inline static bool s_nsight_mode = false;
|
||||
|
||||
@ -59,5 +69,3 @@ private:
|
||||
|
||||
static bool ExtractorTool(std::wstring_view wud_path, std::string_view output_path, std::wstring_view log_path);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user