Xbox Cloud Gaming app for PS5 Homebrew
C
fix(ui): prevent autoplayScreens from immediately closing Report a Problem QR modal
Rafael Abud Ferreirad5f8e284cf44
diff --git a/src/app/autoplay.cpp b/src/app/autoplay.cppindex 7118c54..da19dec 100644--- a/src/app/autoplay.cpp+++ b/src/app/autoplay.cpp@@ -34,6 +34,7 @@ bool uiSaved = false;bool settingsShot = false; // "settingstest": save the screen nowbool bitrateShot = false; // "bitratetest": save the screen nowbool donationShot = false; // "donationtest": save the screen now+bool reportShot = false; // "reporttest": save report.ppm nowbool signInCheckShot = false; // "checksignintest": save the screen nowbool freeUiShot = false, freeDetailsShot = false; // "freetest": save free account screenshotsconst char* keysShot = nullptr; // "keystest": the screen to save now@@ -171,6 +172,7 @@ void loadAutoplay() {if (opt == "regiontest") g_autoplay.regionTest = true;if (opt == "tlscheck") g_autoplay.tlsCheck = true;if (opt == "donationtest") g_autoplay.donationTest = true;+ if (opt == "reporttest") g_autoplay.reportTest = true;if (opt == "norestart") g_autoplay.noRestart = true;if (opt.rfind("threads=", 0) == 0) g_autoplay.decodeThreads = std::atoi(opt.c_str() + 8);}@@ -994,9 +996,29 @@ void autoplayNav(ui::NavInput& nav, bool& menuCombo, uint64_t now) {if (next) ++step;}}++ if (g_autoplay.reportTest && uiSaved) {+ static uint64_t since = 0;+ static int step = 0;+ if (!since) since = now;+ const uint64_t at[] = {500, 1500, 3500, 4500};+ if (step < 4 && now - since >= at[step]) {+ if (step == 0) nav.options = true;+ if (step == 1) nav.triangle = true;+ if (step == 2) reportShot = true;+ if (step == 3) {+ nav.back = true;+ g_ui->showHome();+ g_autoplay.reportTest = false;+ XC_LOGI("AUTOPLAY END: report test");+ }+ ++step;+ }+ }}void autoplayScreens(const ui::Canvas& canvas, uint64_t now) {+ if (g_autoplay.title.empty()) return;// Autoplay: save the rendered home and loading screens.auto saveCanvas = [&](const char* name) {std::string ppm = "P6\n1920 1080\n255\n";@@ -1100,7 +1122,7 @@ void autoplayScreens(const ui::Canvas& canvas, uint64_t now) {errorSince = 1;}}- if (g_ui->reportOpen() && !g_autoplay.crashTest) {+ if (g_ui->reportOpen() && !g_autoplay.crashTest && !g_autoplay.reportTest) {ui::NavInput in{};in.back = true;g_ui->handle(in);@@ -1180,6 +1202,11 @@ void autoplayScreens(const ui::Canvas& canvas, uint64_t now) {saveCanvas("donation.ppm");XC_LOGI("AUTOPLAY END: donation screenshot saved");}+ if (reportShot) {+ reportShot = false;+ saveCanvas("report.ppm");+ XC_LOGI("AUTOPLAY: report.ppm saved");+ }if (signInCheckShot) {signInCheckShot = false;saveCanvas("signin_check.ppm");diff --git a/src/app/autoplay.h b/src/app/autoplay.hindex 7ea8851..fe3a3b4 100644--- a/src/app/autoplay.h+++ b/src/app/autoplay.h@@ -104,6 +104,7 @@ struct Autoplay {// closed unchanged), Settings on the sign-in country (region_settings.ppm), back// (region_back.ppm). The sign-in country is never changed.bool donationTest = false; // donationtest: navigate to Settings row 19, open donation modal, save donation.ppm+ bool reportTest = false; // reporttest: open Settings, press Triangle for Report a problem, save report.ppm};extern Autoplay g_autoplay;extern std::atomic<bool> g_syntheticA; // A held down for the gamediff --git a/src/ui/app_ui_internal.h b/src/ui/app_ui_internal.hindex c5c908b..3964a0b 100644--- a/src/ui/app_ui_internal.h+++ b/src/ui/app_ui_internal.h@@ -312,18 +312,26 @@ inline void drawFaceButton(Canvas& c, const Font& letters, int icon, float cx, f// about `target` px of code; the card's rect (empty when it can't be encoded).inline Rect drawQr(Canvas& c, const std::string& url, int right, int top, int target,qrcodegen_Ecc ecc = qrcodegen_Ecc_MEDIUM) {- uint8_t qr[qrcodegen_BUFFER_LEN_MAX], tmp[qrcodegen_BUFFER_LEN_MAX];- if (!qrcodegen_encodeText(url.c_str(), tmp, qr, ecc, qrcodegen_VERSION_MIN, qrcodegen_VERSION_MAX,- qrcodegen_Mask_AUTO, true))- return {};- int n = qrcodegen_getSize(qr);+ static std::string s_cachedUrl;+ static qrcodegen_Ecc s_cachedEcc = qrcodegen_Ecc_MEDIUM;+ static uint8_t s_qr[qrcodegen_BUFFER_LEN_MAX]{};+ static bool s_valid = false;+ if (url != s_cachedUrl || ecc != s_cachedEcc) {+ uint8_t tmp[qrcodegen_BUFFER_LEN_MAX];+ s_valid = qrcodegen_encodeText(url.c_str(), tmp, s_qr, ecc, qrcodegen_VERSION_MIN, qrcodegen_VERSION_MAX,+ qrcodegen_Mask_AUTO, true);+ s_cachedUrl = url;+ s_cachedEcc = ecc;+ }+ if (!s_valid) return {};+ int n = qrcodegen_getSize(s_qr);int module = target / (n + 2), size = module * (n + 2);Rect box{right - size - 40, top, size + 40, size + 40};c.fillRect(box, kWhite, 20);int ox = box.x + 20 + module, oy = box.y + 20 + module;for (int yy = 0; yy < n; ++yy)for (int xx = 0; xx < n; ++xx)- if (qrcodegen_getModule(qr, xx, yy)) c.fillRect({ox + xx * module, oy + yy * module, module, module}, kBg);+ if (qrcodegen_getModule(s_qr, xx, yy)) c.fillRect({ox + xx * module, oy + yy * module, module, module}, kBg);return box;}