Play your Steam library's Windows games on a jailbroken PS5.
C++
Add Play with detailed logs to a game's actions
Leonardo Lobatoa51e115845c9
diff --git a/src/homebrew/controller.cpp b/src/homebrew/controller.cppindex 96f942a..208bc38 100644--- a/src/homebrew/controller.cpp+++ b/src/homebrew/controller.cpp@@ -1240,8 +1240,11 @@ void Controller::TickRuntime() {{const auto current_shared = runtime_->Shared();const auto& current = *current_shared;- if (current.handoff_ready && current.launch && !cloud_busy_.count(current.launch->game))+ if (current.handoff_ready && current.launch && !cloud_busy_.count(current.launch->game)) {+ // This start's settings are published; Playden may not get to run again once the game takes over.+ model_.EndOneSessionLogging(current.launch->game);runtime_->Handoff();+ }}const auto snapshot_shared = runtime_->Shared();const auto& snapshot = *snapshot_shared;diff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cppindex 7d2620b..f1fe58d 100644--- a/src/homebrew/simulation.cpp+++ b/src/homebrew/simulation.cpp@@ -548,7 +548,7 @@ std::string action_label(const std::string& key) {{"install-confirm", "Install"}, {"install-version", "Version"}, {"install-language", "Language"}, {"install-dlc", "DLC"}, {"install-dlc-all", "All DLC"}, {"install-dlc-done", "Done"}, {"heading-dlc-included", "Included"}, {"heading-dlc-optional", "Optional"}, {"update-confirm", "Download and install"}, {"storage-picker", "Change storage…"},{"value-edit", "Edit…"}, {"value-reset", "Reset to recipe"}, {"override-add", "Add an override…"},{"unlock-setting", "Change anyway"}, {"export-recipe", "Export as recipe"}, {"program-scan", "Looking for programs…"},- {"preset-picker", "Preset"}, {"game-settings", "Game settings"}, {"game-maintenance", "Maintenance"}, {"run-once", "Run launcher or setup…"}, {"run-once-start", "Run once"}, {"game-move", "Move to…"}, {"runtime-check-again", "Check again"}, {"reset-settings", "Reset all to preset"}, {"clear-shader-cache", "Clear shader cache"},+ {"preset-picker", "Preset"}, {"game-settings", "Game settings"}, {"game-maintenance", "Maintenance"}, {"run-once", "Run launcher or setup…"}, {"play-detailed-logs", "Play with detailed logs"}, {"run-once-start", "Run once"}, {"game-move", "Move to…"}, {"runtime-check-again", "Check again"}, {"reset-settings", "Reset all to preset"}, {"clear-shader-cache", "Clear shader cache"},{"section-compatibility", "Compatibility"}, {"section-advanced", "Advanced"}, {"heading-game", "Game"},{"heading-display", "Display"}, {"heading-controls", "Controls"}, {"heading-sound", "Sound"},{"heading-graphics", "Graphics"}, {"heading-windows", "Windows"}, {"heading-sort", "Sort"}, {"heading-filter", "Filter"},@@ -2705,18 +2705,12 @@ void Simulation::UpdateRuntime(RuntimeState runtime, const std::vector<LiveRuntipush_notice({"maintenance-" + ToKey(id), game.maintenance_ok ? title + ": done" : title + ": not done", "",false, kLiveNoticeSeconds * (game.maintenance_ok ? 1 : 2), !game.maintenance_ok, game.maintenance_message});}- // A Playden session ended: verbose or input logging lasts one session and goes back to Normal,- // and settings saved while the game ran are applied now, so a start from Home uses them.+ // A session that didn't come through the handoff (the Controller ends the logging there first).+ const auto started = [](const LiveRuntimeGame& value) { return value.play_status == "Starting…" || value.play_status == "Playing"; };+ if (started(game) && !started(before->second)) EndOneSessionLogging(id);+ // A Playden session ended: settings saved while the game ran are applied now, so a start from Home uses them.if (before->second.play_status == "Playing" && game.play_status != "Playing") {const auto record = state_.game_settings.find(id);- if (record != state_.game_settings.end() && record->second.overrides.count("logging") &&- record->second.overrides.at("logging") != "normal" && can_change_game_settings()) {- record->second.overrides.erase("logging");- ++record->second.revision;- save_profile();- push_notice({"verbose-logging-" + ToKey(id), "Detailed logging is off again", "", false,- kLiveNoticeSeconds, false, title + " logs at the Normal level from its next start"});- }if (game.prepared && record != state_.game_settings.end() && record->second.revision > game.settings_revision)pending_maintenance_requests_.push_back({id, MaintenanceKind::ApplySettings});}@@ -6396,6 +6390,10 @@ void Simulation::rebuild_view() {record->second.revision > runtime_game->second.settings_revision)item.subtitle = "Changes apply on next launch";}+ } else if (action_key == "play-detailed-logs") {+ const auto runtime_game = state_.runtime_games.find(state_.navigation.selected_game_id);+ item.enabled = runtime_game != state_.runtime_games.end() && runtime_game->second.can_play;+ item.subtitle = "For this start only";} else if (action_key == "run-once") {// Only a game known to run waits: opening the list asks whether it runs, and Run once checks again.std::string refusal;@@ -9170,8 +9168,17 @@ void Simulation::activate() {pending_runtime_cleanup_ = true;close_modal();push_notice({"runtime-cleanup", "Unused game settings data cleaned up", "", false, kLiveNoticeSeconds, false, ""});- } else if (live() && action_name == "runtime-play") {+ } else if (live() && (action_name == "runtime-play" || action_name == "play-detailed-logs")) {const auto id = state_.navigation.detail_id.value_or(state_.navigation.selected_game_id);+ if (action_name == "play-detailed-logs") {+ // Verbose for this one start; Normal again as it starts.+ state_.navigation.selected_game_id = id;+ set_game_setting("logging", "verbose");+ close_modal();+ state_.navigation.focus_key = "details-play";+ // Play reads the settings from disk: without them it would log nothing more.+ if (!save_profile()) return;+ }if (id.valid() && !update_locked(id)) {// A new attempt may fail for the same reason; only background refreshes// should be deduplicated against the previous outcome.@@ -11121,7 +11128,8 @@ std::vector<std::string> Simulation::details_context_actions() const {// A program from the game folder (its settings launcher) for one run, after Maintenance.if (live() && game_prepared(selected)) {const auto maintenance = std::find(actions.begin(), actions.end(), "game-maintenance");- actions.insert(maintenance == actions.end() ? actions.begin() : maintenance + 1, "run-once");+ const auto run_once = actions.insert(maintenance == actions.end() ? actions.begin() : maintenance + 1, "run-once");+ actions.insert(run_once + 1, "play-detailed-logs");}return actions;}@@ -11452,6 +11460,19 @@ void Simulation::announce_settings_saved() {if (live() && game_prepared(game)) pending_maintenance_requests_.push_back({game, MaintenanceKind::ApplySettings});}+void Simulation::EndOneSessionLogging(GameId id) {+ const auto record = state_.game_settings.find(id);+ if (record == state_.game_settings.end() || !record->second.overrides.count("logging") ||+ record->second.overrides.at("logging") == "normal" || !can_change_game_settings())+ return;+ record->second.overrides.erase("logging");+ ++record->second.revision;+ save_profile();+ const auto* known = find_game(state_, id);+ push_notice({"verbose-logging-" + ToKey(id), "Detailed logging is off again", "", false, kLiveNoticeSeconds, false,+ (known ? known->title : std::string("The game")) + " logs at the Normal level from its next start"});+}+bool Simulation::can_change_game_settings() {const auto found = state_.game_settings.find(state_.navigation.selected_game_id);if (found == state_.game_settings.end() || found->second.revision != std::numeric_limits<std::uint64_t>::max()) return true;diff --git a/src/homebrew/simulation.hpp b/src/homebrew/simulation.hppindex bd3a031..efed426 100644--- a/src/homebrew/simulation.hpp+++ b/src/homebrew/simulation.hpp@@ -1014,6 +1014,8 @@ public:// Queues Prepare without a button press: after a download, or before Play.void RequestRuntimePrepare(GameId id);[[nodiscard]] std::vector<GameId> TakeRuntimePlayRequests();+ // Verbose or input logging lasts one session: back to Normal for the game's next start, as this one starts.+ void EndOneSessionLogging(GameId id);// The Play requests above that run a program from the game folder once instead of the game (Run a program// once…): the program, relative to the game folder. A plain Play request of the same game replaces its entry.[[nodiscard]] std::map<GameId, std::string> TakeRuntimeSetupPrograms();diff --git a/tests/homebrew_live_model_test.cpp b/tests/homebrew_live_model_test.cppindex 23d1f8b..9418705 100644--- a/tests/homebrew_live_model_test.cpp+++ b/tests/homebrew_live_model_test.cpp@@ -795,6 +795,52 @@ void live_runs_setup_program_once(const std::filesystem::path& base) {"launcher hint: it turns the setting on and plays");model.NotifyLauncherHint(SteamId(35140), "Binaries/BatmanAC.exe");check(model.state().navigation.modals.empty(), "launcher hint: not offered with the setting on");++ // Play with detailed logs: Verbose for this start, Normal again as the game starts, even if it crashes right+ // away or Playden quits before seeing the session end.+ {+ auto idle = runtime;+ idle.activity = TitleActivity::Stopped;+ idle.can_play = true;+ idle.prepared = true;+ model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, {idle});+ activate(model, "details-more");+ check(find_row(model, "play-detailed-logs") && find_row(model, "play-detailed-logs")->enabled, "detailed logs: offered");+ (void)model.TakeRuntimePlayRequests();+ activate(model, "play-detailed-logs");+ const auto plays = model.TakeRuntimePlayRequests();+ check(std::count(plays.begin(), plays.end(), SteamId(35140)) == 1 && model.state().navigation.modals.empty(), "detailed logs: it plays");+ const auto& logged = model.state().game_settings.at(SteamId(35140));+ check(logged.overrides.at("logging") == "verbose", "detailed logs: Verbose for this start");+ const auto revision = logged.revision;+ auto starting = idle;+ starting.play_status = "Starting…";+ starting.can_play = false;+ model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, {starting});+ check(!model.state().game_settings.at(SteamId(35140)).overrides.count("logging") &&+ model.state().game_settings.at(SteamId(35140)).revision > revision,+ "detailed logs: Normal again as the game starts");+ model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, {idle});+ activate(model, "details-more");+ auto busy = idle;+ busy.can_play = false;+ model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, {busy});+ check(!find_row(model, "play-detailed-logs")->enabled, "detailed logs: only when Play could start it");+ model.action("circle");+ // Ended before the handoff, as the Controller does it: the game's next start is Normal even if Playden stops here.+ model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, {idle});+ activate(model, "details-more");+ activate(model, "play-detailed-logs");+ (void)model.TakeRuntimePlayRequests();+ model.EndOneSessionLogging(SteamId(35140));+ check(!model.state().game_settings.at(SteamId(35140)).overrides.count("logging"), "detailed logs: over before the handoff");+ // Settings that can't be saved: Play would read the old ones, so it doesn't start.+ model.SetGameSettingsFile(base / "missing-folder" / "settings.json");+ activate(model, "details-more");+ activate(model, "play-detailed-logs");+ check(model.TakeRuntimePlayRequests().empty(), "detailed logs: doesn't start without saved settings");+ model.UpdateRuntime(playden::homebrew::RuntimeState::Ready, {runtime});+ }}void live_download_telemetry() {