Skip to content

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

C++

Say which program starts instead of Steam's default

Leonardo Lobato9af478e533d3
diff --git a/src/homebrew/runtime_host.cpp b/src/homebrew/runtime_host.cpp
index e371ac8..b499838 100644
--- a/src/homebrew/runtime_host.cpp
+++ b/src/homebrew/runtime_host.cpp
@@ -3126,6 +3126,11 @@ const rt::GameRecipe* RuntimeHost::RecipeForPrepare(Composition& c, const Runtim
Log("steamstub app=" + std::to_string(request.runtime_number) + " found=" + diagnostics.steam_stub_program +
" changed=- " + (made ? std::string("skipped") : "failed=" + *reason) + " (" +
(diagnostics.steam_stub_detail.empty() ? "unknown" : diagnostics.steam_stub_detail) + ")");
+ // Steam's default only starts the game: which program starts instead and why, so a report shows the choice.
+ if (!diagnostics.steam_default.empty())
+ Log("steam default skipped app=" + std::to_string(request.runtime_number) + " default=" + diagnostics.steam_default +
+ " why=" + diagnostics.steam_default_skipped_because + " instead=" +
+ (diagnostics.game_instead.empty() ? "-" : diagnostics.game_instead));
if (!made && launches.empty() && choices.program.empty())
*reason = request.launch_reason.empty() ? "Steam lists no Windows program this console can start for this game."
: request.launch_reason;
diff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cpp
index 033859a..1f5ca2d 100644
--- a/src/homebrew/simulation.cpp
+++ b/src/homebrew/simulation.cpp
@@ -6256,6 +6256,8 @@ void Simulation::rebuild_view() {
item.value = settings_values.launch ? settings_values.launch->label : "Choose a program";
if (settings_values.launch && settings_values.launch->id == rt::kProgramEntryId)
item.subtitle = "From the game folder: " + settings_values.launch->executable + ".";
+ else if (rt::ProgramInsteadOfSteamDefault(RecipeFor(settings_game), settings_values.launch))
+ item.subtitle = "Found in the game's files: Steam's default program only starts the game.";
else if (!settings_values.launch) item.subtitle = "Pick the game's program from its folder.";
}
else if (id.rfind("button.", 0) == 0) item.value = binding_label(value.value);
@@ -7393,9 +7395,21 @@ void Simulation::rebuild_view() {
hint = stopped ? "Setup stopped early: console storage was full." : "Setup failed: console storage was full.";
else hint = stopped ? "Setup stopped early." : "Setup failed.";
}
+ // Playden starts another program than Steam's default, which only starts the game: say which, and where to
+ // change it, so a wrong guess is easy to spot and undo (#576).
+ bool program_note = false;
+ if (hint.empty() && status == "Ready") {
+ rt::EffectiveSettings values;
+ if (EffectiveSettingsFor(game->id, &values))
+ if (const auto program = rt::ProgramInsteadOfSteamDefault(RecipeFor(game->id), values.launch)) {
+ hint = "Starts " + program->substr(program->rfind('/') + 1) +
+ " because Steam's default program only starts the game. You can change it in Game settings.";
+ program_note = true;
+ }
+ }
if (!hint.empty()) {
auto& note = row("details-hint", RowKind::Status, hint, "");
- note.tone = setup.tone;
+ note.tone = program_note ? "quiet" : setup.tone;
note.enabled = false;
}
// Waiting behind other games: move it to the front; the game being set up now finishes first.
diff --git a/src/runtime/game_settings.cpp b/src/runtime/game_settings.cpp
index 7ec262a..8075962 100644
--- a/src/runtime/game_settings.cpp
+++ b/src/runtime/game_settings.cpp
@@ -1981,16 +1981,21 @@ namespace {
// A program that draws or has a known engine is the game. A .NET program is the game only when it names XNA itself
// (Guncraft): its graphics libraries and most engines are found from the folder (UnityPlayer.dll, a DLL that imports
// Direct3D), which a .NET launcher beside the game shares.
-bool StartsTheGameOnly(const std::string& program, const GameProbe& probe) {
+// Why the program only starts the game, for the log; empty when it is the game.
+std::string WhyStartsTheGameOnly(const std::string& program, const GameProbe& probe) {
auto name = LowerAscii(program.substr(program.rfind('/') == std::string::npos ? 0 : program.rfind('/') + 1));
// Redistributable installers and uninstallers are never the game, whatever they import (UE3Redist.exe draws a dialog with D3D9).
for (const char* word : {"redist", "dxsetup", "uninst"})
- if (name.find(word) != std::string::npos) return true;
- if (probe.dotnet) return probe.engine != "xna";
- if (!probe.apis.empty() || !probe.engine.empty()) return false;
+ if (name.find(word) != std::string::npos) return "installer";
+ if (probe.dotnet) return probe.engine != "xna" ? "dotnet-launcher" : "";
+ if (!probe.apis.empty() || !probe.engine.empty()) return "";
for (const char* word : {"launch", "updater", "config", "setup", "settings"})
- if (name.find(word) != std::string::npos) return true;
- return false;
+ if (name.find(word) != std::string::npos) return std::string("name-") + word;
+ return "";
+}
+
+bool StartsTheGameOnly(const std::string& program, const GameProbe& probe) {
+ return !WhyStartsTheGameOnly(program, probe).empty();
}
bool DrawsGraphics(const std::string& summary) {
@@ -2077,12 +2082,21 @@ bool GenerateGameRecipe(const GameId& game, std::uint32_t runtime_number, const
if (choices.program.empty() && !launches.empty()) {
const auto relative = steam::RelativeGamePath(launches.front().executable);
const auto on_disk = relative ? ResolveGameFile(install_root, *relative) : std::nullopt;
- if (on_disk && LowerAscii(on_disk->substr(on_disk->size() - std::min<std::size_t>(4, on_disk->size()))) == ".exe" &&
- StartsTheGameOnly(*on_disk, ProbeGame(install_root, *on_disk)))
- if (const auto game = GameInsteadOf(install_root, *on_disk, kit)) {
+ const auto why = on_disk && LowerAscii(on_disk->substr(on_disk->size() - std::min<std::size_t>(4, on_disk->size()))) == ".exe"
+ ? WhyStartsTheGameOnly(*on_disk, ProbeGame(install_root, *on_disk))
+ : std::string();
+ if (!why.empty()) {
+ const auto game = GameInsteadOf(install_root, *on_disk, kit);
+ if (game) {
game_program = *game;
candidates.insert(candidates.begin(), {LaunchEntry{"", "", *game, "", ""}, false});
}
+ if (diagnostics) {
+ diagnostics->steam_default = *on_disk;
+ diagnostics->steam_default_skipped_because = why;
+ diagnostics->game_instead = game.value_or("");
+ }
+ }
}
int steam_entries = 0;
// Steam's own entries are the last ones; the player's program and the game found instead of a
@@ -2184,6 +2198,12 @@ bool GenerateGameRecipe(const GameId& game, std::uint32_t runtime_number, const
return true;
}
+std::optional<std::string> ProgramInsteadOfSteamDefault(const GameRecipe& recipe, const LaunchEntry* current) {
+ if (!current) current = recipe.launch_entries.empty() ? nullptr : &recipe.launch_entries.front();
+ if (!IsGeneratedRecipeId(recipe.id) || !current || current->id != "game") return std::nullopt;
+ return current->executable;
+}
+
bool RefreshRecipeDefaults(const std::string& install_root, const KitCapabilities& kit, GameRecipe* recipe) {
if (!IsGeneratedRecipeId(recipe->id) || recipe->launch_entries.empty() ||
recipe->defaults_revision >= DefaultsRevision(recipe->detected))
diff --git a/src/runtime/game_settings.h b/src/runtime/game_settings.h
index add2ca5..9a0e823 100644
--- a/src/runtime/game_settings.h
+++ b/src/runtime/game_settings.h
@@ -386,11 +386,19 @@ RecipeChoices RecipeChoicesFrom(const GameSettingsRecord& record);
// replaced by its *-Shipping.exe. The player's program comes first and Steam's entries stay
// as suggestions. On failure, reason is a short sentence for the player and refusal_soft
// says whether "Try anyway" or another program could get past it.
-// What a refused recipe saw, for logs: the first SteamStub program and why it was not unpacked.
+// What a recipe saw, for logs: the first SteamStub program and why it was not unpacked, and when Steam's default
+// program only starts the game (a launcher, a .NET launcher, an installer), why and which program starts instead.
struct GameRecipeDiagnostics {
std::string steam_stub_program;
std::string steam_stub_detail;
+ std::string steam_default; // Steam's default program, when it only starts the game
+ std::string steam_default_skipped_because; // installer, dotnet-launcher or name-<word> (launch, updater, ...)
+ std::string game_instead; // the game's own program put first; empty: none found, the default stays
};
+// The program Play starts when Playden found it in the game's files because Steam's default only starts the game
+// (GameRecipeDiagnostics). current is the entry Play starts (EffectiveSettings::launch); null means the recipe's first.
+// Nullopt when Play starts one of Steam's options or the player's program.
+std::optional<std::string> ProgramInsteadOfSteamDefault(const GameRecipe& recipe, const LaunchEntry* current);
bool GenerateGameRecipe(std::uint32_t app_id, const std::string& name, const std::vector<LaunchEntry>& launches,
const std::string& install_root, GameRecipe* recipe, std::string* reason,
const KitCapabilities& kit = {}, const RecipeChoices& choices = {},
diff --git a/tests/game_probe_test.cpp b/tests/game_probe_test.cpp
index 2cead00..a31cba4 100644
--- a/tests/game_probe_test.cpp
+++ b/tests/game_probe_test.cpp
@@ -885,6 +885,19 @@ int main() {
CHECK(GenerateGameRecipe(241720, "Guncraft", {{"", "", "Launcher.exe", "", ""}}, guncraft.string(), &recipe,
&reason, mono));
CHECK(recipe.launch_entries.size() == 2 && recipe.launch_entries[0].executable == "Guncraft.exe");
+ // The swap is logged with why, and the game page names the program that starts until the player picks another.
+ GameRecipeDiagnostics swap;
+ CHECK(GenerateGameRecipe(241720, "Guncraft", {{"", "", "Launcher.exe", "", ""}}, guncraft.string(), &recipe,
+ &reason, mono, {}, nullptr, &swap));
+ CHECK(swap.steam_default == "Launcher.exe" && swap.steam_default_skipped_because == "dotnet-launcher" &&
+ swap.game_instead == "Guncraft.exe");
+ CHECK(ProgramInsteadOfSteamDefault(recipe, nullptr) == std::optional<std::string>("Guncraft.exe"));
+ CHECK(ProgramInsteadOfSteamDefault(recipe, &recipe.launch_entries[0]).has_value());
+ CHECK(!ProgramInsteadOfSteamDefault(recipe, &recipe.launch_entries[1]));
+ GameRecipeDiagnostics none;
+ CHECK(GenerateGameRecipe(241720, "Guncraft", {{"", "", "Guncraft.exe", "", ""}}, guncraft.string(), &recipe,
+ &reason, mono, {}, nullptr, &none));
+ CHECK(none.steam_default.empty() && !ProgramInsteadOfSteamDefault(recipe, nullptr));
}
// A program that draws, or the player's choice, is started as listed.
CHECK(GenerateGameRecipe(1, "Game", {{"", "", "Tools/Viewer.exe", "", ""}}, root.string(), &recipe, &reason));
diff --git a/tests/homebrew_live_model_test.cpp b/tests/homebrew_live_model_test.cpp
index ec114dc..c73a135 100644
--- a/tests/homebrew_live_model_test.cpp
+++ b/tests/homebrew_live_model_test.cpp
@@ -662,6 +662,56 @@ void live_program_change_applies_like_other_settings(const std::filesystem::path
"program: the reset applies the same way");
}
+// Steam's default only starts the game, so Playden starts a program found in the game's files: the game page says which
+// and where to change it, and the note goes once the player picks Steam's option.
+void live_names_program_found_instead_of_steam_default(const std::filesystem::path& base) {
+ using playden::homebrew::GameId;
+ using playden::homebrew::TitleActivity;
+ std::filesystem::create_directories(base);
+ auto model = make_live(base);
+ model.SetGameSettingsFile(base / "swap-settings.json");
+ model.SetSettingsData({{"playden-default", "Playden default", "Most games", "", {}}}, {});
+ model.UpdateAccount({AuthState::SignedIn, "account", "Owner", {}, {}, false});
+ playden::GameSummary game;
+ game.id = SteamId(241720);
+ game.title = "Guncraft";
+ check(model.UpdateLibrary({{game}, false, {}, false, true, 100}), "swap: library delivered");
+ model.UpdateInstalls({}, {{SteamId(241720), 1024, "internal", true}});
+ playden::runtime::GameRecipe recipe;
+ recipe.id = playden::runtime::GeneratedRecipeId(241720);
+ recipe.version = 2;
+ recipe.app_id = 241720;
+ recipe.name = game.title;
+ recipe.launch_entries = {{"game", "Guncraft.exe", "Bin/Guncraft.exe", "", ""},
+ {"launch-1", "Guncraft", "Launcher.exe", "", ""}};
+ model.SetGeneratedRecipes({recipe});
+ playden::homebrew::LiveRuntimeGame runtime;
+ runtime.game_id = SteamId(241720);
+ runtime.status = "Ready";
+ runtime.ready = runtime.prepared = runtime.has_title = runtime.can_play = true;
+ runtime.launch_entry_id = "game";
+ runtime.activity = TitleActivity::Stopped;
+ model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, {runtime});
+ check(model.action("details:241720"), "swap: open details");
+ const auto* hint = find_row(model, "details-hint");
+ check(hint && hint->title == "Starts Guncraft.exe because Steam's default program only starts the game. "
+ "You can change it in Game settings.",
+ "swap: the game page names the program that starts");
+
+ activate(model, "details-more");
+ activate(model, "game-settings");
+ (void)model.TakeActivityRequests();
+ check(find_row(model, "setting-launch_option")->subtitle ==
+ "Found in the game's files: Steam's default program only starts the game.",
+ "swap: the Program row says why");
+ activate(model, "setting-launch_option");
+ activate(model, "choice-1");
+ check(find_row(model, "setting-launch_option")->subtitle.rfind("Which program starts when you press Play.", 0) == 0,
+ "swap: Steam's option has the usual description");
+ while (!model.state().navigation.modals.empty()) model.action("circle");
+ check(!find_row(model, "details-hint"), "swap: no note once the player picks Steam's option");
+}
+
// Run launcher or setup (Game actions): a program from the game folder, its settings launcher, starts once through
// Play's own request, which carries the program; Game settings and the next Play stay the game's.
void live_runs_setup_program_once(const std::filesystem::path& base) {
@@ -2586,6 +2636,7 @@ int main() {
live_refresh_rate_keeps_off_over_a_preset_cap(base / "capped");
live_update_runtime_from_maintenance(base / "update-runtime");
live_program_change_applies_like_other_settings(base);
+ live_names_program_found_instead_of_steam_default(base);
live_runs_setup_program_once(base);
live_imported_game_steam_app_id(base);
live_imported_program_seeds_once(base);