Skip to content

Xbox Cloud Gaming app for PS5 Homebrew

C

Keep the user's data in /data/psbox, outside the app's folder

Rafael Abud Ferreirab8ad861d687a
diff --git a/.agents/skills/ps5-console-testing/SKILL.md b/.agents/skills/ps5-console-testing/SKILL.md
index ed33ed7..9954482 100644
--- a/.agents/skills/ps5-console-testing/SKILL.md
+++ b/.agents/skills/ps5-console-testing/SKILL.md
@@ -54,7 +54,7 @@ PS5_HOST=192.168.15.17 ./tools/ps5/deploy.sh build-ps5
## 4. Headless Autoplay Navigation & Screenshot Configuration
-The application supports automated scripted actions configured via `/data/homebrew/PPSA99810/autoplay.txt`.
+The application supports automated scripted actions configured via `/data/psbox/autoplay.txt` (the data folder since v0.9.7: logs and `.ppm` captures are there too).
### Format of `autoplay.txt`:
```text
@@ -91,7 +91,7 @@ from ftplib import FTP, error_perm, error_reply
host = "192.168.15.17"
port = 2121
-remote_dir = "/data/homebrew/PPSA99810"
+remote_dir = "/data/psbox" # data folder (v0.9.7+): autoplay.txt, logs, captures
ftp = FTP()
ftp.connect(host, port, timeout=15)
@@ -143,7 +143,7 @@ from PIL import Image
host = "192.168.15.17"
port = 2121
-remote_dir = "/data/homebrew/PPSA99810"
+remote_dir = "/data/psbox" # data folder (v0.9.7+): autoplay.txt, logs, captures
out_dir = "/tmp/ps5_shots"
os.makedirs(out_dir, exist_ok=True)
@@ -184,7 +184,7 @@ from ftplib import FTP, error_perm, error_reply
ftp = FTP()
ftp.connect("192.168.15.17", 2121, timeout=15)
ftp.login()
-ftp.cwd("/data/homebrew/PPSA99810")
+ftp.cwd("/data/psbox")
try:
ftp.sendcmd("DELE autoplay.txt")
print("Deleted autoplay.txt successfully.")
diff --git a/.github/triage/triage.py b/.github/triage/triage.py
index f09855f..0f731ee 100644
--- a/.github/triage/triage.py
+++ b/.github/triage/triage.py
@@ -119,7 +119,7 @@ def triage(issue, rules, latest):
elif not release:
asks.append("the **app release** (Settings > Updates shows it, e.g. v0.9.6)")
if fields and not looks_like_log(log):
- asks.append("the **xcloud.log** (in `/data/homebrew/PPSA99810/` over FTP, or use *Report a problem* "
+ asks.append("the **xcloud.log** (`/data/psbox/xcloud.log` over FTP; before v0.9.7 in `/data/homebrew/PPSA99810/`, or use *Report a problem* "
"(△ in Settings or on the error) to fill this form from the app)")
if asks:
labels.append("needs-info")
diff --git a/AGENTS.md b/AGENTS.md
index c816a9f..b16f823 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -31,7 +31,7 @@ Para qualquer alteração em arquivos de interface (`src/app_ui.cpp`, `src/app/a
PS5_HOST=192.168.15.17 ./tools/ps5/deploy.sh build-ps5
```
4. **Configurar teste autônomo (`autoplay.txt`)**:
- - Enviar `/data/homebrew/PPSA99810/autoplay.txt` via FTP.
+ - Enviar `/data/psbox/autoplay.txt` via FTP (desde a v0.9.7 os dados do app, logs e capturas `.ppm` ficam em `/data/psbox`; o app continua instalado em `/data/homebrew/PPSA99810`).
- **Regra obrigatória para testes de UI**: Sempre utilize o prefixo `AUTOTEST` (ex: `AUTOTEST 30 gamesettingstest`, `AUTOTEST 30 librarytest`, etc.) para testes de telas/modais sem streaming. NUNCA use nomes arbitrários no primeiro argumento que possam ser interpretados como IDs de jogos pelo loop de streaming (`worker.cpp`).
- Remover capturas `.ppm` antigas antes de iniciar.
5. **Iniciar a aplicação remotamente**:
@@ -44,7 +44,7 @@ Para qualquer alteração em arquivos de interface (`src/app_ui.cpp`, `src/app/a
- Usar a ferramenta `view_file` para analisar visualmente a imagem gerada.
- Verificar conformidade: clipping, centralização, padding, corte de texto, contraste e consistência de grade.
7. **Limpeza e Restauração de Modo Interativo**:
- - Excluir `/data/homebrew/PPSA99810/autoplay.txt` via FTP para que a aplicação não inicialize em modo autoplay caso o usuário queira usá-la interativamente.
+ - Excluir `/data/psbox/autoplay.txt` via FTP para que a aplicação não inicialize em modo autoplay caso o usuário queira usá-la interativamente.
- Matar e reiniciar o app se for entregar o controle ao usuário:
```bash
PS5_HOST=192.168.15.17 python3 ../PS5_Vulkan/tools/ps5_console.py kill PPSA99810
diff --git a/README.md b/README.md
index 29d8c01..e1bbd4a 100644
--- a/README.md
+++ b/README.md
@@ -56,11 +56,13 @@ No building needed: download `PPSA99810.zip` from the
New versions install from inside the app (it asks after sign-in, and
Settings > Updates): only a package signed with the project's key is
-accepted, and your sign-in is kept. ProsperoStore's updates replace the
-whole folder; the app brings the sign-in and settings back from the copy
-the store keeps. By hand: close the app and copy the new folder over the
-old one. The sign-in lives in `PPSA99810/account.json`: never share
-that file. More details, controls and troubleshooting are in the
+accepted, and your sign-in is kept. By hand: close the app and copy the
+new folder over the old one. Since v0.9.7 the sign-in, settings, caches
+and log live in `/data/psbox`, outside the app's folder: updating,
+reinstalling or uninstalling the app (also from ProsperoStore) keeps
+them, and the first start moves them there from older versions. The
+sign-in is `/data/psbox/account.json`: never share that file. To remove
+everything the app keeps, delete `/data/psbox` too. More details, controls and troubleshooting are in the
`README.txt` inside the folder.
## Building
diff --git a/SECURITY.md b/SECURITY.md
index 4b9e1a7..7e0f7d9 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -13,7 +13,8 @@ rather stay anonymous.
## Your account
The app stores its Microsoft sign-in (a refresh token) in
-`/data/homebrew/PPSA99810/account.json` on the console. Treat that file like a
+`/data/psbox/account.json` on the console (before v0.9.7:
+`/data/homebrew/PPSA99810/account.json`). Treat that file like a
password: never share it or attach it to an issue. If it may have leaked, sign
out of all sessions at <https://account.microsoft.com/security> and sign in on
the console again. The log (`xcloud.log`) contains no passwords or tokens.
diff --git a/ps5/release/README.txt b/ps5/release/README.txt
index b14c6ec..45658ce 100644
--- a/ps5/release/README.txt
+++ b/ps5/release/README.txt
@@ -46,10 +46,12 @@ The app shows a code. On your phone or computer, open
https://www.microsoft.com/link (or scan the QR code on screen) and enter
that code. Your password is never typed on the console.
-The sign-in is saved in /data/homebrew/@TITLE_ID@/account.json. That
-file gives access to your Microsoft account: never share it, and never
-attach it to a bug report. Signing out (hold TOUCHPAD for 5 seconds
-on the home screen) deletes it.
+The sign-in is saved in /data/psbox/account.json (outside the app's
+folder since v0.9.7, so updating, reinstalling or uninstalling the app
+keeps it). That file gives access to your Microsoft account: never
+share it, and never attach it to a bug report. Signing out (hold
+TOUCHPAD for 5 seconds on the home screen) deletes it. To remove
+everything the app keeps, delete /data/psbox too.
Controls
@@ -109,7 +111,7 @@ region, with the latency measured in your past sessions), the sticks'
dead zone (raise it if a stick drifts), trigger vibration on or off,
the light bar in the colour of the game in focus, and the confirm button (Cross, or Circle as on Japanese consoles: it
then acts as Xbox A in games too). Saved in
-/data/homebrew/@TITLE_ID@/settings.json.
+/data/psbox/settings.json.
@@ -147,7 +149,7 @@ on xbox.com / in the Xbox app) and it appears in Your games.
Problems
--------
-The app writes a log to /data/homebrew/@TITLE_ID@/xcloud.log. It holds
+The app writes a log to /data/psbox/xcloud.log. It holds
nothing of your account: no password, token, sign-in code, gamertag or
PS5 user name. Attach it when you report a problem:
https://github.com/RafaelNGP/xbox-cloud-gaming-ps5/issues
diff --git a/src/app/ps5_main.cpp b/src/app/ps5_main.cpp
index 1c14ec8..4f4b02c 100644
--- a/src/app/ps5_main.cpp
+++ b/src/app/ps5_main.cpp
@@ -164,8 +164,8 @@ int main(int argc, char** argv) {
platform::init();
log::setFile((platform::dataDir() + "/xcloud.log").c_str());
- if (platform::dataDir() != "/data/homebrew/PPSA99810")
- XC_LOGW("data folder: %s (/data/homebrew/PPSA99810 wasn't writable)", platform::dataDir().c_str());
+ if (!platform::dataDirNote().empty())
+ XC_LOGI("data folder %s: %s", platform::dataDir().c_str(), platform::dataDirNote().c_str());
XC_LOGI("=== PSBox Cloud Gaming starting ===");
XC_LOGI("firmware %s, PSBox %s", platform::firmwareVersion().c_str(), XC_APP_VERSION);
// Did the last session go down? (A crash leaves a marker; being closed
@@ -176,7 +176,7 @@ int main(int argc, char** argv) {
loadAutoplay();
// An update cut short: the old files went back, and the old eboot.bin
// is the one to run.
- if (recoverUpdate(platform::dataDir())) platform::restartApp();
+ if (recoverUpdate(platform::appDir())) platform::restartApp();
importStoreLeftovers(platform::dataDir(), "/data/prosperostore/previous/PPSA99810");
struct stat settingsStat;
if (!g_settings.load(settingsPath()) && ::stat(settingsPath().c_str(), &settingsStat) == 0) {
diff --git a/src/app/worker.cpp b/src/app/worker.cpp
index e02abe8..cd43f8b 100644
--- a/src/app/worker.cpp
+++ b/src/app/worker.cpp
@@ -386,9 +386,9 @@ void runUpdate() {
if (r.tag.empty()) return;
XC_LOGI("update to %s: starting", r.tag.c_str());
g_ui->showUpdating(r.tag);
- // Only where the app runs from (/app0 is the data folder): installed
- // elsewhere, it would write next to the wrong eboot.bin.
- std::string dir = platform::dataDir(), err;
+ // Only where the app runs from: installed elsewhere, it would write next
+ // to the wrong eboot.bin.
+ std::string dir = platform::appDir(), err;
struct stat here {}, running {};
bool ok = ::stat((dir + "/eboot.bin").c_str(), &here) == 0 && ::stat("/app0/eboot.bin", &running) == 0 &&
here.st_ino == running.st_ino;
diff --git a/src/platform/host/platform_host.cpp b/src/platform/host/platform_host.cpp
index 8430fe5..bf91882 100644
--- a/src/platform/host/platform_host.cpp
+++ b/src/platform/host/platform_host.cpp
@@ -37,6 +37,8 @@ bool init() {
void shutdown() {}
std::string dataDir() { return g_dataDir; }
+std::string dataDirNote() { return {}; }
+std::string appDir() { return g_dataDir; }
std::string assetDir() {
if (const char* env = std::getenv("XCLOUD_ASSETS")) return env;
diff --git a/src/platform/platform.h b/src/platform/platform.h
index 46d7223..e83256a 100644
--- a/src/platform/platform.h
+++ b/src/platform/platform.h
@@ -16,8 +16,15 @@ namespace xc::platform {
bool init();
void shutdown();
-// Writable directory for tokens, caches and logs (no trailing slash).
+// Writable directory for tokens, caches and logs (no trailing slash). On the
+// PS5 outside the app's folder, so uninstalling, reinstalling or a store
+// update keeps them.
std::string dataDir();
+// What start-up did about the data folder (moved from the app's folder,
+// fell back...), for the log once it is open; empty when nothing.
+std::string dataDirNote();
+// The folder the app runs from (updates are installed there).
+std::string appDir();
// Read-only directory with the bundled assets (fonts, certificates).
std::string assetDir();
// Read-only PEM bundle of trusted root certificates.
diff --git a/src/platform/ps5/platform_ps5.cpp b/src/platform/ps5/platform_ps5.cpp
index 3a0bbc6..762fd12 100644
--- a/src/platform/ps5/platform_ps5.cpp
+++ b/src/platform/ps5/platform_ps5.cpp
@@ -38,7 +38,12 @@ int sceNetResolverDestroy(int rid);
namespace xc::platform {
namespace {
-std::string g_dataDir = "/data/homebrew/PPSA99810";
+// User data (sign-in, settings, caches, log): its own folder, apart from the
+// app's, which installers replace or delete. Before 0.9.7 it was the app's.
+constexpr const char* kDataDir = "/data/psbox";
+constexpr const char* kLegacyDir = "/data/homebrew/PPSA99810";
+std::string g_dataDir = kDataDir;
+std::string g_dataNote;
std::atomic<int> g_netPool{-1};
}
@@ -52,27 +57,34 @@ bool writable(const std::string& dir) {
return true;
}
+// Once: the user's files of a version before 0.9.7, from the app's folder
+// (copied, then its sign-in removed there: one copy of the token). Not
+// again after (.migrated): a sign-out later must not bring them back.
+void migrateLegacy() {
+ const std::string data = kDataDir, legacy = kLegacyDir, done = data + "/.migrated";
+ std::string text;
+ if (readFile(done, text)) return;
+ int moved = 0;
+ for (const char* name : {"account.json", "settings.json", "library.json", "prices.json"}) {
+ std::string mine;
+ if (readFile(legacy + "/" + name, text) && !readFile(data + "/" + name, mine) &&
+ writeFileAtomic(data + "/" + name, text))
+ ++moved;
+ }
+ if (readFile(data + "/account.json", text)) ::unlink((legacy + "/account.json").c_str());
+ writeFileAtomic(done, "1\n");
+ if (moved) g_dataNote = "moved " + std::to_string(moved) + " file(s) from " + legacy + " to " + data;
+}
+
bool init() {
- // The sign-in, settings and caches live in /data/homebrew/PPSA99810 (the
- // app's own folder when installed there, kept apart from it on a USB
- // drive). A folder the app can't write in (as an installer may leave
- // it) would lose the sign-in at every start: then /data/psbox.
- if (!writable(g_dataDir)) {
+ if (writable(kDataDir)) {
+ migrateLegacy();
+ } else if (writable(kLegacyDir)) { // as before 0.9.7
int err = errno;
- const std::string fallback = "/data/psbox";
- bool ok = writable(fallback);
- XC_LOGW("data folder %s not writable (errno %d); %s", g_dataDir.c_str(), err,
- ok ? ("using " + fallback).c_str() : "nor /data/psbox: nothing will be kept");
- if (ok) {
- // What can still be read there comes along (a folder that only
- // refuses writes keeps the last sign-in).
- for (const char* name : {"account.json", "settings.json"}) {
- std::string text, mine;
- if (readFile(g_dataDir + "/" + name, text) && !readFile(fallback + "/" + name, mine))
- writeFileAtomic(fallback + "/" + name, text);
- }
- g_dataDir = fallback;
- }
+ g_dataDir = kLegacyDir;
+ g_dataNote = std::string(kDataDir) + " not writable (errno " + std::to_string(err) + "); using " + kLegacyDir;
+ } else {
+ g_dataNote = std::string("neither ") + kDataDir + " nor " + kLegacyDir + " is writable: nothing will be kept";
}
// libSceNet's resolver: 32 KiB pool.
int rc = sceNetInit();
@@ -89,6 +101,18 @@ std::string dataDir() {
return g_dataDir;
}
+std::string dataDirNote() { return g_dataNote; }
+
+std::string appDir() {
+ // /app0 is the app's own folder; its real path where it has been
+ // tested to take updates (renames over the running eboot.bin).
+ struct stat legacy {}, running {};
+ if (::stat((std::string(kLegacyDir) + "/eboot.bin").c_str(), &legacy) == 0 &&
+ ::stat("/app0/eboot.bin", &running) == 0 && legacy.st_ino == running.st_ino)
+ return kLegacyDir;
+ return "/app0";
+}
+
std::string assetDir() { return "/app0/assets"; }
std::string caBundlePath() {
diff --git a/src/ui/image_cache.cpp b/src/ui/image_cache.cpp
index 8758ba5..f7a2784 100644
--- a/src/ui/image_cache.cpp
+++ b/src/ui/image_cache.cpp
@@ -74,7 +74,8 @@ ImageCache::ImageCache(std::function<void()> onReady, size_t budgetBytes, std::s
size_t diskBudgetBytes)
: onReady_(std::move(onReady)), budget_(budgetBytes), diskDir_(std::move(diskDir)), diskBudget_(diskBudgetBytes) {
if (!diskDir_.empty()) {
- ::mkdir(diskDir_.c_str(), 0755);
+ ::mkdir(diskDir_.c_str(), 0777); // like the data folder: removable over FTP too
+ ::chmod(diskDir_.c_str(), 0777); // one made 0755 by an older version
trimDisk();
}
threads_.resize(3);
diff --git a/tools/ps5/autotest.sh b/tools/ps5/autotest.sh
index 292abf8..99b03f8 100755
--- a/tools/ps5/autotest.sh
+++ b/tools/ps5/autotest.sh
@@ -32,11 +32,13 @@ sleep 2
python3 "$vk/tools/deploy-title-folder.py" "$root/build-ps5/pkg/$title_id" | tail -1
# Fresh log, the autoplay request, no stale frame.
-python3 - "$PS5_HOST" "${FTP_PORT:-2121}" "/data/homebrew/$title_id" "$game $seconds $option" <<'PY'
+python3 - "$PS5_HOST" "${FTP_PORT:-2121}" "/data/psbox" "$game $seconds $option" <<'PY'
import io, sys
from ftplib import FTP, error_perm, error_reply
host, port, d, line = sys.argv[1], int(sys.argv[2]), sys.argv[3], sys.argv[4]
-f = FTP(); f.connect(host, port, timeout=15); f.login(); f.cwd(d)
+f = FTP(); f.connect(host, port, timeout=15); f.login()
+try: f.cwd(d)
+except error_perm: f.mkd(d); f.cwd(d) # the app makes it on its first start
for name in ("xcloud.log", "frame.ppm", "frame2.ppm", "stream.aus", "ui.ppm", "launch.ppm", "screen.ppm", "detail.ppm", "library.ppm", "library2.ppm", "error.ppm", "consoles.ppm", "settings.ppm"):
try: f.sendcmd(f"DELE {name}")
except (error_perm, error_reply): pass
@@ -51,7 +53,7 @@ PY
ctl launch "$title_id" | tail -1
deadline=$(( $(date +%s) + seconds + 180 ))
fetch() {
- python3 - "$PS5_HOST" "${FTP_PORT:-2121}" "/data/homebrew/$title_id" "$out" "$@" <<'PY'
+ python3 - "$PS5_HOST" "${FTP_PORT:-2121}" "/data/psbox" "$out" "$@" <<'PY'
import os, sys
from ftplib import FTP, error_perm
host, port, d, out, names = sys.argv[1], int(sys.argv[2]), sys.argv[3], sys.argv[4], sys.argv[5:]
@@ -85,7 +87,7 @@ done
fetch xcloud.log frame.ppm frame2.ppm stream.aus ui.ppm launch.ppm screen.ppm detail.ppm library.ppm library2.ppm error.ppm consoles.ppm settings.ppm || true
ctl kill "$title_id" >/dev/null 2>&1 || true
# Remove the request so a manual launch behaves normally.
-python3 - "$PS5_HOST" "${FTP_PORT:-2121}" "/data/homebrew/$title_id" <<'PY'
+python3 - "$PS5_HOST" "${FTP_PORT:-2121}" "/data/psbox" <<'PY'
import sys
from ftplib import FTP, error_perm, error_reply
f = FTP(); f.connect(sys.argv[1], int(sys.argv[2]), timeout=15); f.login(); f.cwd(sys.argv[3])
diff --git a/tools/ps5/deploy.sh b/tools/ps5/deploy.sh
index 7cbc858..f2ed70e 100755
--- a/tools/ps5/deploy.sh
+++ b/tools/ps5/deploy.sh
@@ -18,7 +18,7 @@ export PS5_HOST
if [[ ${1:-} == --log ]]; then
out=${2:-$root/xcloud.log}
- python3 - "$PS5_HOST" "${FTP_PORT:-2121}" "/data/homebrew/$title/xcloud.log" "$out" <<'PY'
+ python3 - "$PS5_HOST" "${FTP_PORT:-2121}" "/data/psbox/xcloud.log" "$out" <<'PY'
import sys
from ftplib import FTP
host, port, remote, out = sys.argv[1], int(sys.argv[2]), sys.argv[3], sys.argv[4]