Migrate more config parsing to the new parser

This commit is contained in:
Henrik Rydgård committed 2026-07-20 16:50:34 +02:00
1 parent bd25962cbe
commit 650a59f964
3 files changed
+32 -34

No files matched your search

+10 -3
View File
@@ -133,8 +133,14 @@ static const CommandLineParam g_autoParams[] = {
{POFF(startScreen), CmdParamType::String, "start-screen", 0, "Start on a specific screen (e.g. 'gamesettings', 'touchscreentest')"},
{POFF(escapeExit), CmdParamType::Bool, "escape-exit", 0, "Escape key exits the application"},
{POFF(pauseMenuExit), CmdParamType::Bool, "pause-menu-exit", 0, "Change \"Exit to menu\" in pause menu to \"Exit\""},
{POFF(appendConfig), CmdParamType::String, "appendconfig", 0, "Merge config FILE into the current configuration"},
{POFF(root), CmdParamType::String, "root", 0, "Mount root directory"},
{POFF(stateToLoad), CmdParamType::String, "state", 0, "Load state from specified file"},
};
// NOTE: On Windows this prints nothing unfortunately, since PPSSPP is not a "console app".
// A fun trick we could do is AttachConsole(ATTACH_PARENT_PROCESS) which works at least from git bash and powershell, if we also use WriteConsole.
// However it's not exactly ideal.
static int printUsage(int argc, const char *argv[]) {
// NOTE: by convention, --help outputs to stdout,
// not to stderr, since it is intended output in this
@@ -175,9 +181,6 @@ static int printUsage(int argc, const char *argv[]) {
PRINT_STDOUT(" --scale FACTOR set scale\n");
PRINT_STDOUT(" --graphics=BACKEND use a different gpu backend\n");
PRINT_STDOUT(" options: gles, software, etc. (also opengl3.1, etc.)\n");
PRINT_STDOUT(" --appendconfig=FILE merge config FILE into the current configuration\n");
return 0;
}
@@ -350,6 +353,10 @@ void CommandLineOptions::ApplyToConfig() const {
g_logManager.SetAllLogLevels(logLevel.value());
}
if (root.has_value()) {
g_Config.DoNotSaveSetting(&g_Config.mountRoot);
g_Config.mountRoot = Path(root.value());
}
// Note: dpi is not applied here - it's platform-specific.
// Platforms should check cmdLineOptions.dpi.has_value() and handle accordingly.
}
+4
View File
@@ -26,6 +26,10 @@ struct CommandLineOptions {
std::optional<bool> escapeExit;
std::optional<bool> pauseMenuExit;
std::optional<std::string> appendConfig;
std::optional<std::string> root; // mount root, needs more explanation
std::optional<std::string> stateToLoad;
// SDL only: Option to force a specific OpenGL version (42="4.2",
// etc.; -1 means "try them all").
// Implemented as a workaround for https://github.com/hrydgard/ppsspp/issues/20687
+18 -31
View File
@@ -587,12 +587,8 @@ void NativeInit(int argc, const char *argv[], const CommandLineOptions &cmdLineO
cmdLineOptions.ApplyToConfig();
const char *fileToLog = nullptr;
Path stateToLoad;
bool gotBootFilename = false;
bool gotoGameSettings = false;
bool gotoTouchScreenTest = false;
bool gotoDeveloperTools = false;
boot_filename.clear();
// Parse command line
@@ -606,14 +602,6 @@ void NativeInit(int argc, const char *argv[], const CommandLineOptions &cmdLineO
if (cmdLineOptions.logLevel.has_value()) {
setLogLevel(cmdLineOptions.logLevel.value());
}
if (cmdLineOptions.startScreen.has_value()) {
if (equals(cmdLineOptions.startScreen.value(), "touchscreentest"))
gotoTouchScreenTest = true;
if (equals(cmdLineOptions.startScreen.value(), "gamesettings"))
gotoGameSettings = true;
if (equals(cmdLineOptions.startScreen.value(), "developertools"))
gotoDeveloperTools = true;
}
for (int i = 1; i < argc; i++) {
if (argv[i][0] == '-') {
@@ -630,16 +618,6 @@ void NativeInit(int argc, const char *argv[], const CommandLineOptions &cmdLineO
setLogLevel(static_cast<LogLevel>(std::atoi(argv[i] + strlen("--loglevel="))));
if (!strncmp(argv[i], "--log=", strlen("--log=")) && strlen(argv[i]) > strlen("--log="))
fileToLog = argv[i] + strlen("--log=");
if (!strncmp(argv[i], "--state=", strlen("--state=")) && strlen(argv[i]) > strlen("--state="))
stateToLoad = Path(argv[i] + strlen("--state="));
if (!strncmp(argv[i], "--root=", strlen("--root=")) && strlen(argv[i]) > strlen("--root=")) {
g_Config.DoNotSaveSetting(&g_Config.mountRoot);
g_Config.mountRoot = Path(argv[i] + strlen("--root="));
}
if (!strncmp(argv[i], "--appendconfig=", strlen("--appendconfig=")) && strlen(argv[i]) > strlen("--appendconfig=")) {
g_Config.SetAppendedConfigIni(Path(argv[i] + strlen("--appendconfig=")));
g_Config.LoadAppendedConfig();
}
break;
}
} else {
@@ -647,6 +625,11 @@ void NativeInit(int argc, const char *argv[], const CommandLineOptions &cmdLineO
}
}
if (cmdLineOptions.appendConfig.has_value()) {
g_Config.SetAppendedConfigIni(Path(cmdLineOptions.appendConfig.value()));
g_Config.LoadAppendedConfig();
}
// This parameter should be a boot filename. Only accept it if we
// don't already have one.
if (cmdLineOptions.bootFilename.has_value()) {
@@ -730,8 +713,8 @@ void NativeInit(int argc, const char *argv[], const CommandLineOptions &cmdLineO
g_BackgroundAudio.SFX().Init();
if (!boot_filename.empty() && stateToLoad.Valid()) {
SaveState::Load(stateToLoad, -1, &ShowMessageAfterSaveStateAction);
if (!boot_filename.empty() && cmdLineOptions.stateToLoad.has_value()) {
SaveState::Load(Path(cmdLineOptions.stateToLoad.value()), -1, &ShowMessageAfterSaveStateAction);
}
if (g_Config.bAchievementsEnable) {
@@ -751,14 +734,18 @@ void NativeInit(int argc, const char *argv[], const CommandLineOptions &cmdLineO
if (g_Config.memStickDirectory.empty()) {
INFO_LOG(Log::System, "No memstick directory! Asking for one to be configured.");
g_screenManager->switchScreen(new LogoScreen(AfterLogoScreen::MEMSTICK_SCREEN_INITIAL_SETUP));
} else if (gotoGameSettings) {
g_screenManager->switchScreen(new LogoScreen(AfterLogoScreen::TO_GAME_SETTINGS));
} else if (gotoTouchScreenTest) {
g_screenManager->switchScreen(new MainScreen());
} else if (cmdLineOptions.startScreen.has_value()) {
// Launch into specified start screen. This is useful for testing UI, more screens can be easily added here.
if (equals(cmdLineOptions.startScreen.value(), "touchscreentest")) {
g_screenManager->switchScreen(new MainScreen());
}
g_screenManager->push(new TouchTestScreen(Path()));
} else if (gotoDeveloperTools) {
g_screenManager->switchScreen(new MainScreen());
g_screenManager->push(new DeveloperToolsScreen(Path()));
if (equals(cmdLineOptions.startScreen.value(), "gamesettings")) {
g_screenManager->switchScreen(new LogoScreen(AfterLogoScreen::TO_GAME_SETTINGS));
} else if (equals(cmdLineOptions.startScreen.value(), "developertools")) {
g_screenManager->switchScreen(new MainScreen());
g_screenManager->push(new DeveloperToolsScreen(Path()));
}
} else if (skipLogo && !boot_filename.empty()) {
INFO_LOG(Log::System, "Launching EmuScreen with boot filename '%s'", boot_filename.c_str());
g_screenManager->switchScreen(new EmuScreen(boot_filename));