Xbox Cloud Gaming app for PS5 Homebrew
C
Touchpad: swipe down for the game menu; one short hint; 1440p asks
Rafael Abud Ferreira62d5f2dcf8aa
diff --git a/src/app/ps5_main.cpp b/src/app/ps5_main.cppindex 3b699bd..f8524c0 100644--- a/src/app/ps5_main.cpp+++ b/src/app/ps5_main.cpp@@ -287,8 +287,15 @@ std::string stream(xcloud::GssvClient& gssv) {g_player = &player;}g_ui->showStreaming();- platform::notify(ui::tr(ui::Str::LeaveHint));- if (gssv.isHome()) platform::notify(ui::tr(ui::Str::SwipeHint));+ {+ // The touchpad's gestures, in the first three streams only.+ std::lock_guard<std::mutex> lock(g_settingsMutex);+ if (g_settings.gestureHints < 3) {+ ++g_settings.gestureHints;+ g_settings.save(settingsPath());+ platform::notify(ui::tr(ui::Str::GestureHint));+ }+ }const uint64_t started = platform::nowMs();uint64_t nextTick = started;@@ -955,6 +962,7 @@ int main(int argc, char** argv) {bool active = false, fired = false;float x = 0, y = 0; // where the finger came down} swipe;+ bool swipeMenu = false; // a swipe asked for the game menuint sharpness = 0; // 0..3, as Settings::sharpnessint deband = 1; // 0..2, as Settings::debandint upscaler = 0; // as Settings::upscaler@@ -1098,7 +1106,8 @@ int main(int argc, char** argv) {updateTextInput(g_player);// OPTIONS + TOUCHPAD opens the menu (and closes it again).bool wasOpen = menu.isOpen();- if (!wasOpen && menuCombo && g_keyboardFor.empty()) {+ if (!wasOpen && (menuCombo || swipeMenu) && g_keyboardFor.empty()) {+ swipeMenu = false;menu.setCircleConfirms(g_settings.circleConfirms);menu.open(streamResolution, showStats, sharpness, deband, upscaler, g_playingHome);overlaySeq = 0;@@ -1177,10 +1186,15 @@ int main(int argc, char** argv) {if (!swipe.active) swipe = {true, false, pad.touchX, pad.touchY};float dx = pad.touchX - swipe.x, dy = swipe.y - pad.touchY; // dy > 0: upbool right = dx > 0.30f && std::abs(dy) < 0.30f, up = dy > 0.40f && std::abs(dx) < 0.30f;+ bool left = dx < -0.30f && std::abs(dy) < 0.30f, down = dy < -0.40f && std::abs(dx) < 0.30f;if (!swipe.fired && (right || up)) {swipe.fired = true;g_xboxButtonUntil = platform::nowMs() + 250;XC_LOGI("touchpad swipe %s: Xbox button", right ? "right" : "up");+ } else if (!swipe.fired && (left || down)) {+ swipe.fired = true;+ swipeMenu = true; // opened on the next pass, as by OPTIONS + TOUCHPAD+ XC_LOGI("touchpad swipe %s: game menu", left ? "left" : "down");}} else {swipe.active = false;diff --git a/src/app/settings.cpp b/src/app/settings.cppindex 98cd56b..d3eb87f 100644--- a/src/app/settings.cpp+++ b/src/app/settings.cpp@@ -30,6 +30,7 @@ bool Settings::load(const std::string& path) {triggerRumble = (*j)["triggerRumble"].asBool(triggerRumble);circleConfirms = (*j)["circleConfirms"].asBool(circleConfirms);lightBar = (*j)["lightBar"].asBool(lightBar);+ gestureHints = static_cast<int>((*j)["gestureHints"].asInt(gestureHints));regionRtt.clear();for (const auto& [name, ms] : (*j)["regionRtt"].members())if (ms.asInt() > 0) regionRtt[name] = static_cast<int>(ms.asInt());@@ -56,6 +57,7 @@ bool Settings::save(const std::string& path) const {v.set("triggerRumble", triggerRumble);v.set("circleConfirms", circleConfirms);v.set("lightBar", lightBar);+ v.set("gestureHints", gestureHints);return platform::writeFileAtomic(path, v.dump());}diff --git a/src/app/settings.h b/src/app/settings.hindex 45e16d6..9abf084 100644--- a/src/app/settings.h+++ b/src/app/settings.h@@ -34,6 +34,7 @@ struct Settings {bool circleConfirms = false;// The DualSense light bar takes the colour of the game in focus.bool lightBar = true;+ int gestureHints = 0; // streams that showed the touchpad gestures' hint (three do)bool load(const std::string& path);bool save(const std::string& path) const;diff --git a/src/app/stream_player.cpp b/src/app/stream_player.cppindex 61f391e..75076ef 100644--- a/src/app/stream_player.cpp+++ b/src/app/stream_player.cpp@@ -301,6 +301,22 @@ struct StreamPlayer::Impl {return;}if (++videoFrames == 1) XC_LOGI("first video frame received: %zu bytes", n);+ {+ // The H.264 profile the server encodes with (from each new SPS).+ static int lastProfile = -1, lastLevel = -1;+ for (size_t i = 0; i + 6 < n; ++i)+ if (d[i] == 0 && d[i + 1] == 0 && d[i + 2] == 1 && (d[i + 3] & 0x1F) == 7) {+ int profile = d[i + 4], level = d[i + 6];+ if (profile != lastProfile || level != lastLevel) {+ lastProfile = profile;+ lastLevel = level;+ XC_LOGI("video: H.264 profile %d (%s), level %d.%d", profile,+ profile == 66 ? "Baseline" : profile == 77 ? "Main" : profile == 100 ? "High" : "?",+ level / 10, level % 10);+ }+ break;+ }+ }std::lock_guard<std::mutex> lock(mutex);if (frames.size() >= kMaxQueuedFrames) {// Hopelessly behind: start over from the next key frame.diff --git a/src/stream/stream_session.cpp b/src/stream/stream_session.cppindex 3f5a643..63fec83 100644--- a/src/stream/stream_session.cpp+++ b/src/stream/stream_session.cpp@@ -211,6 +211,8 @@ struct StreamSession::Impl {// "720" switches in a few seconds, "720HQ" is ignored in Brazil.std::string base = alias == "1440" ? "1080" : alias;if (base.size() > 2 && base.compare(base.size() - 2, 2, "HQ") == 0) base.resize(base.size() - 2);+ // The user's own Xbox offers every tier on any plan: just the one asked for.+ if (gssv.isHome()) base = alias;auto send = [this](const std::string& a) {json::Value res = json::Value::object();res.set("message", "userRequestedResolutionUpdate");@@ -248,15 +250,18 @@ struct StreamSession::Impl {sendText(message, messageEnvelope("/streaming/characteristics/clientdevicecapabilities", json::Value::object()));+ // The picture's size, as the web client sends its video element's:+ // a 1440p tier needs a 1440p one (the display itself is 4K).+ int w = opt.resolutionAlias == "1440" ? 2560 : 1920, h = opt.resolutionAlias == "1440" ? 1440 : 1080;json::Value dims = json::Value::object();- dims.set("horizontal", 1920);- dims.set("vertical", 1080);- dims.set("preferredWidth", 1920);- dims.set("preferredHeight", 1080);+ dims.set("horizontal", w);+ dims.set("vertical", h);+ dims.set("preferredWidth", w);+ dims.set("preferredHeight", h);dims.set("safeAreaLeft", 0);dims.set("safeAreaTop", 0);- dims.set("safeAreaRight", 1920);- dims.set("safeAreaBottom", 1080);+ dims.set("safeAreaRight", w);+ dims.set("safeAreaBottom", h);dims.set("supportsCustomResolution", true);sendText(message, messageEnvelope("/streaming/characteristics/dimensionschanged", dims));}diff --git a/src/ui/app_ui.cpp b/src/ui/app_ui.cppindex 7c1383c..634d3e1 100644--- a/src/ui/app_ui.cpp+++ b/src/ui/app_ui.cpp@@ -1972,7 +1972,7 @@ void AppUi::drawLaunching(Canvas& c, uint64_t nowMs) {drawCentered(c, fonts_.bold, launching_.name, 500, 48, kWhite);drawCentered(c, fonts_.semibold, tr(Str::GettingReady), 576, 30, kGray);drawCentered(c, fonts_.regular, status_, 630, 26, kDim);- drawCentered(c, fonts_.regular, tr(Str::LeaveHint), 900, 22, kDim);+ drawCentered(c, fonts_.regular, tr(Str::GestureHint), 900, 22, kDim);drawHints(c, {{kIconCircle, tr(Str::Cancel)}});}diff --git a/src/ui/stream_menu.cpp b/src/ui/stream_menu.cppindex d535480..47285c7 100644--- a/src/ui/stream_menu.cpp+++ b/src/ui/stream_menu.cpp@@ -176,6 +176,15 @@ Canvas StreamMenu::renderMenu(const StreamInfo& info) const {// Cross selects, Circle goes back to the game (swapped with Circle// confirming).int hy = kMenuH - 56, x = kPad;+ {+ // The touchpad's gestures, small, above the button hints.+ auto lines = fonts_.regular.wrap(tr(Str::MenuGestureHint), 18, kMenuW - 2 * kPad, 2);+ int gy = hy - 20 - static_cast<int>(lines.size()) * 26;+ for (const auto& l : lines) {+ fonts_.regular.draw(c, l, kPad, gy, 18, kDim);+ gy += 26;+ }+ }auto icon = [&](bool cross) {c.fillCircle(x + 14, hy + 13, 14, rgba(255, 255, 255, 40));if (cross) {diff --git a/src/ui/stream_menu.h b/src/ui/stream_menu.hindex 744e21d..7876e6a 100644--- a/src/ui/stream_menu.h+++ b/src/ui/stream_menu.h@@ -28,7 +28,7 @@ enum class MenuAction { None, Close, Leave, Resolution, Stats, Sharpness, Debandclass StreamMenu {public:- static constexpr int kMenuW = 620, kMenuH = 992;+ static constexpr int kMenuW = 620, kMenuH = 1064;static constexpr int kMenuX = 80, kMenuY = (1080 - kMenuH) / 2;static constexpr int kStatsX = 32, kStatsY = 28;diff --git a/src/ui/strings.cpp b/src/ui/strings.cppindex 7fe3502..7d80041 100644--- a/src/ui/strings.cpp+++ b/src/ui/strings.cpp@@ -54,7 +54,7 @@ constexpr Column kEnglish = {"You're in the queue. Estimated wait: %s", // InQueue"Connecting...", // Connecting"Starting the stream...", // StartingStream- "Press OPTIONS + TOUCHPAD for the game menu", // LeaveHint+ "Touchpad: ↓ this menu · ↑ Xbox button", // MenuGestureHint"Stream ended", // StreamEnded"Something went wrong", // ErrorTitle"Signed in as %s", // SignedInAs@@ -175,7 +175,7 @@ constexpr Column kEnglish = {"Another device took over the stream", // EndedByOtherDevice"The Xbox was turned off", // EndedXboxOff"%s got the request but its Remote Play didn't start. Restart it: hold the power button on the console for 10 seconds, turn it back on, then try again.", // StreamingStuck- "Swipe up or right on the touchpad for the Xbox button", // SwipeHint+ "Touchpad: swipe ↓ for the menu, ↑ for the Xbox button", // GestureHint};constexpr Column kPortugueseBR = {@@ -200,7 +200,7 @@ constexpr Column kPortugueseBR = {"Você está na fila. Espera estimada: %s","Conectando...","Iniciando o streaming...",- "Pressione OPTIONS + TOUCHPAD para abrir o menu do jogo",+ "Touchpad: ↓ este menu · ↑ botão Xbox","Streaming encerrado","Algo deu errado","Conectado como %s",@@ -321,7 +321,7 @@ constexpr Column kPortugueseBR = {"Outro aparelho assumiu a transmissão","O Xbox foi desligado","%s recebeu o pedido, mas o jogo remoto dele não iniciou. Reinicie o console: segure o botão de ligar do Xbox por 10 segundos, ligue de novo e tente outra vez.",- "Deslize para cima ou para a direita no touchpad: botão Xbox",+ "Touchpad: deslize ↓ para o menu, ↑ para o botão Xbox",};constexpr Column kSpanish = {@@ -346,7 +346,7 @@ constexpr Column kSpanish = {"Estás en la cola. Espera estimada: %s","Conectando...","Iniciando el streaming...",- "Pulsa OPTIONS + TOUCHPAD para abrir el menú del juego",+ "Panel táctil: ↓ este menú · ↑ botón Xbox","Streaming finalizado","Algo salió mal","Sesión iniciada como %s",@@ -467,7 +467,7 @@ constexpr Column kSpanish = {"Otro dispositivo tomó la transmisión","La Xbox se apagó","%s recibió la solicitud, pero su juego remoto no se inició. Reiníciala: mantén pulsado el botón de encendido de la consola 10 segundos, enciéndela de nuevo y vuelve a intentarlo.",- "Desliza hacia arriba o a la derecha en el panel táctil: botón Xbox",+ "Panel táctil: desliza ↓ para el menú, ↑ para el botón Xbox",};constexpr Column kFrench = {@@ -492,7 +492,7 @@ constexpr Column kFrench = {"Vous êtes dans la file d'attente. Attente estimée : %s","Connexion...","Démarrage du streaming...",- "Appuyez sur OPTIONS + PAVÉ TACTILE pour le menu du jeu",+ "Pavé tactile : ↓ ce menu · ↑ bouton Xbox","Streaming terminé","Un problème est survenu","Connecté en tant que %s",@@ -613,7 +613,7 @@ constexpr Column kFrench = {"Un autre appareil a repris la diffusion","La Xbox a été éteinte","%s a reçu la demande, mais son jeu à distance n'a pas démarré. Redémarrez-la : maintenez le bouton d'alimentation de la console 10 secondes, rallumez-la, puis réessayez.",- "Glissez vers le haut ou la droite sur le pavé tactile : bouton Xbox",+ "Pavé tactile : glissez ↓ pour le menu, ↑ pour le bouton Xbox",};constexpr Column kGerman = {@@ -638,7 +638,7 @@ constexpr Column kGerman = {"Du bist in der Warteschlange. Geschätzte Wartezeit: %s","Verbindung wird hergestellt...","Streaming wird gestartet...",- "OPTIONS + TOUCHPAD drücken, um das Spielmenü zu öffnen",+ "Touchpad: ↓ dieses Menü · ↑ Xbox-Taste","Streaming beendet","Etwas ist schiefgelaufen","Angemeldet als %s",@@ -759,7 +759,7 @@ constexpr Column kGerman = {"Ein anderes Gerät hat das Streaming übernommen","Die Xbox wurde ausgeschaltet","%s hat die Anfrage erhalten, aber Remote Play ist nicht gestartet. Starte sie neu: Halte die Ein/Aus-Taste der Konsole 10 Sekunden gedrückt, schalte sie wieder ein und versuche es erneut.",- "Wische auf dem Touchpad nach oben oder rechts: Xbox-Taste",+ "Touchpad: ↓ wischen für das Menü, ↑ für die Xbox-Taste",};constexpr Column kItalian = {@@ -784,7 +784,7 @@ constexpr Column kItalian = {"Sei in coda. Attesa stimata: %s","Connessione...","Avvio dello streaming...",- "Premi OPTIONS + TOUCHPAD per il menu di gioco",+ "Touchpad: ↓ questo menu · ↑ pulsante Xbox","Streaming terminato","Si è verificato un problema","Accesso effettuato come %s",@@ -905,7 +905,7 @@ constexpr Column kItalian = {"Un altro dispositivo ha preso lo streaming","La Xbox è stata spenta","%s ha ricevuto la richiesta, ma il gioco remoto non è partito. Riavviala: tieni premuto il pulsante di accensione della console per 10 secondi, riaccendila e riprova.",- "Scorri verso l'alto o a destra sul touchpad: pulsante Xbox",+ "Touchpad: scorri ↓ per il menu, ↑ per il pulsante Xbox",};constexpr std::array<const Column*, kLangs> kTable = {&kEnglish, &kPortugueseBR, &kSpanish,diff --git a/src/ui/strings.h b/src/ui/strings.hindex d956dba..f48d48d 100644--- a/src/ui/strings.h+++ b/src/ui/strings.h@@ -31,7 +31,7 @@ enum class Str {InQueue, // "%s" = estimated waitConnecting,StartingStream,- LeaveHint,+ MenuGestureHint, // the game menu's footer: the touchpad gesturesStreamEnded,ErrorTitle,SignedInAs, // "%s" = gamertag@@ -152,7 +152,7 @@ enum class Str {EndedByOtherDevice, // toast: another device took the stream overEndedXboxOff, // toast: the Xbox was turned off during the streamStreamingStuck, // "%s" = the console: its Remote Play service didn't start- SwipeHint, // at the start of a stream from the user's own Xbox+ GestureHint, // at the start of a stream (the first three): the touchpad gesturesCount};