Skip to content

Commit

Permalink
Qt: Add Portable Mode launch argument
Browse files Browse the repository at this point in the history
  • Loading branch information
kamfretoz committed Jan 23, 2025
1 parent df7646f commit de95354
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions pcsx2-qt/QtHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2040,6 +2040,7 @@ void QtHost::PrintCommandLineHelp(const std::string_view progname)
std::fprintf(stderr, " -version: Displays version information and exits.\n");
std::fprintf(stderr, " -batch: Enables batch mode (exits after shutting down).\n");
std::fprintf(stderr, " -nogui: Hides main window while running (implies batch mode).\n");
std::fprintf(stderr, " -portable: Force enable portable mode to store data in local PCSX2 path instead of the current user's Documents path.\n");
std::fprintf(stderr, " -elf <file>: Overrides the boot ELF with the specified filename.\n");
std::fprintf(stderr, " -gameargs <string>: passes the specified quoted space-delimited string of launch arguments.\n");
std::fprintf(stderr, " -disc <path>: Uses the specified host DVD drive as a source.\n");
Expand Down Expand Up @@ -2111,6 +2112,11 @@ bool QtHost::ParseCommandLineOptions(const QStringList& args, std::shared_ptr<VM
s_nogui_mode = true;
continue;
}
else if (CHECK_ARG(QStringLiteral("-portable")))
{
EmuConfig.IsPortableMode = true;
continue;
}
else if (CHECK_ARG(QStringLiteral("-fastboot")))
{
AutoBoot(autoboot)->fast_boot = true;
Expand Down
1 change: 1 addition & 0 deletions pcsx2/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,7 @@ struct Pcsx2Config
std::string CurrentIRX;
std::string CurrentGameArgs;
AspectRatioType CurrentAspectRatio = AspectRatioType::RAuto4_3_3_2;
bool IsPortableMode = false;

Pcsx2Config();
void LoadSave(SettingsWrapper& wrap);
Expand Down
12 changes: 10 additions & 2 deletions pcsx2/Pcsx2Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2036,6 +2036,7 @@ void Pcsx2Config::CopyRuntimeConfig(Pcsx2Config& cfg)
CurrentIRX = std::move(cfg.CurrentIRX);
CurrentGameArgs = std::move(cfg.CurrentGameArgs);
CurrentAspectRatio = cfg.CurrentAspectRatio;
IsPortableMode = cfg.IsPortableMode;

for (u32 i = 0; i < sizeof(Mcd) / sizeof(Mcd[0]); i++)
{
Expand Down Expand Up @@ -2122,8 +2123,15 @@ bool EmuFolders::SetResourcesDirectory()

bool EmuFolders::ShouldUsePortableMode()
{
// Check whether portable.ini exists in the program directory.
return FileSystem::FileExists(Path::Combine(AppRoot, "portable.ini").c_str()) || FileSystem::FileExists(Path::Combine(AppRoot, "portable.txt").c_str());
// Check whether portable.ini/txt exists in the program directory or the `-portable` launch arguments have been passed.
if (FileSystem::FileExists(Path::Combine(AppRoot, "portable.ini").c_str()) ||
FileSystem::FileExists(Path::Combine(AppRoot, "portable.txt").c_str()) ||
EmuConfig.IsPortableMode)
{
return true;
}

return false;
}

std::string EmuFolders::GetPortableModePath()
Expand Down

0 comments on commit de95354

Please sign in to comment.