Skip to content

Xbox Cloud Gaming app for PS5 Homebrew

C

WIP: the queue's estimated wait from the title's estimate (the per-session one doesn't exist), counted down; 'You're in the queue.' without one

Rafael Abud Ferreira21de973f03b3
diff --git a/src/app/cli_main.cpp b/src/app/cli_main.cpp
index 4720d6b..33c1898 100644
--- a/src/app/cli_main.cpp
+++ b/src/app/cli_main.cpp
@@ -121,7 +121,7 @@ bool provision(auth::AuthManager& am, xcloud::GssvClient& gssv, const std::strin
return false;
}
if (st.state == xcloud::SessionState::WaitingForResources) {
- XC_LOGI("in queue, estimated wait %ds", gssv.waitTimeSeconds());
+ XC_LOGI("in queue, estimated wait %ds", gssv.titleWaitSeconds(titleId));
} else {
XC_LOGI("session state: %s", st.raw.c_str());
}
diff --git a/src/app/worker.cpp b/src/app/worker.cpp
index 283ce74..964d6a6 100644
--- a/src/app/worker.cpp
+++ b/src/app/worker.cpp
@@ -341,6 +341,10 @@ std::string play(auth::AuthManager& am, xcloud::GssvClient& gssv, const ui::Game
// Provisioning: give up after a minute (the cloud's queue may take long).
const uint64_t provisioningSince = platform::nowMs();
int pollErrors = 0;
+ // The queue's estimate: the title's (the service has no per-session one),
+ // asked every 15 s and counted down in between; -1 unknown.
+ int queueSeconds = -1;
+ uint64_t queueAskedAt = 0;
for (int i = 0; i < 900 && !g_cancel; ++i) {
if (gssv.isHome() && platform::nowMs() - provisioningSince > 60000) {
result = "ConsoleDidNotWake: no answer in 60 s";
@@ -359,8 +363,18 @@ std::string play(auth::AuthManager& am, xcloud::GssvClient& gssv, const ui::Game
}
pollErrors = 0;
XC_LOGI("session state: %s", st.raw.c_str());
- if (st.state == xcloud::SessionState::WaitingForResources)
- g_ui->setLaunchStatus(ui::trf(ui::Str::InQueue, formatWait(gssv.waitTimeSeconds())));
+ if (st.state == xcloud::SessionState::WaitingForResources) {
+ uint64_t now = platform::nowMs();
+ if (!queueAskedAt || now - queueAskedAt >= 15000) {
+ int s = gssv.titleWaitSeconds(game.titleId);
+ XC_LOGI("queue: estimated %d s", s);
+ if (s >= 0 || queueSeconds < 0) queueSeconds = s;
+ queueAskedAt = now;
+ }
+ int left = queueSeconds < 0 ? -1 : std::max(0, queueSeconds - static_cast<int>((now - queueAskedAt) / 1000));
+ g_ui->setLaunchStatus(left < 0 ? std::string(ui::tr(ui::Str::InQueueNoEstimate))
+ : ui::trf(ui::Str::InQueue, formatWait(left)));
+ }
if (st.state == xcloud::SessionState::Provisioning && gssv.isHome())
g_ui->setLaunchStatus(ui::tr(ui::Str::WakingConsole)); // a sleeping Xbox takes ~10 s
if (st.state == xcloud::SessionState::Failed) {
diff --git a/src/ui/strings.cpp b/src/ui/strings.cpp
index b341d17..c46ab29 100644
--- a/src/ui/strings.cpp
+++ b/src/ui/strings.cpp
@@ -273,6 +273,7 @@ constexpr Column kEnglish = {
"Mouse & keyboard", // FilterMouseKeyboard
"Mouse and keyboard", // MouseKeyboardSupport
"Keyboard and mouse: player %s", // KeyboardPlayer
+ "You're in the queue.", // InQueueNoEstimate
};
constexpr Column kPortugueseBR = {
@@ -516,6 +517,7 @@ constexpr Column kPortugueseBR = {
"Teclado e mouse", // FilterMouseKeyboard
"Teclado e mouse", // MouseKeyboardSupport
"Teclado e mouse: jogador %s", // KeyboardPlayer
+ "Você está na fila.", // InQueueNoEstimate
};
constexpr Column kSpanish = {
@@ -759,6 +761,7 @@ constexpr Column kSpanish = {
"Teclado y ratón", // FilterMouseKeyboard
"Teclado y ratón", // MouseKeyboardSupport
"Teclado y ratón: jugador %s", // KeyboardPlayer
+ "Estás en la cola.", // InQueueNoEstimate
};
constexpr Column kFrench = {
@@ -1002,6 +1005,7 @@ constexpr Column kFrench = {
"Clavier et souris", // FilterMouseKeyboard
"Clavier et souris", // MouseKeyboardSupport
"Clavier et souris : joueur %s", // KeyboardPlayer
+ "Vous êtes dans la file d'attente.", // InQueueNoEstimate
};
constexpr Column kGerman = {
@@ -1245,6 +1249,7 @@ constexpr Column kGerman = {
"Maus & Tastatur", // FilterMouseKeyboard
"Maus und Tastatur", // MouseKeyboardSupport
"Tastatur und Maus: Spieler %s", // KeyboardPlayer
+ "Du bist in der Warteschlange.", // InQueueNoEstimate
};
constexpr Column kItalian = {
@@ -1488,6 +1493,7 @@ constexpr Column kItalian = {
"Tastiera e mouse", // FilterMouseKeyboard
"Tastiera e mouse", // MouseKeyboardSupport
"Tastiera e mouse: giocatore %s", // KeyboardPlayer
+ "Sei in coda.", // InQueueNoEstimate
};
constexpr std::array<const Column*, kLangs> kTable = {&kEnglish, &kPortugueseBR, &kSpanish,
diff --git a/src/ui/strings.h b/src/ui/strings.h
index 1564d7b..328c020 100644
--- a/src/ui/strings.h
+++ b/src/ui/strings.h
@@ -250,6 +250,7 @@ enum class Str {
FilterMouseKeyboard, // search filter: games the cloud plays with native mouse and keyboard
MouseKeyboardSupport, // game page, beside the console and genres
KeyboardPlayer, // notification: keys 1-4 chose the player the keyboard plays as (%s: 1..4)
+ InQueueNoEstimate, // launching, in the queue, the service gives no estimate
Count
};
diff --git a/src/xcloud/gssv.cpp b/src/xcloud/gssv.cpp
index 4f469eb..a78020b 100644
--- a/src/xcloud/gssv.cpp
+++ b/src/xcloud/gssv.cpp
@@ -500,13 +500,6 @@ bool GssvClient::sessionState(SessionStatus& out, std::string& err) {
return true;
}
-int GssvClient::waitTimeSeconds() {
- auto r = net::perform(authed(resolution_, login_, "GET", sessionUrl("/waittime")));
- auto j = json::parse(r.body);
- if (!r.ok() || !j) return -1;
- return static_cast<int>((*j)["estimatedTotalWaitTimeInSeconds"].asInt(-1));
-}
-
int GssvClient::titleWaitSeconds(const std::string& titleId) {
if (titleId.empty() || login_.gsToken.empty()) return -1;
auto r = net::perform(authed(resolution_, login_, "GET", url("/v1/waittime/" + titleId)));
diff --git a/src/xcloud/gssv.h b/src/xcloud/gssv.h
index ed30aa1..b6cc5de 100644
--- a/src/xcloud/gssv.h
+++ b/src/xcloud/gssv.h
@@ -126,8 +126,6 @@ public:
bool startSession(const std::string& titleId, const std::string& locale, std::string& err);
bool hasSession() const { return !sessionPath_.empty(); }
bool sessionState(SessionStatus& out, std::string& err);
- // Estimated queue time in seconds while WaitingForResources (-1 unknown).
- int waitTimeSeconds();
// Before a session: the estimated wait to start `titleId` (xCloud title
// id), in seconds; -1 unknown.
int titleWaitSeconds(const std::string& titleId);