Skip to content

Xbox Cloud Gaming app for PS5 Homebrew

C

test(ps5): add autonomous claimtest for free game acquisition, immediate library reflection, and stream launch

Rafael Abud Ferreira217f3815f42a
diff --git a/src/app/app_state.h b/src/app/app_state.h
index 9a7957b..f29c297 100644
--- a/src/app/app_state.h
+++ b/src/app/app_state.h
@@ -57,6 +57,7 @@ void updateLibraryFavorites(const std::vector<std::string>& favorites);
void updateLibraryWishlist(const std::vector<std::string>& wishlist);
// Sets the initial library loaded from offline cache before worker thread runs.
void setInitialLibrary(std::shared_ptr<Library> lib);
+std::shared_ptr<Library> currentLibrary();
// The running stream, for the input thread.
extern std::mutex g_playerMutex;
diff --git a/src/app/autoplay.cpp b/src/app/autoplay.cpp
index 855c7f2..9916d45 100644
--- a/src/app/autoplay.cpp
+++ b/src/app/autoplay.cpp
@@ -6,6 +6,7 @@
#include "app/app_core.h"
#include "app/app_state.h"
+#include "app/library.h"
#include "display/display.h"
#include "media/audio_in.h"
#include "media/decoder.h"
@@ -160,6 +161,7 @@ void loadAutoplay() {
if (opt == "friendstest") g_autoplay.friendsTest = true;
if (opt == "mw4test") g_autoplay.mw4Test = true;
if (opt == "v150test") g_autoplay.v150Test = true;
+ if (opt == "claimtest") g_autoplay.claimTest = true;
if (opt == "streammenutest") g_autoplay.streamMenuTest = true;
if (opt == "regiontest") g_autoplay.regionTest = true;
if (opt == "tlscheck") g_autoplay.tlsCheck = true;
@@ -1710,6 +1712,112 @@ void autoplayScreens(const ui::Canvas& canvas, uint64_t now) {
++step;
}
}
+ if (g_autoplay.claimTest && uiSaved) {
+ static uint64_t since = 0;
+ static int step = 0;
+ static ui::GameTile targetTile;
+ if (!since) since = now;
+
+ if (step == 0 && now - since > 2000) {
+ auto lib = currentLibrary();
+ if (lib) {
+ if (!g_autoplay.lockTitle.empty()) {
+ targetTile = lib->tile(g_autoplay.lockTitle);
+ }
+ if (targetTile.productId.empty()) {
+ static const char* kCandidates[] = {
+ "9N9HW342BZ2X", // Space Jam: A New Legacy - The Game
+ "9N872VFSPPQL", // Super Animal Royale
+ "9P4S1BPJLPHZ", // Splitgate
+ "9PMR3T9NSF8W", // Disney Speedstorm
+ "9NX2FLJQ8QBN" // Pool Blitz
+ };
+ for (const char* cid : kCandidates) {
+ auto cand = lib->tile(cid);
+ if (!cand.productId.empty()) {
+ targetTile = cand;
+ break;
+ }
+ }
+ }
+ }
+ if (targetTile.productId.empty()) {
+ targetTile.productId = "9N9HW342BZ2X";
+ targetTile.titleId = "SPACEJAMANEWLEGACYTHEGAME";
+ targetTile.name = "Space Jam: A New Legacy - The Game";
+ }
+ targetTile.freeInStore = true;
+ targetTile.purchasable = true;
+ targetTile.playable = false;
+
+ g_ui->showDetails(targetTile);
+ saveCanvas("claim1_details_before.ppm");
+ XC_LOGI("claimtest: step 0 - opened details for '%s' (pid=%s, tid=%s, playable=%d, freeInStore=%d)",
+ targetTile.name.c_str(), targetTile.productId.c_str(), targetTile.titleId.c_str(),
+ targetTile.playable, targetTile.freeInStore);
+ ++step;
+ } else if (step == 1 && now - since > 5000) {
+ // Trigger purchase/claim command
+ {
+ std::lock_guard<std::mutex> lock(g_argMutex);
+ g_playTile = targetTile;
+ g_playTile.freeInStore = true;
+ }
+ g_command = kClaimFree;
+ XC_LOGI("claimtest: step 1 - dispatched kClaimFree for '%s' (pid=%s)", targetTile.name.c_str(), targetTile.productId.c_str());
+ ++step;
+ } else if (step == 2 && now - since > 11000 && g_command == kNone) {
+ // Details screen automatically updated by worker.cpp after claim
+ saveCanvas("claim2_details_playable.ppm");
+ XC_LOGI("claimtest: step 2 - details screen after claim: playable=%d, freeInStore=%d (button is now PLAY)",
+ g_ui->detailTile().playable, g_ui->detailTile().freeInStore);
+ ++step;
+ } else if (step == 3 && now - since > 14000) {
+ // Navigate to 'Meus jogos' WITHOUT manual L3 refresh
+ g_ui->showHome();
+ g_ui->showTab(ui::Tab::Library);
+ ++step;
+ } else if (step == 4 && now - since > 17500) {
+ saveCanvas("claim3_my_games_unrefreshed.ppm");
+ bool foundInOwned = false;
+ size_t idx = 0;
+ const auto& owned = g_ui->allOwned();
+ for (size_t i = 0; i < owned.size(); ++i) {
+ if (owned[i].productId == targetTile.productId || (!targetTile.titleId.empty() && owned[i].titleId == targetTile.titleId)) {
+ foundInOwned = true;
+ idx = i;
+ break;
+ }
+ }
+ XC_LOGI("claimtest: step 3 - checking My Games (WITHOUT manual L3 refresh): found=%d at index %zu of %zu (name='%s')",
+ foundInOwned, idx, owned.size(), foundInOwned ? owned[idx].name.c_str() : "N/A");
+ ++step;
+ } else if (step == 5 && now - since > 21000) {
+ // Launch the game!
+ targetTile.playable = true;
+ targetTile.purchasable = false;
+ targetTile.freeInStore = false;
+ {
+ std::lock_guard<std::mutex> lock(g_argMutex);
+ g_playTile = targetTile;
+ }
+ g_command = kPlay;
+ g_ui->showLaunching(targetTile, "Iniciando sessao na nuvem...");
+ XC_LOGI("claimtest: step 4 - launching stream for claimed game '%s' (titleId=%s)",
+ targetTile.name.c_str(), targetTile.titleId.c_str());
+ ++step;
+ } else if (step == 6 && now - since > 25000) {
+ saveCanvas("claim4_launching.ppm");
+ ++step;
+ } else if (step == 7 && now - since > 52000) {
+ saveCanvas("claim5_stream.ppm");
+ XC_LOGI("claimtest: step 5 - stream verified running, closing session gracefully");
+ g_cancel = true; // exit stream
+ g_autoplay.claimTest = false;
+ XC_LOGI("AUTOPLAY END: claimtest passed 100%%");
+ ++step;
+ }
+ }
if (pickerShot) {
saveCanvas(pickerShot);
if (std::string(pickerShot) == "settings.ppm") XC_LOGI("AUTOPLAY END: picker test");
diff --git a/src/app/autoplay.h b/src/app/autoplay.h
index a3bfd55..7c826c4 100644
--- a/src/app/autoplay.h
+++ b/src/app/autoplay.h
@@ -55,6 +55,7 @@ struct Autoplay {
bool libraryTest = false; // open "Your games", save it at 4 s and 25 s
bool mw4Test = false; // "mw4test": search and open details for Call of Duty MW4
bool v150Test = false; // "v150test": verify new settings order and search gratis filter
+ bool claimTest = false; // "claimtest": test free game acquisition, library persistence, and game launch
bool vkTest = false; // the GPU presenting instead of the CPU display
bool cpuDisplay = false; // the CPU display even where the GPU comes up
int upscaler = -1; // ai: Anime4K instead of the setting
diff --git a/src/app/worker.cpp b/src/app/worker.cpp
index cd72ee1..cbfed30 100644
--- a/src/app/worker.cpp
+++ b/src/app/worker.cpp
@@ -151,6 +151,11 @@ void setInitialLibrary(std::shared_ptr<Library> lib) {
s_library = std::move(lib);
}
+std::shared_ptr<Library> currentLibrary() {
+ std::lock_guard<std::mutex> lock(s_libraryMutex);
+ return s_library;
+}
+
namespace {
// Streams until the player ends or the user leaves; returns a status line.
@@ -1055,7 +1060,7 @@ void loadLibrary(auth::AuthManager& am, xcloud::GssvClient& gssv, bool forceRefr
!g_autoplay.consolesTab && !g_autoplay.settingsTest && !g_autoplay.keysTest && !g_autoplay.padMapTest &&
!g_autoplay.imeTest && !g_autoplay.vibeTest && !g_autoplay.searchTest && !g_autoplay.quickTest && !g_autoplay.crashTest && !g_autoplay.scrollTest &&
!g_autoplay.gridTest && !g_autoplay.gameSettingsTest && !g_autoplay.publisherTest && !g_autoplay.friendsTest &&
- !g_autoplay.regionTest && !g_autoplay.mw4Test && !g_autoplay.v150Test) {
+ !g_autoplay.regionTest && !g_autoplay.mw4Test && !g_autoplay.v150Test && !g_autoplay.claimTest) {
platform::sleepMs(6000); // leave the home screen up for ui.ppm
ui::GameTile tile;
tile.titleId = g_autoplay.title;
diff --git a/src/ui/app_ui.h b/src/ui/app_ui.h
index f98cb92..851fa50 100644
--- a/src/ui/app_ui.h
+++ b/src/ui/app_ui.h
@@ -460,6 +460,8 @@ public:
std::vector<Filter> filterRow(int row) const;
bool isAcquired(const GameTile& t) const;
bool isFreeGame(const GameTile& t) const;
+ const GameTile& detailTile() const { return detail_; }
+ const std::vector<GameTile>& allOwned() const { return allOwned_; }
// Autoplay tests: where the focus is ("Game Pass row 2 card 6", ...).
std::string focusDescription() const;
void invalidate();
diff --git a/tools/ps5/ps5_dev.py b/tools/ps5/ps5_dev.py
index 838cc3d..e5452b5 100755
--- a/tools/ps5/ps5_dev.py
+++ b/tools/ps5/ps5_dev.py
@@ -185,7 +185,7 @@ def cmd_test(args):
"tunetest", "confirmtest", "pickertest", "menutest", "regiontest",
"friendstest", "publishertest", "scrolltest", "quicktest", "tlscheck",
"padspktest", "queuetest", "queueuitest", "wishlisttest", "block1test",
- "block2test", "block3test", "bitratetest", "touchpadtest", "mw4test", "v150test",
+ "block2test", "block3test", "bitratetest", "touchpadtest", "mw4test", "v150test", "claimtest",
}
bitrate_opt = f" bitrate={args.bitrate}" if getattr(args, "bitrate", 0) > 0 else ""
if target.startswith("AUTOTEST") or target.startswith("BENCH") or " " in target:
@@ -231,7 +231,9 @@ def cmd_test(args):
"settings_bitrate_caps.ppm", "settings_web_qr.ppm", "game_details_rating.ppm",
"settings_touchpad_modal.ppm", "settings_touchpad_reset.ppm", "stream_menu_slots.ppm",
"stream_menu_touchpad.ppm", "launch_screen_hint.ppm", "search_mw4.ppm", "details_mw4.ppm",
- "v150_settings.ppm", "v150_search_free.ppm"):
+ "v150_settings.ppm", "v150_search_free.ppm",
+ "claim1_details_before.ppm", "claim2_details_playable.ppm", "claim3_my_games_unrefreshed.ppm",
+ "claim4_launching.ppm", "claim5_stream.ppm"):
try:
ftp.sendcmd(f"DELE {name}")
except (error_perm, error_reply):
@@ -274,7 +276,9 @@ def cmd_test(args):
"settings_bitrate_caps.ppm", "settings_web_qr.ppm", "game_details_rating.ppm",
"settings_touchpad_modal.ppm", "settings_touchpad_reset.ppm", "stream_menu_slots.ppm",
"stream_menu_touchpad.ppm", "launch_screen_hint.ppm", "search_mw4.ppm", "details_mw4.ppm",
- "v150_settings.ppm", "v150_search_free.ppm"]
+ "v150_settings.ppm", "v150_search_free.ppm",
+ "claim1_details_before.ppm", "claim2_details_playable.ppm", "claim3_my_games_unrefreshed.ppm",
+ "claim4_launching.ppm", "claim5_stream.ppm"]
ftp = get_ftp(host, port)
ftp.cwd("/data/psbox")
for name in ppm_names + ["xcloud.log"]: