diff --git a/Core/CmdLine.cpp b/Core/CmdLine.cpp index 44801d626a..827af1d693 100644 --- a/Core/CmdLine.cpp +++ b/Core/CmdLine.cpp @@ -151,14 +151,11 @@ static ParseParamResult ParseParameterStr(int argc, const char *argv[], size_t & } // Check for boolean/inverse-boolean parameter - these don't take a separate param value. - if (param.type == CmdParamType::Bool && equals(arg, std::string("--") + param.longName)) { + // SetValue() does the inverting, so both get "true". + if ((param.type == CmdParamType::Bool || param.type == CmdParamType::BoolInverse) && equals(arg, std::string("--") + param.longName)) { ParseParamResult result = SetValue(options, param, "true"); i++; // Skip --param return result; - } else if (param.type == CmdParamType::BoolInverse && equals(arg, std::string("--") + param.longName)) { - ParseParamResult result = SetValue(options, param, "false"); - i++; // Skip --param - return result; } // Check for long form with space: --param value @@ -202,6 +199,7 @@ static const CommandLineParam g_autoParams[] = { {POFF(compare), CmdParamType::Bool, "compare", 'c', "Enable comparison mode", CmdLineMode::Headless}, {POFF(bench), CmdParamType::Bool, "bench", 'b', "Enable benchmark mode", CmdLineMode::Headless}, {POFF(oldAtrac), CmdParamType::Bool, "old-atrac", '\0', "Use old ATRAC decoder"}, + {POFF(memStickInserted), CmdParamType::BoolInverse, "no-memstick", '\0', "Run with the memory stick removed"}, {POFF(log), CmdParamType::String, "log", '\0', "Output log to FILE", CmdLineMode::Application}, {POFF(enableLogging), CmdParamType::Bool, "log", '\0', "Full log output, not just emulated printfs", CmdLineMode::Headless}, {POFF(screenshotFilename), CmdParamType::String, "screenshot", '\0', "Compare rendered output against a reference screenshot FILE", CmdLineMode::Headless}, @@ -554,6 +552,10 @@ void CommandLineOptions::ApplyToConfig() const { g_Config.bAutoRun = false; g_Config.bSaveSettings = false; } + if (memStickInserted.has_value()) { + g_Config.bMemStickInserted = memStickInserted.value(); + g_Config.DoNotSaveSetting(&g_Config.bMemStickInserted); + } if (escapeExit.has_value()) { g_Config.bPauseExitsEmulator = escapeExit.value(); } diff --git a/Core/CmdLine.h b/Core/CmdLine.h index e0b7e03148..18e882449e 100644 --- a/Core/CmdLine.h +++ b/Core/CmdLine.h @@ -43,6 +43,8 @@ struct CommandLineOptions { std::optional startScreen; std::optional escapeExit; + // Run as if no memory stick were inserted. + std::optional memStickInserted; std::optional pauseMenuExit; // Enables the WebSocket debugger on startup, on this port (0 = pick automatically). diff --git a/unittest/UnitTest.cpp b/unittest/UnitTest.cpp index 3a55f8191a..51d92272a3 100644 --- a/unittest/UnitTest.cpp +++ b/unittest/UnitTest.cpp @@ -3029,6 +3029,21 @@ bool TestCmdLine() { EXPECT_EQ_INT(options.timeoutWall.value_or(0), 4); EXPECT_EQ_INT(options.timeoutEmulated.value_or(0), 5); } + // Inverse booleans: --windowed turns fullscreen off, and --no-memstick removes the stick. + { + const char *argv[] = { + "ppsspp", + "--windowed", + "--no-memstick", + }; + int argc = ARRAY_SIZE(argv); + CommandLineOptions options; + options.Parse(argc, argv, CmdLineMode::Application); + EXPECT_TRUE(options.fullscreen.has_value()); + EXPECT_FALSE(options.fullscreen.value_or(true)); + EXPECT_TRUE(options.memStickInserted.has_value()); + EXPECT_FALSE(options.memStickInserted.value_or(true)); + } // Test GL version override { const char *argv[] = {