Browse Source

[qt, cmd] Document & fix some inconsistencies with command line arguments (#3104)

- documents command line arguments
- allows you to specify files starting with `-`
Signed-off-by: lizzie lizzie@eden-emu.dev

Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3104
Reviewed-by: Caio Oliveira <caiooliveirafarias0@gmail.com>
Reviewed-by: crueter <crueter@eden-emu.dev>
Co-authored-by: lizzie <lizzie@eden-emu.dev>
Co-committed-by: lizzie <lizzie@eden-emu.dev>
vk-fix-oom-force-maller-buffers
lizzie 3 weeks ago
committed by crueter
parent
commit
16ca7851c5
No known key found for this signature in database GPG Key ID: 425ACD2D4830EBC6
  1. 22
      docs/user/CommandLine.md
  2. 1
      docs/user/README.md
  3. 64
      src/yuzu/main_window.cpp

22
docs/user/CommandLine.md

@ -0,0 +1,22 @@
# User Handbook - Command Line
There are two main applications, an SDL2 based app (`eden-cli`) and a Qt based app (`eden`); both accept command line arguments.
## eden
- `./eden <path>`: Running with a single argument and nothing else, will make the emulator look for the given file and load it, this behaviour is similar to `eden-cli`; allows dragging and dropping games into the application.
- `-g <path>`: Alternate way to specify what to load, overrides. However let it be noted that arguments that use `-` will be treated as options/ignored, if your game, for some reason, starts with `-`, in order to safely handle it you may need to specify it as an argument.
- `-f`: Use fullscreen.
- `-u <number>`: Select the index of the user to load as.
- `-qlaunch`: Launch QLaunch.
- `-setup`: Launch setup applet.
## eden-cli
- `--debug/-d`: Enter debug mode, allow gdb stub at port `1234`
- `--config/-c`: Specify alternate configuration file.
- `--fullscreen/-f`: Set fullscreen.
- `--help/-h`: Display help.
- `--game/-g`: Specify the game to run.
- `--multiplayer/-m`: Specify multiplayer options.
- `--program/-p`: Specify the program arguments to pass (optional).
- `--user/-u`: Specify the user index.
- `--version/-v`: Display version and quit.

1
docs/user/README.md

@ -12,4 +12,5 @@ This handbook is primarily aimed at the end-user - baking useful knowledge for e
- **[Testing](Testing.md)** - **[Testing](Testing.md)**
- **[Data, savefiles and storage](Storage.md)** - **[Data, savefiles and storage](Storage.md)**
- **[Orphaned Profiles](Orphaned.md)** - **[Orphaned Profiles](Orphaned.md)**
- **[Command Line](CommandLine.md)**
- **[Native Application Development](Native.md)** - **[Native Application Development](Native.md)**

64
src/yuzu/main_window.cpp

@ -627,75 +627,43 @@ MainWindow::MainWindow(bool has_broken_vulkan)
bool has_gamepath = false; bool has_gamepath = false;
bool is_fullscreen = false; bool is_fullscreen = false;
for (int i = 1; i < args.size(); ++i) {
// Preserves drag/drop functionality // Preserves drag/drop functionality
if (args.size() == 2 && !args[1].startsWith(QChar::fromLatin1('-'))) { if (args.size() == 2 && !args[1].startsWith(QChar::fromLatin1('-'))) {
game_path = args[1]; game_path = args[1];
has_gamepath = true; has_gamepath = true;
break;
}
// Launch game in fullscreen mode
} else for (int i = 1; i < args.size(); ++i) {
if (args[i] == QStringLiteral("-f")) { if (args[i] == QStringLiteral("-f")) {
// Launch game in fullscreen mode
is_fullscreen = true; is_fullscreen = true;
continue;
}
} else if (args[i] == QStringLiteral("-u") && i < args.size() - 1) {
// Launch game with a specific user // Launch game with a specific user
if (args[i] == QStringLiteral("-u")) {
if (i >= args.size() - 1) {
continue;
}
if (args[i + 1].startsWith(QChar::fromLatin1('-'))) {
continue;
}
int user_arg_idx = ++i; int user_arg_idx = ++i;
bool argument_ok; bool argument_ok;
std::size_t selected_user = args[user_arg_idx].toUInt(&argument_ok); std::size_t selected_user = args[user_arg_idx].toUInt(&argument_ok);
if (!argument_ok) { if (!argument_ok) {
// try to look it up by username, only finds the first username that matches. // try to look it up by username, only finds the first username that matches.
const std::string user_arg_str = args[user_arg_idx].toStdString();
const auto user_idx = QtCommon::system->GetProfileManager().GetUserIndex(user_arg_str);
if (user_idx == std::nullopt) {
LOG_ERROR(Frontend, "Invalid user argument");
continue;
}
std::string const user_arg_str = args[user_arg_idx].toStdString();
auto const user_idx = QtCommon::system->GetProfileManager().GetUserIndex(user_arg_str);
if (user_idx != std::nullopt) {
selected_user = user_idx.value(); selected_user = user_idx.value();
}
if (!QtCommon::system->GetProfileManager().UserExistsIndex(selected_user)) {
LOG_ERROR(Frontend, "Selected user doesn't exist");
} else {
LOG_ERROR(Frontend, "Invalid user argument '{}'", user_arg_str);
continue; continue;
} }
Settings::values.current_user = static_cast<s32>(selected_user);
}
if (QtCommon::system->GetProfileManager().UserExistsIndex(selected_user)) {
Settings::values.current_user = s32(selected_user);
user_flag_cmd_line = true; user_flag_cmd_line = true;
continue;
} else {
LOG_ERROR(Frontend, "Selected user {} doesn't exist", selected_user);
} }
} else if (args[i] == QStringLiteral("-g") && i < args.size() - 1) {
// Launch game at path // Launch game at path
if (args[i] == QStringLiteral("-g")) {
if (i >= args.size() - 1) {
continue;
}
if (args[i + 1].startsWith(QChar::fromLatin1('-'))) {
continue;
}
game_path = args[++i]; game_path = args[++i];
has_gamepath = true; has_gamepath = true;
}
if (args[i] == QStringLiteral("-qlaunch"))
} else if (args[i] == QStringLiteral("-qlaunch"))
should_launch_qlaunch = true; should_launch_qlaunch = true;
if (args[i] == QStringLiteral("-setup"))
else if (args[i] == QStringLiteral("-setup"))
should_launch_setup = true; should_launch_setup = true;
} }

Loading…
Cancel
Save