Browse Source

[frontend] allow to specify input profile name for first player on command line

Signed-off-by: lizzie <lizzie@eden-emu.dev>
lizzie/input-profile-cmdline
lizzie 3 days ago
parent
commit
2ea37c1142
  1. 2
      docs/user/CommandLine.md
  2. 3
      src/yuzu/main_window.cpp
  3. 15
      src/yuzu_cmd/yuzu.cpp

2
docs/user/CommandLine.md

@ -7,6 +7,7 @@ There are two main applications, an SDL2 based app (`eden-cli`) and a Qt based a
- `-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. - `-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. - `-f`: Use fullscreen.
- `-u <number>`: Select the index of the user to load as. - `-u <number>`: Select the index of the user to load as.
- `-input-profile <name>`: Specifies input profile name to use (for player #0 only).
- `-qlaunch`: Launch QLaunch. - `-qlaunch`: Launch QLaunch.
- `-setup`: Launch setup applet. - `-setup`: Launch setup applet.
@ -20,3 +21,4 @@ There are two main applications, an SDL2 based app (`eden-cli`) and a Qt based a
- `--program/-p`: Specify the program arguments to pass (optional). - `--program/-p`: Specify the program arguments to pass (optional).
- `--user/-u`: Specify the user index. - `--user/-u`: Specify the user index.
- `--version/-v`: Display version and quit. - `--version/-v`: Display version and quit.
- `--input-profile/-i`: Specifies input profile name to use (for player #0 only).

3
src/yuzu/main_window.cpp

@ -665,6 +665,9 @@ MainWindow::MainWindow(bool has_broken_vulkan)
// Launch game at path // Launch game at path
game_path = args[++i]; game_path = args[++i];
has_gamepath = true; has_gamepath = true;
} else if (args[i] == QStringLiteral("-input-profile") && i < args.size() - 1) {
auto& players = Settings::values.players.GetValue();
players[0].profile_name = args[++i].toStdString();
} else if (args[i] == QStringLiteral("-qlaunch")) { } else if (args[i] == QStringLiteral("-qlaunch")) {
should_launch_qlaunch = true; should_launch_qlaunch = true;
} else if (args[i] == QStringLiteral("-setup")) { } else if (args[i] == QStringLiteral("-setup")) {

15
src/yuzu_cmd/yuzu.cpp

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2014 Citra Emulator Project // SPDX-FileCopyrightText: 2014 Citra Emulator Project
@ -208,6 +208,7 @@ int main(int argc, char** argv) {
std::string nickname{}; std::string nickname{};
std::string password{}; std::string password{};
std::string address{}; std::string address{};
std::string input_profile{};
u16 port = Network::DefaultRoomPort; u16 port = Network::DefaultRoomPort;
static struct option long_options[] = { static struct option long_options[] = {
@ -221,12 +222,13 @@ int main(int argc, char** argv) {
{"program", optional_argument, 0, 'p'}, {"program", optional_argument, 0, 'p'},
{"user", required_argument, 0, 'u'}, {"user", required_argument, 0, 'u'},
{"version", no_argument, 0, 'v'}, {"version", no_argument, 0, 'v'},
{"input-profile", no_argument, 0, 'i'},
{0, 0, 0, 0}, {0, 0, 0, 0},
// clang-format on // clang-format on
}; };
while (optind < argc) { while (optind < argc) {
int arg = getopt_long(argc, argv, "g:fhvp::c:u:d:", long_options, &option_index);
int arg = getopt_long(argc, argv, "g:fhvcip::c:u:d:", long_options, &option_index);
if (arg != -1) { if (arg != -1) {
switch (char(arg)) { switch (char(arg)) {
case 'd': case 'd':
@ -245,6 +247,10 @@ int main(int argc, char** argv) {
case 'g': case 'g':
filepath = std::string(optarg); filepath = std::string(optarg);
break; break;
case 'i': {
input_profile = std::string(optarg);
break;
}
case 'm': { case 'm': {
use_multiplayer = true; use_multiplayer = true;
const std::string str_arg(optarg); const std::string str_arg(optarg);
@ -311,6 +317,11 @@ int main(int argc, char** argv) {
Settings::values.program_args = program_args; Settings::values.program_args = program_args;
} }
if (!input_profile.empty()) {
auto& players = Settings::values.players.GetValue();
players[0].profile_name = input_profile;
}
if (selected_user.has_value()) { if (selected_user.has_value()) {
Settings::values.current_user = std::clamp(*selected_user, 0, 7); Settings::values.current_user = std::clamp(*selected_user, 0, 7);
} }

Loading…
Cancel
Save