Skip to content

Play your Steam library's Windows games on a jailbroken PS5.

C++

Add launcher mode to Game settings and Run once

Leonardo Lobatoa52a47316825
diff --git a/src/app/preferences.cpp b/src/app/preferences.cpp
index 861cc89..6f927ba 100644
--- a/src/app/preferences.cpp
+++ b/src/app/preferences.cpp
@@ -17,12 +17,13 @@ std::string ToString(const Bytes& bytes) {
return std::string(bytes.begin(), bytes.end());
}
-// Versions 8 to 10: one "key=value" line per field, in this order, each ending in a newline. Version 9 adds
+// Versions 8 to 11: one "key=value" line per field, in this order, each ending in a newline. Version 9 adds
// web_access (on in older files), version 10 content_language (English in older files, which is what they
-// downloaded).
-constexpr const char* kVersionTenKeys[] = {"reduce_motion", "title_store_suffix", "cloud_saves_auto",
+// downloaded), version 11 the launcher dialogs' "Don't show this again" (shown in older files).
+constexpr const char* kKeys[] = {"reduce_motion", "title_store_suffix", "cloud_saves_auto",
"steam_sign_in_password", "downloads_slow_network", "steam_stay_signed_in",
- "beta_updates", "download_server", "web_access", "content_language"};
+ "beta_updates", "download_server", "web_access", "content_language",
+ "hide_run_once_help", "hide_launcher_help"};
bool ParseFlag(const std::string& value, bool* flag) {
if (value != "0" && value != "1") return false;
@@ -42,9 +43,9 @@ bool ParseKeyed(const std::string& serialized, int version, Preferences* prefere
if (serialized.compare(0, header.size(), header) != 0 || serialized.back() != '\n') return false;
std::vector<std::string> values;
std::size_t start = header.size();
- const std::size_t count = std::size(kVersionTenKeys) - static_cast<std::size_t>(10 - version);
+ const std::size_t count = std::size(kKeys) - static_cast<std::size_t>(version >= 11 ? 0 : 2 + (10 - version));
for (std::size_t field = 0; field < count; ++field) {
- const char* key = kVersionTenKeys[field];
+ const char* key = kKeys[field];
const std::string prefix = std::string(key) + "=";
const auto end = serialized.find('\n', start);
if (end == std::string::npos || serialized.compare(start, prefix.size(), prefix) != 0) return false;
@@ -63,6 +64,8 @@ bool ParseKeyed(const std::string& serialized, int version, Preferences* prefere
if (!steam::IsContentLanguage(values[9])) return false;
parsed.content_language = values[9];
}
+ if (version >= 11 && (!ParseFlag(values[10], &parsed.hide_run_once_help) || !ParseFlag(values[11], &parsed.hide_launcher_help)))
+ return false;
// A host the current rule refuses is dropped without resetting unrelated preferences.
if (ValidDownloadServer(values[7])) parsed.download_server = values[7];
*preferences = std::move(parsed);
@@ -90,7 +93,7 @@ PreferencesLoadResult PreferencesStore::Load() const {
std::string serialized = ToString(read.value());
Preferences keyed;
- if (ParseKeyed(serialized, 10, &keyed) || ParseKeyed(serialized, 9, &keyed) || ParseKeyed(serialized, 8, &keyed))
+ if (ParseKeyed(serialized, 11, &keyed) || ParseKeyed(serialized, 10, &keyed) || ParseKeyed(serialized, 9, &keyed) || ParseKeyed(serialized, 8, &keyed))
return PreferencesLoadResult{std::move(keyed), PreferencesLoadStatus::kLoaded, std::string()};
bool beta_updates = false;
if (serialized.rfind("version=7\n", 0) == 0) {
@@ -191,7 +194,7 @@ Result<void> PreferencesStore::Save(const Preferences& preferences) const {
if(!ready.ok()) return ready;
// Never write a host that cannot be read back, including embedded newlines.
const std::string server = ValidDownloadServer(preferences.download_server) ? preferences.download_server : std::string();
- const std::string text = std::string("version=10\nreduce_motion=") + (preferences.reduce_motion ? "1" : "0") +
+ const std::string text = std::string("version=11\nreduce_motion=") + (preferences.reduce_motion ? "1" : "0") +
"\ntitle_store_suffix=" + (preferences.title_store_suffix ? "1" : "0") +
"\ncloud_saves_auto=" + (preferences.cloud_saves_auto ? "1" : "0") +
"\nsteam_sign_in_password=" + (preferences.steam_sign_in_password ? "1" : "0") +
@@ -203,7 +206,8 @@ Result<void> PreferencesStore::Save(const Preferences& preferences) const {
(steam::IsContentLanguage(preferences.content_language)
? preferences.content_language
: std::string(steam::kDefaultContentLanguage)) +
- "\n";
+ "\nhide_run_once_help=" + (preferences.hide_run_once_help ? "1" : "0") +
+ "\nhide_launcher_help=" + (preferences.hide_launcher_help ? "1" : "0") + "\n";
return storage_.WriteAtomic(kPreferencesPath, Bytes(text.begin(), text.end()));
}
diff --git a/src/app/preferences.h b/src/app/preferences.h
index 8eead9d..649dd23 100644
--- a/src/app/preferences.h
+++ b/src/app/preferences.h
@@ -32,6 +32,10 @@ struct Preferences {
// ("german", "koreana"). Steam ships localisations as separate depots; a game that has none
// in this language is installed in English, as every game was before this could be chosen.
std::string content_language = "english";
+ // "Don't show this again" on the dialogs that explain launcher mode: Run a program once, and turning on
+ // Start through a launcher. Separate, because the second warns about other games.
+ bool hide_run_once_help = false;
+ bool hide_launcher_help = false;
};
enum class PreferencesLoadStatus {
diff --git a/src/homebrew/runtime_host.cpp b/src/homebrew/runtime_host.cpp
index d473627..81fb012 100644
--- a/src/homebrew/runtime_host.cpp
+++ b/src/homebrew/runtime_host.cpp
@@ -1538,7 +1538,7 @@ rt::KitCapabilities RuntimeHost::TitleKit(const Composition& c, const rt::Runtim
if (!c.kit) return {};
const auto kit = rt::KitCapabilitiesFromManifest(c.kit->capabilities, true);
// The title's markers are read only when the kit has something an older runtime would refuse.
- return kit.display_120hz || kit.profile_version_2 || kit.input_rumble || kit.display_framegen
+ return kit.display_120hz || kit.profile_version_2 || kit.input_rumble || kit.display_framegen || kit.launcher_mode
? rt::KitForTitleRuntime(kit, TitleRuntimeCurrent(c, record))
: kit;
}
@@ -1866,17 +1866,24 @@ std::string RuntimeHost::PublishSavedSettings(Composition& c, const rt::RuntimeI
// keeps that profile until the next publication without one puts the saved settings back (RuntimeInstall::
// setup_program), whatever their revision.
const bool restoring = setup_program.empty() && !record.setup_program.empty();
+ // With launcher mode the game's own controls stay for the game the program starts, and the program gets the
+ // launcher preset.
+ const bool run_launcher_mode = !setup_program.empty() && TitleKit(c, record).launcher_mode;
if (!setup_program.empty()) {
auto& overrides = saved.overrides;
- std::erase_if(overrides, [](const auto& entry) {
+ std::erase_if(overrides, [&](const auto& entry) {
static const std::set<std::string> program = {"program", "architecture", "program_folder", "program_arguments",
"start_check"};
- return program.count(entry.first) || entry.first.rfind("button.", 0) == 0;
+ return program.count(entry.first) || (!run_launcher_mode && entry.first.rfind("button.", 0) == 0);
});
overrides["launch_option"] = rt::kProgramEntryId;
overrides["program"] = setup_program;
- overrides["controller_preset"] = "mouse";
- for (const auto& [id, value] : rt::ControllerPresetInputs().at("mouse")) overrides[id] = value;
+ if (run_launcher_mode) {
+ overrides["start_through_launcher"] = "on";
+ } else {
+ overrides["controller_preset"] = "mouse";
+ for (const auto& [id, value] : rt::ControllerPresetInputs().at("mouse")) overrides[id] = value;
+ }
}
// A game whose folder moved (RuntimeInstall::moved_from) is published again at its revision, so
// its descriptor, profile and dxvk.conf name the new folder.
@@ -1912,14 +1919,15 @@ std::string RuntimeHost::PublishSavedSettings(Composition& c, const rt::RuntimeI
if (!saved.overrides.count("graphics") && !recipe->locked.count("graphics") &&
rt::ProgramDrawsWithOpenGLOnly(HostPath(record.install_path).string(), setup_program))
run_recipe->graphics = "opengl";
- std::erase_if(run_recipe->defaults, button);
- std::erase_if(run_recipe->locked, [](const std::string& id) {
+ if (!run_launcher_mode) std::erase_if(run_recipe->defaults, button);
+ std::erase_if(run_recipe->locked, [&](const std::string& id) {
+ if (run_launcher_mode) return id == "launch_option" || id == "program" || id == "start_through_launcher";
static const std::set<std::string> controls = {"launch_option", "program", "controller_preset", "controller",
"pointer_stick", "pointer_speed"};
return controls.count(id) || id.rfind("button.", 0) == 0;
});
recipe = &*run_recipe;
- if (preset) {
+ if (preset && !run_launcher_mode) {
run_preset = *preset;
std::erase_if(run_preset->settings, button);
preset = &*run_preset;
diff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cpp
index 40591b8..d0987e1 100644
--- a/src/homebrew/simulation.cpp
+++ b/src/homebrew/simulation.cpp
@@ -514,7 +514,7 @@ std::string action_label(const std::string& key) {
static const std::map<std::string, std::string> labels = {
{"cancel", "Cancel"}, {"confirm-destructive", "Confirm"}, {"ready-later", "Later"}, {"alert-ok", "OK"}, {"alert-settings", "Game settings"}, {"runtime-cleanup-confirm", "Clean up"}, {"quit-to-home", "Play"}, {"favorite", "Favorite"},
{"collection", "Collections"}, {"note", "Compatibility and note"}, {"verify", "Verify files"},
- {"uninstall", "Uninstall…"}, {"import-remove", "Remove from library…"}, {"uninstall-delete-saves", "Delete saves too"}, {"logs", "Open logs"}, {"logs-back", "Back"},
+ {"uninstall", "Uninstall…"}, {"import-remove", "Remove from library…"}, {"uninstall-delete-saves", "Delete saves too"}, {"run-once-dont-show", "Don't show again"}, {"launcher-help-dont-show", "Don't show again"}, {"launcher-help-on", "Turn on"}, {"logs", "Open logs"}, {"logs-back", "Back"},
{"logs-pick", "Logs"}, {"log-install", "Install log"}, {"log-auth", "Sign-in log"},
{"log-launch", "Launch log"}, {"log-cloud", "Cloud saves log"}, {"logs-refresh", "Refresh"},
{"cloud-sync", "Cloud saves"}, {"cloud-choose", "Cloud saves"}, {"cloud-use-cloud", "Use Cloud saves"},
@@ -2209,6 +2209,22 @@ std::vector<GameId> Simulation::TakeActivityRequests() {
return requests;
}
+void Simulation::start_setup_program() {
+ const auto id = state_.navigation.selected_game_id;
+ std::string refusal;
+ if (setup_program_choice_.empty() || !game_closed(id, &refusal)) {
+ if (!refusal.empty()) push_notice({"run-once-" + ToKey(id), "The program can't run now", "", false, kLiveNoticeSeconds, false, refusal});
+ return;
+ }
+ // Back to the game's page, where Play shows the start as it does the game's.
+ while (!state_.navigation.modals.empty()) close_modal();
+ if (auto previous = state_.runtime_games.find(id); previous != state_.runtime_games.end())
+ previous->second.play_detail.clear();
+ pending_runtime_play_requests_.push_back(id);
+ pending_runtime_setup_programs_[id] = setup_program_choice_;
+ state_.navigation.focus_key = "details-play";
+}
+
void Simulation::request_uninstall(GameId id, bool delete_saves, bool batch) {
pending_install_requests_.push_back({InstallRequestKind::Uninstall, id, {}, delete_saves});
pending_uninstalls_.insert(id);
@@ -3729,7 +3745,7 @@ void Simulation::ApplyLiveDownloadServers(const LiveDownloadServers& snapshot) {
playden::Preferences Simulation::ExportPreferences() const {
return {state_.reduced_motion, state_.title_store_suffix, state_.cloud_saves_auto, state_.sign_in_password,
state_.downloads_slow_network, state_.stay_signed_in, state_.beta_updates, state_.download_server,
- state_.web_access, state_.content_language};
+ state_.web_access, state_.content_language, state_.hide_run_once_help, state_.hide_launcher_help};
}
void Simulation::apply_organization_snapshot(const playden::OrganizationSnapshot& snapshot) {
@@ -3961,6 +3977,8 @@ bool Simulation::ApplyPreferences(PersistenceLoadToken token,
state_.web_access = loaded.preferences.web_access;
state_.stay_signed_in = loaded.preferences.steam_stay_signed_in;
state_.content_language = loaded.preferences.content_language;
+ state_.hide_run_once_help = loaded.preferences.hide_run_once_help;
+ state_.hide_launcher_help = loaded.preferences.hide_launcher_help;
captured_preferences_ = loaded.preferences;
preferences_saved_revision_ = preferences_revision_;
}
@@ -4225,6 +4243,8 @@ bool Simulation::record_live_persistence() {
after_preferences.web_access != captured_preferences_.web_access ||
after_preferences.beta_updates != captured_preferences_.beta_updates ||
after_preferences.content_language != captured_preferences_.content_language ||
+ after_preferences.hide_run_once_help != captured_preferences_.hide_run_once_help ||
+ after_preferences.hide_launcher_help != captured_preferences_.hide_launcher_help ||
after_preferences.steam_stay_signed_in != captured_preferences_.steam_stay_signed_in);
if (organization_changed && !snapshot_within_model_bounds(after_organization)) {
@@ -4253,6 +4273,8 @@ bool Simulation::record_live_persistence() {
state_.web_access = captured_preferences_.web_access;
state_.stay_signed_in = captured_preferences_.steam_stay_signed_in;
state_.content_language = captured_preferences_.content_language;
+ state_.hide_run_once_help = captured_preferences_.hide_run_once_help;
+ state_.hide_launcher_help = captured_preferences_.hide_launcher_help;
organization_journal_full_ = true;
force_organization_reset_ = false;
force_organization_selection_ = false;
@@ -5393,8 +5415,9 @@ void Simulation::rebuild_view() {
inherited = base.values.at(modal.setting_id);
}
if (modal.id == "setup-programs")
- view_.subtitle = "Pick a program from the game folder, such as its settings launcher. It runs one time with the "
- "Mouse preset; Play and Game settings stay as they are.";
+ view_.subtitle = launcher_mode_kit()
+ ? "Pick a program from the game folder, such as its launcher. It runs one time in launcher mode; Play and Game settings stay as they are."
+ : "Pick a program from the game folder, such as its settings launcher. It runs one time with the Mouse preset; Play and Game settings stay as they are.";
if (modal.id == "game-settings" || modal.id == "game-maintenance") {
if (const auto* game = find_game(state_, settings_game)) view_.subtitle = game->title;
} else if (!modal.setting_id.empty()) {
@@ -6137,6 +6160,10 @@ void Simulation::rebuild_view() {
item.value = std::to_string(leftover_selected_.size()) + (leftover_selected_.size() == 1 ? " title · " : " titles · ") +
format_bytes(bytes);
}
+ else if (action_key == "run-once-dont-show" || action_key == "launcher-help-dont-show") {
+ item.kind = RowKind::Toggle;
+ item.selected = action_key == "run-once-dont-show" ? state_.hide_run_once_help : state_.hide_launcher_help;
+ }
else if (action_key == "uninstall-delete-saves") {
item.kind = RowKind::Toggle;
item.dangerous = false;
@@ -6161,6 +6188,7 @@ void Simulation::rebuild_view() {
const auto runtime_game = state_.runtime_games.find(state_.navigation.selected_game_id);
const bool checking = runtime_game != state_.runtime_games.end() &&
runtime_game->second.activity == TitleActivity::Unknown;
+ if (launcher_mode_kit()) item.subtitle = "Starts it in launcher mode.";
if (live() && !checking && !game_closed(state_.navigation.selected_game_id, &refusal)) {
item.enabled = false;
item.value = "Game running";
@@ -9460,26 +9488,37 @@ void Simulation::activate() {
setup_program_choice_ = setup->second.programs[index].path;
const auto slash = setup_program_choice_.find_last_of('/');
const auto name = slash == std::string::npos ? setup_program_choice_ : setup_program_choice_.substr(slash + 1);
+ if (launcher_mode_kit() && state_.hide_run_once_help) {
+ start_setup_program();
+ return;
+ }
ModalEntry confirm{"confirmation", "Run " + name + " once?", state_.navigation.focus_key, {"cancel", "run-once-start"}, 1, false};
// The dialog shows about five lines.
confirm.body = setup_program_choice_ + " starts instead of the game, once, with the Mouse preset: the left stick "
"moves the pointer and Cross clicks.\n\n"
- "Its own Play button can't start the game here. Change the settings, close it, then press Play.";
+ "Its own Play button closes it and starts the game. If that does not work, change the settings, close it, then press Play.";
+ if (launcher_mode_kit()) {
+ confirm.action_keys = {"cancel", "run-once-dont-show", "run-once-start"};
+ confirm.focused_action = 2;
+ rt::EffectiveSettings values;
+ const bool settings = EffectiveSettingsFor(state_.navigation.selected_game_id, &values);
+ const std::string preset = settings && values.values["launcher_controller_preset"].value != "mouse" ? "the game's launcher preset"
+ : "the Mouse preset: the left stick moves the pointer and Cross clicks";
+ confirm.body = "It starts in launcher mode, with " + preset + ". Its own Play button closes it and starts the game, "
+ "which then uses your Controller preset.\n\nHold the touchpad for 2 seconds to switch between the two.";
+ }
open_modal(std::move(confirm));
+ } else if (action_name == "run-once-dont-show") {
+ state_.hide_run_once_help = !state_.hide_run_once_help;
+ } else if (action_name == "launcher-help-dont-show") {
+ state_.hide_launcher_help = !state_.hide_launcher_help;
+ } else if (action_name == "launcher-help-on") {
+ close_modal(); // this dialog
+ close_modal(); // the setting's choices
+ set_game_setting("start_through_launcher", "on");
+ refresh_game_settings(); save_profile();
} else if (live() && action_name == "run-once-start") {
- const auto id = state_.navigation.selected_game_id;
- std::string refusal;
- if (setup_program_choice_.empty() || !game_closed(id, &refusal)) {
- if (!refusal.empty()) push_notice({"run-once-" + ToKey(id), "The program can't run now", "", false, kLiveNoticeSeconds, false, refusal});
- return;
- }
- // Back to the game's page, where Play shows the start as it does the game's.
- while (!state_.navigation.modals.empty()) close_modal();
- if (auto previous = state_.runtime_games.find(id); previous != state_.runtime_games.end())
- previous->second.play_detail.clear();
- pending_runtime_play_requests_.push_back(id);
- pending_runtime_setup_programs_[id] = setup_program_choice_;
- state_.navigation.focus_key = "details-play";
+ start_setup_program();
} else if (action_name == "game-move") {
const auto game = state_.navigation.selected_game_id;
if (move_blocker(game, {}).empty() && move_volumes().size() >= 2) open_move_picker(game);
@@ -9655,6 +9694,16 @@ void Simulation::activate() {
if (launch) {
forget_program_choices(&state_.game_settings[state_.navigation.selected_game_id].overrides);
}
+ // Turning this on explains it first, over the choices, until the player says not to.
+ if (id == "start_through_launcher" && definition->choices[index].value == "on" && !state_.hide_launcher_help) {
+ ModalEntry help{"confirmation", "Start through a launcher", state_.navigation.focus_key,
+ {"cancel", "launcher-help-dont-show", "launcher-help-on"}, 2, false};
+ help.body = "For a program that opens a launcher window, which starts the game. The launcher uses the Launcher controller "
+ "preset, and the game your Controller preset. Hold the touchpad for 2 seconds to switch.\n\n"
+ "Leave this off for other games: one that starts helper programs could restart or close.";
+ open_modal(std::move(help));
+ return;
+ }
set_game_setting(id, launch ? recipe.launch_entries[index].id : definition->choices[index].value);
}
close_modal(); refresh_game_settings(); save_profile();
@@ -10727,6 +10776,10 @@ std::vector<std::string> Simulation::game_settings_actions() const {
// Whether the sheet lists a setting's row: Known problems only for a game that has one.
bool Simulation::game_settings_row_shown(const rt::SettingDefinition& definition, GameId game) const {
+ if (definition.id == "launcher_controller_preset") {
+ rt::EffectiveSettings values;
+ if (!EffectiveSettingsFor(game, &values) || values.values["start_through_launcher"].value != "on") return false;
+ }
return rt::SettingShown(definition, kit_) && (definition.id != "start_check" || known_problem(game));
}
diff --git a/src/homebrew/simulation.hpp b/src/homebrew/simulation.hpp
index db838d4..335d175 100644
--- a/src/homebrew/simulation.hpp
+++ b/src/homebrew/simulation.hpp
@@ -792,6 +792,8 @@ struct State {
// Empty: Steam default (Steam's order); kFastestDownloadServer: Fastest (raced at each download); otherwise
// the chosen provider's stable identifier.
std::string download_server;
+ bool hide_run_once_help = false; // "Don't show again" on Run a program once's dialog
+ bool hide_launcher_help = false; // ...and on the one for turning on Start through a launcher
bool web_access = true; // Settings › Web access: the logs page on the local network (on by default)
bool controller_connected = true;
ControllerState controller;
@@ -1487,6 +1489,8 @@ private:
bool move_manage(int delta_x, int delta_y);
// Asks the controller to uninstall a game; batch: from the Installed games list.
void request_uninstall(GameId id, bool delete_saves, bool batch);
+ void start_setup_program(); // Run a program once: the program chosen, when the game is closed
+ bool launcher_mode_kit() const { return kit_.launcher_mode || kit_.launcher_mode_needs_update; }
void end_uninstall(GameId id, const std::string& stopped);
[[nodiscard]] const EndedUninstall* uninstall_stop(GameId id) const;
[[nodiscard]] std::vector<std::string> collection_sheet_actions(const std::string& sheet) const;
diff --git a/src/runtime/game_settings.cpp b/src/runtime/game_settings.cpp
index ce975eb..3cef29a 100644
--- a/src/runtime/game_settings.cpp
+++ b/src/runtime/game_settings.cpp
@@ -75,6 +75,16 @@ std::vector<SettingDefinition> BuildCatalogue() {
"[application] executable", G::kGame);
list.push_back(std::move(program));
}
+ list.push_back(Choice("start_through_launcher", "Start through a launcher",
+ "Turn on if this program opens a launcher that starts the game.", "[launcher]", G::kGame,
+ {{"off", "Off", ""}, {"on", "On", "Starts in launcher mode. Hold the touchpad in game to switch presets."}},
+ "off"));
+ list.push_back(Choice("launcher_controller_preset", "Launcher controller preset",
+ "Used until the game starts. Then the Controller preset takes over.", "[launcher] preset", G::kGame,
+ {{"mouse", "Mouse", "Left stick moves the pointer; Cross clicks, Circle right-clicks, Options Enter."},
+ {"gamepad", "Gamepad", "Xbox controller layout; no stick moves the pointer."},
+ {"arrows", "Arrow keys", "D-pad sends the arrows; Cross Z, Circle X, Triangle C, Options Enter."}},
+ "mouse"));
list.push_back(Text("extra_arguments", "Extra arguments", "Added after the arguments the game needs.",
"[application] arguments", G::kGame));
// Display.
@@ -545,6 +555,12 @@ std::string Unavailable(const SettingDefinition& definition, const std::string&
if (id == "registry_dll_overrides") return "Needs a prospero-win update that lets Playden write more registry values.";
// Wine reads WINE_CPU_TOPOLOGY from the [environment] section; [debug] env does not take WINE_ names.
if (id == "cpu_topology" && !kit.environment) return "Needs a prospero-win update that reads [environment].";
+ if (id == "start_through_launcher" || id == "launcher_controller_preset") {
+ if (kit.launcher_mode_needs_update) return kAppliesAfterKitUpdate;
+ if (!kit.launcher_mode) return "Needs a runtime kit with launcher mode.";
+ if (id == "launcher_controller_preset" && values.at("start_through_launcher").value != "on")
+ return "Turn on Start through a launcher first.";
+ }
if (id == "performance_overlay" && graphics == "gdi") return "Only available with DXVK or OpenGL.";
// DXVK's overlay is drawn by its Direct3D 9-11 presenter, not by vkd3d-proton's swapchain. The Direct3D 12 row comes
// later in the catalogue, so its value here is not checked yet: the same test it gets below.
@@ -590,6 +606,18 @@ const std::map<std::string, std::map<std::string, std::string>>& ControllerPrese
return inputs;
}
+const std::map<std::string, std::map<std::string, std::string>>& ControllerPresetButtons() {
+ // Mirrors the button lines of runtime/input/*.input (a host test compares them).
+ static const std::map<std::string, std::map<std::string, std::string>> buttons = {
+ {"arrows", {{"up", "up"}, {"down", "down"}, {"left", "left"}, {"right", "right"}, {"cross", "z"},
+ {"circle", "x"}, {"triangle", "c"}, {"square", "shift"}, {"options", "enter"}}},
+ {"gamepad", {}},
+ {"mouse", {{"cross", "mouse_left"}, {"circle", "mouse_right"}, {"square", "mouse_middle"}, {"r2", "mouse_left"},
+ {"l2", "mouse_right"}, {"options", "enter"}}},
+ };
+ return buttons;
+}
+
const std::vector<std::string>& ProsperoButtons() {
static const std::vector<std::string> buttons = {"cross", "circle", "square", "triangle", "l1", "r1",
"l2", "r2", "l3", "r3", "up", "down",
@@ -608,7 +636,10 @@ const SettingDefinition* FindSetting(std::string_view id) {
return nullptr;
}
-bool SettingShown(const SettingDefinition& definition, const KitCapabilities&) {
+bool SettingShown(const SettingDefinition& definition, const KitCapabilities& kit) {
+ if ((definition.id == "start_through_launcher" || definition.id == "launcher_controller_preset") &&
+ !kit.launcher_mode && !kit.launcher_mode_needs_update)
+ return false;
return definition.id.rfind("button.", 0) != 0 && definition.id != "program" && definition.id != "library_overrides";
}
@@ -1111,6 +1142,28 @@ bool RenderProsperoProfile(const GameRecipe& recipe, const EffectiveSettings& se
if (!binding.empty()) text += button + " = " + binding + "\n";
}
+ // Starting through a launcher: the launcher's preset written out, since a title reads one preset file, and the
+ // names the title's notification shows.
+ const bool launcher_section = settings.values.at("start_through_launcher").available &&
+ value("start_through_launcher") == "on" && settings.values.at("launcher_controller_preset").available;
+ if (launcher_section) {
+ const auto label = [](const char* id, const std::string& choice) {
+ for (const auto& option : FindSetting(id)->choices)
+ if (option.value == choice) return option.label;
+ return std::string();
+ };
+ const auto& launcher_preset = value("launcher_controller_preset");
+ const auto& rows = ControllerPresetInputs().at(launcher_preset);
+ text += "\n[launcher]\nlabel = " + label("launcher_controller_preset", launcher_preset) + "\n";
+ if (value("controller_preset") != "none") text += "game_label = " + label("controller_preset", value("controller_preset")) + "\n";
+ else text += "game_label = Game controls\n";
+ text += "mode = " + rows.at("controller") + "\nmouse = " + rows.at("pointer_stick") + "\n";
+ if (rows.count("pointer_speed")) text += "mouse_speed = " + rows.at("pointer_speed") + "\n";
+ const auto& buttons = ControllerPresetButtons().at(launcher_preset);
+ for (const auto& button : ProsperoButtons())
+ if (buttons.count(button)) text += button + " = " + buttons.at(button) + "\n";
+ }
+
const bool audio_section = settings.values.at("volume").available && value("volume") != "100";
if (audio_section) text += "\n[audio]\nvolume = " + value("volume") + "\n";
@@ -1208,6 +1261,7 @@ bool RenderProsperoProfile(const GameRecipe& recipe, const EffectiveSettings& se
features.display_frame_rate = frame_rate;
features.display_framegen = display_framegen;
features.runtime_version = settings.profile_version == 2;
+ features.launcher_section = launcher_section;
if (!CheckProsperoProfile(text, &why, features)) return fail("generated profile is invalid: " + why);
*profile = {target.id, std::move(text)};
return true;
@@ -3105,7 +3159,7 @@ namespace playden::runtime {
const std::vector<std::string>& SettingsKitCapabilityNames() {
// Sorted, as a kit manifest lists them.
- static const std::vector<std::string> names = {kKitDisplay120Hz, kKitDisplayFramegen, kKitInputRumble,
+ static const std::vector<std::string> names = {kKitDisplay120Hz, kKitDisplayFramegen, kKitInputRumble, kKitLauncherMode,
kKitAudioVolume, kKitDxvkConfig, kKitDxvkPresent,
kKitInputTuning, kKitInputWheel, kKitEnvironment};
return names;
@@ -3135,6 +3189,7 @@ KitCapabilities KitCapabilitiesFromManifest(const std::vector<std::string>& capa
kit.profile_version_2 = has(kKitProfileVersion2);
kit.input_rumble = has(kKitInputRumble);
kit.display_framegen = has(kKitDisplayFramegen);
+ kit.launcher_mode = has(kKitLauncherMode);
kit.registry = bottle_access;
return kit;
}
@@ -3156,6 +3211,10 @@ KitCapabilities KitForTitleRuntime(KitCapabilities kit, bool title_runtime_curre
kit.display_framegen = false;
kit.display_framegen_needs_update = true;
}
+ if (!title_runtime_current && kit.launcher_mode) {
+ kit.launcher_mode = false;
+ kit.launcher_mode_needs_update = true;
+ }
return kit;
}
diff --git a/src/runtime/game_settings.h b/src/runtime/game_settings.h
index b1e239b..da30ec4 100644
--- a/src/runtime/game_settings.h
+++ b/src/runtime/game_settings.h
@@ -76,6 +76,8 @@ struct KitCapabilities {
// [display] framegen = off|2|3|4 (frame generation in libvulkan.prx). Counts only for a title that runs this kit's
// runtime, like display_120hz.
bool display_framegen = false;
+ bool launcher_mode = false; // [launcher]: the game starts through a launcher (kKitLauncherMode)
+ bool launcher_mode_needs_update = false; // the kit has it, but the game's title still runs an older runtime
bool display_framegen_needs_update = false;
};
@@ -109,6 +111,7 @@ bool SettingShown(const SettingDefinition& definition, const KitCapabilities& ki
// The 17 controller buttons prospero-win binds, as setting ids "button.<name>".
// The rows a controller preset sets, by preset id: setting id → value.
const std::map<std::string, std::map<std::string, std::string>>& ControllerPresetInputs();
+const std::map<std::string, std::map<std::string, std::string>>& ControllerPresetButtons();
const std::vector<std::string>& ProsperoButtons();
struct LaunchEntry {
@@ -561,6 +564,9 @@ inline constexpr const char* kKitInputRumble = "input-rumble";
// The title reads [display] framegen = off|2|3|4: the kit's libvulkan.prx shows that many pictures for each frame a
// Vulkan-presenting game (DXVK, Zink) draws, made by MihawkGen. Runtimes without it refuse a profile with framegen.
inline constexpr const char* kKitDisplayFramegen = "display-framegen";
+// The title reads [launcher]: the exec chain only for a game that asks for it, a second input for the first
+// program, and the touchpad hold that swaps them. Runtimes without it refuse a profile with the section.
+inline constexpr const char* kKitLauncherMode = "launcher-mode";
const std::vector<std::string>& SettingsKitCapabilityNames();
// Settings gates from a verified kit's capabilities. bottle_access: the adapter can edit the
diff --git a/src/runtime/kit_trust.cpp b/src/runtime/kit_trust.cpp
index 0974385..0e8764e 100644
--- a/src/runtime/kit_trust.cpp
+++ b/src/runtime/kit_trust.cpp
@@ -15,7 +15,7 @@ KitAdmissionConfig DevelopmentKitAdmission() {
kKitAudioVolume, kKitDxvkConfig, kKitDxvkPresent, kKitInputTuning,
kKitInputWheel, kKitEnvironment, kKitWineMono, kKitVkd3dProton,
kKitDisplay120Hz, kKitProfileVersion2, kKitInputRumble,
- kKitDisplayFramegen};
+ kKitDisplayFramegen, kKitLauncherMode};
std::sort(config.known_capabilities.begin(), config.known_capabilities.end());
return config;
}
diff --git a/src/runtime/prospero_profile.cpp b/src/runtime/prospero_profile.cpp
index 3d14653..bc081fb 100644
--- a/src/runtime/prospero_profile.cpp
+++ b/src/runtime/prospero_profile.cpp
@@ -238,7 +238,8 @@ bool CheckProsperoProfile(std::string_view text, std::string* reason, ProsperoPr
const auto name = Lower(line.substr(1, line.size() - 2));
if ((name != "application" && name != "display" && name != "input" && name != "debug" &&
!(features.environment_section && name == "environment") &&
- !(features.audio_section && name == "audio") && !(features.runtime_version && name == "runtime")) ||
+ !(features.audio_section && name == "audio") && !(features.runtime_version && name == "runtime") &&
+ !(features.launcher_section && name == "launcher")) ||
std::find(sections.begin(), sections.end(), name) != sections.end())
return fail("section [" + name + "] unknown or repeated");
if (sections.empty() != (name == "application")) return fail("[application] must come first");
@@ -317,6 +318,24 @@ bool CheckProsperoProfile(std::string_view text, std::string* reason, ProsperoPr
} else {
return fail("unknown [display] key " + key);
}
+ } else if (section == "launcher") {
+ // The first program's input, written out: as [input], without a preset file.
+ if (key == "label" || key == "game_label") {
+ if (value.empty() || value.size() >= 32 ||
+ value.find_first_not_of("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 -") != std::string_view::npos)
+ return bad("not a short name");
+ } else if (key == "mode") {
+ if (!OneOf(value, {"keyboard", "xinput"})) return bad("not keyboard or xinput");
+ } else if (key == "mouse") {
+ if (!OneOf(value, {"none", "left_stick", "right_stick"})) return bad("unknown pointer stick");
+ } else if (key == "mouse_speed") {
+ const long speed = IsDigits(value, 9) ? std::atol(std::string(value).c_str()) : 0;
+ if (speed < 1 || speed > 20000) return bad("not 1-20000");
+ } else if (std::find(std::begin(kButtons), std::end(kButtons), key) != std::end(kButtons)) {
+ if (!IsProsperoBinding(value)) return bad("not a key, mouse button or none");
+ } else {
+ return fail("unknown [launcher] key " + key);
+ }
} else if (section == "input") {
if (key == "preset") {
if (!IsIdentifier(value)) return bad("not a preset name");
diff --git a/src/runtime/prospero_profile.h b/src/runtime/prospero_profile.h
index 32b2c30..2daf4ab 100644
--- a/src/runtime/prospero_profile.h
+++ b/src/runtime/prospero_profile.h
@@ -81,6 +81,7 @@ struct ProsperoProfileFeatures {
bool debug_env = false; // [debug] env = NAME=value (upstream prospero-win)
bool display_frame_rate = false; // [display] frame_rate = 0|120|60|40|30 (kit capability display-120hz)
bool display_framegen = false; // [display] framegen = off|2|3|4 (kit capability display-framegen)
+ bool launcher_section = false; // [launcher] (kit launcher-mode)
bool runtime_version = false; // [runtime] version = 1|2 (kit capability profile-version-2)
};
// A [debug] env variable the runtime takes: PW_, DXVK_, MESA_, GALLIUM_, ZINK_, RADV_ or VK_ names, without the ones
diff --git a/tests/game_settings_test.cpp b/tests/game_settings_test.cpp
index c04282e..35a2b46 100644
--- a/tests/game_settings_test.cpp
+++ b/tests/game_settings_test.cpp
@@ -75,7 +75,7 @@ int main(int argc, char** argv) {
for (const auto& definition : SettingsCatalogue())
if (definition.group != SettingGroup::kButtonMapping) ids.push_back(definition.id);
const std::vector<std::string> expected = {
- "launch_option", "program", "extra_arguments",
+ "launch_option", "program", "start_through_launcher", "launcher_controller_preset", "extra_arguments",
"resolution", "refresh", "frame_limit", "framegen", "vsync", "performance_overlay", "overlay_detail", "scaling",
"window_view",
"controller", "controller_preset",
@@ -227,7 +227,55 @@ int main(int argc, char** argv) {
&settings, &error));
CHECK(RenderProsperoProfile(hl2, settings, target, &profile, &reason));
CHECK(profile.text.find("\nmouse_speed = 600\n") != std::string::npos && profile.text.find("\nmouse = ") == std::string::npos);
- // Playden's table of preset rows matches the shipped input files.
+ // Starting through a launcher: only with the kit, written out, and refused when the kit can't read it.
+ {
+ KitCapabilities launcher_kit;
+ launcher_kit.launcher_mode = true;
+ KitCapabilities needs_update;
+ needs_update.launcher_mode_needs_update = true;
+ CHECK(!SettingShown(*FindSetting("start_through_launcher"), KitCapabilities{}));
+ CHECK(SettingShown(*FindSetting("start_through_launcher"), launcher_kit));
+ CHECK(SettingShown(*FindSetting("launcher_controller_preset"), needs_update));
+ CHECK(BuildEffectiveSettings(hl2, nullptr, {{"controller_preset", "gamepad"}}, launcher_kit, &settings, &error));
+ CHECK(settings.values.at("start_through_launcher").value == "off");
+ CHECK(!settings.values.at("launcher_controller_preset").available);
+ CHECK(RenderProsperoProfile(hl2, settings, target, &profile, &reason));
+ CHECK(profile.text.find("[launcher]") == std::string::npos);
+ CHECK(BuildEffectiveSettings(hl2, nullptr, {{"controller_preset", "gamepad"}, {"start_through_launcher", "on"}}, launcher_kit,
+ &settings, &error));
+ CHECK(settings.values.at("launcher_controller_preset").value == "mouse");
+ CHECK(RenderProsperoProfile(hl2, settings, target, &profile, &reason));
+ CHECK(profile.text.find("\npreset = gamepad\n") != std::string::npos);
+ CHECK(profile.text.find("\n[launcher]\nlabel = Mouse\ngame_label = Gamepad\nmode = keyboard\nmouse = left_stick\n"
+ "mouse_speed = 900\ncross = mouse_left\ncircle = mouse_right\nsquare = mouse_middle\n") != std::string::npos);
+ CHECK(BuildEffectiveSettings(hl2, nullptr, {{"start_through_launcher", "on"}, {"launcher_controller_preset", "gamepad"}},
+ launcher_kit, &settings, &error));
+ CHECK(RenderProsperoProfile(hl2, settings, target, &profile, &reason));
+ CHECK(profile.text.find("\n[launcher]\nlabel = Gamepad\ngame_label = Game controls\nmode = xinput\nmouse = none\n") != std::string::npos);
+ // A title on an older runtime gets no section: its parser would refuse the profile.
+ CHECK(BuildEffectiveSettings(hl2, nullptr, {{"start_through_launcher", "on"}}, needs_update, &settings, &error));
+ CHECK(RenderProsperoProfile(hl2, settings, target, &profile, &reason));
+ CHECK(profile.text.find("[launcher]") == std::string::npos);
+ // The section is only accepted when the renderer says so.
+ const std::string with_section = std::string(profile.text) + "\n[launcher]\nmode = keyboard\n";
+ std::string why;
+ CHECK(!CheckProsperoProfile(with_section, &why, {}));
+ ProsperoProfileFeatures launcher_features;
+ launcher_features.launcher_section = true;
+ const std::string bad_label = std::string("[application]\n") + "\n[launcher]\nlabel = a\"b\n";
+ CHECK(!CheckProsperoProfile(bad_label, &why, launcher_features));
+ }
+ // Playden's tables of preset rows and buttons match the shipped input files.
+ for (const auto& [name, buttons] : ControllerPresetButtons()) {
+ const auto file = ReadText(source / ("runtime/input/" + name + ".input"));
+ for (const auto& button : ProsperoButtons()) {
+ const auto line = "\n" + button + " = ";
+ const auto at = file.find(line);
+ const std::string in_file = at == std::string::npos ? "" : file.substr(at + line.size(), file.find('\n', at + line.size()) - at - line.size());
+ const auto row = buttons.find(button);
+ CHECK(in_file == (row == buttons.end() ? std::string() : row->second));
+ }
+ }
for (const auto& [name, rows] : ControllerPresetInputs()) {
const auto file = ReadText(source / ("runtime/input/" + name + ".input"));
const std::map<std::string, std::string> keys = {{"controller", "mode"}, {"pointer_stick", "mouse"}, {"pointer_speed", "mouse_speed"}};
diff --git a/tests/homebrew_live_model_test.cpp b/tests/homebrew_live_model_test.cpp
index d1103c9..9673e40 100644
--- a/tests/homebrew_live_model_test.cpp
+++ b/tests/homebrew_live_model_test.cpp
@@ -749,6 +749,28 @@ void live_runs_setup_program_once(const std::filesystem::path& base) {
activate(model, "details-play");
check(model.TakeRuntimePlayRequests().size() == 2 && model.TakeRuntimeSetupPrograms().empty(),
"setup program: Play replaces the program's run");
+
+ // With launcher mode: the dialog says so and offers Don't show again, which then starts the program directly.
+ model.SetKitCapabilities(playden::runtime::KitCapabilitiesFromManifest({"launcher-mode"}, true));
+ activate(model, "details-more");
+ check(find_row(model, "run-once")->subtitle == "Starts it in launcher mode.", "launcher mode: its row says so");
+ activate(model, "run-once");
+ activate(model, "setup-program-0");
+ check(model.state().navigation.modals.back().body.find("launcher mode") != std::string::npos &&
+ find_row(model, "run-once-dont-show") && !find_row(model, "run-once-dont-show")->selected,
+ "launcher mode: the dialog explains it");
+ (void)model.TakeRuntimePlayRequests();
+ (void)model.TakeRuntimeSetupPrograms();
+ activate(model, "run-once-dont-show");
+ check(find_row(model, "run-once-dont-show")->selected && model.ExportPreferences().hide_run_once_help &&
+ !model.ExportPreferences().hide_launcher_help,
+ "launcher mode: Don't show again is this dialog's own");
+ check(model.TakeRuntimePlayRequests().empty(), "launcher mode: the choice starts nothing");
+ activate(model, "cancel");
+ activate(model, "setup-program-0");
+ check(model.state().navigation.modals.empty() && model.TakeRuntimePlayRequests() == std::vector<playden::GameId>{SteamId(35140)} &&
+ model.TakeRuntimeSetupPrograms() == std::map<GameId, std::string>{{SteamId(35140), "Binaries/BmLauncher.exe"}},
+ "launcher mode: with it set, picking a program starts it");
}
void live_download_telemetry() {
diff --git a/tests/preferences_test.cpp b/tests/preferences_test.cpp
index 85eb045..60735c2 100644
--- a/tests/preferences_test.cpp
+++ b/tests/preferences_test.cpp
@@ -186,10 +186,10 @@ void SignInMethodPersistsAndVersionThreeOpensQr() {
Check(store.Save(preferences).ok(), "sign-in method preference saves");
const auto saved = storage.Read("preferences.conf");
Check(saved.ok() && std::string(saved.value().begin(), saved.value().end()) ==
- "version=10\nreduce_motion=0\ntitle_store_suffix=0\ncloud_saves_auto=1\nsteam_sign_in_password=1\n"
+ "version=11\nreduce_motion=0\ntitle_store_suffix=0\ncloud_saves_auto=1\nsteam_sign_in_password=1\n"
"downloads_slow_network=0\nsteam_stay_signed_in=1\nbeta_updates=0\ndownload_server=\nweb_access=1\n"
- "content_language=english\n",
- "version 10 format includes Automatic download server, web access and English");
+ "content_language=english\nhide_run_once_help=0\nhide_launcher_help=0\n",
+ "version 11 format includes Automatic download server, web access and English");
const auto loaded = store.Load();
Check(loaded.status == playden::PreferencesLoadStatus::kLoaded && loaded.preferences.steam_sign_in_password &&
loaded.preferences.cloud_saves_auto,
@@ -319,6 +319,19 @@ void VersionNineKeepsWebAccessAndVersionEightTurnsItOn() {
}
}
+void LauncherDialogsRemembered() {
+ TemporaryDirectory directory;
+ playden::Storage storage(directory.path());
+ playden::PreferencesStore store(storage);
+ playden::Preferences preferences;
+ Check(!preferences.hide_run_once_help && !preferences.hide_launcher_help, "the launcher dialogs show by default");
+ preferences.hide_launcher_help = true;
+ Check(store.Save(preferences).ok(), "launcher dialog choice saves");
+ const auto loaded = store.Load();
+ Check(loaded.status == playden::PreferencesLoadStatus::kLoaded && loaded.preferences.hide_launcher_help &&
+ !loaded.preferences.hide_run_once_help, "each dialog's choice is kept on its own");
+}
+
void OlderPreferencesUseAutomaticDownloadServer() {
TemporaryDirectory directory;
playden::Storage storage(directory.path());
@@ -345,8 +358,8 @@ void OlderPreferencesUseAutomaticDownloadServer() {
"migration retains old fields and defaults later fields");
Check(store.Save(loaded.preferences).ok(), "migrated preferences save");
const auto saved = storage.Read("preferences.conf");
- Check(saved.ok() && std::string(saved.value().begin(), saved.value().end()).rfind("version=10\n", 0) == 0,
- "saving a migrated file writes version 10");
+ Check(saved.ok() && std::string(saved.value().begin(), saved.value().end()).rfind("version=11\n", 0) == 0,
+ "saving a migrated file writes version 11");
Check(loaded.preferences.web_access, "every older preference version has web access on");
Check(loaded.preferences.content_language == "english", "every older preference version downloads English");
}
@@ -523,6 +536,7 @@ int main() {
VersionEightLoadsDownloadServerWithoutResettingOtherFields();
VersionNineKeepsWebAccessAndVersionEightTurnsItOn();
OlderPreferencesUseAutomaticDownloadServer();
+ LauncherDialogsRemembered();
DownloadServerRoundTripsAndInvalidHostsUseAutomatic();
VersionEightRejectsTruncatedOrMalformedFiles();
ContentLanguagePersistsAndOlderVersionsStayEnglish();