Xbox Cloud Gaming app for PS5 Homebrew
C
Fast scrolling, smooth inertia, and 'All games' vertical grid (#32)
Rafael Abud Ferreira70df22eaa5d2
diff --git a/ROADMAP.md b/ROADMAP.mdindex ae43a34..1e9e25a 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -131,14 +131,17 @@ is rolled back at the next start), then the app restarts itselfLowest price by the discounted price. Modes and languages come from thestore's full details, fetched once in the background and cached.+### Fast scrolling and fresher catalog — done (v0.9.1)+- The right stick pages through the lists (3 rows up / down, 6 cards+ sideways), and so does a swipe on the touchpad.+- Cached game details older than 30 days are fetched again, 40 per start,+ oldest first.+## Next| Item | Why | Size || --- | --- | --- || Per-game settings (next release) | A profile per game (picture, triggers, dead zones, controls) that overrides the general settings for that game only; games without one use the general ones | medium |-| "All games" (Game Pass) as a grid | One row is too little for hundreds of games: a grid like "My games" | medium |-| Fast scrolling | Right stick by pages, a touchpad swipe jumps rows | small |-| Refresh old catalog details | Cached details are never refreshed: a few of the oldest (over 30 days) each start | small || Publisher filter | 918 publishers: the most frequent first, studios of one owner grouped | medium || Friends playing now | Xbox social / presence APIs; privacy to handle | large || Keyboard and mouse filter / icon | The store marks games that take them; together with keyboard and mouse support | small |@@ -156,6 +159,7 @@ is rolled back at the next start), then the app restarts itself## Done+- "All games" (Game Pass) as an expanded vertical grid: uncapped 550+ games in 6 centered columns, 2D D-pad navigation, smooth vertical row scrolling and clean clipping under header and tabs.- v0.5.0: picture on the GPU, FSR 1 upscaling to 4K, block smoothing.- v0.4.0: game menu, PS5 keyboard in games, frame metadata reports, CASsharpness, trigger vibration, local multiplayer, controller settings.diff --git a/src/app/autoplay.cpp b/src/app/autoplay.cppindex 0754070..06df5b6 100644--- a/src/app/autoplay.cpp+++ b/src/app/autoplay.cpp@@ -29,6 +29,7 @@ bool launchSaved = false;const char* pickerShot = nullptr;bool confirmShot = false, confirmHome = false;const char* tuneShot = nullptr; // "tunetest": save this screen next // "confirmtest": save confirm2.ppm / check the home screen // "pickertest": save this screen next, once drawn+const char* gridShot = nullptr; // "gridtest": save grid screenshotbool acceptUpdate = false; // "updatetest": Cross on the pop-up, next pass ("updateskip": Circle)} // namespace@@ -84,7 +85,9 @@ void loadAutoplay() {if (opt == "tunetest") g_autoplay.tuneTest = true;if (opt == "searchtest") g_autoplay.searchTest = true;if (opt == "quicktest") g_autoplay.quickTest = true;+ if (opt == "scrolltest") g_autoplay.scrollTest = true;if (opt.rfind("locktitle=", 0) == 0) g_autoplay.lockTitle = opt.substr(10);+ if (opt == "gridtest") g_autoplay.gridTest = true;if (opt == "norestart") g_autoplay.noRestart = true;if (opt.rfind("threads=", 0) == 0) g_autoplay.decodeThreads = std::atoi(opt.c_str() + 8);}@@ -164,6 +167,28 @@ void autoplayPad(input::ControllerState& pad) {XC_LOGI("AUTOPLAY END: tune test");}}+ if (g_autoplay.scrollTest && uiSaved) {+ // Game Pass: right stick down, then right; R1 to My games: right+ // stick down; a finger moving up the touchpad, then down. The focus+ // is logged after each.+ static uint64_t since = 0;+ uint64_t now = platform::nowMs();+ if (!since) since = now;+ uint64_t t = now - since;+ auto in = [&](uint64_t at, uint64_t len) { return t >= at && t < at + len; };+ if (in(1000, 150)) pad.rightStickY = 1.0f;+ if (in(2500, 150)) pad.rightStickX = 1.0f;+ if (in(4000, 150)) pad.btnR1 = true;+ if (in(5500, 150)) pad.rightStickY = 1.0f;+ if (in(7000, 400)) pad.touching = true, pad.touchX = 0.5f, pad.touchY = 0.8f - 0.5f * static_cast<float>(t - 7000) / 400;+ if (in(8500, 400)) pad.touching = true, pad.touchX = 0.5f, pad.touchY = 0.3f + 0.5f * static_cast<float>(t - 8500) / 400;+ for (uint64_t at : {800, 2000, 3500, 5000, 6500, 8000, 9500})+ if (in(at, 20)) XC_LOGI("scroll: at %llu ms: %s", static_cast<unsigned long long>(at), g_ui->focusDescription().c_str());+ if (in(10000, 20)) {+ g_autoplay.scrollTest = false;+ XC_LOGI("AUTOPLAY END: scroll test");+ }+ }if (g_autoplay.confirmTest && uiSaved) {// The buttons as the hands press them, swapped as input::poll swaps// them: Settings, down to the confirm button; Cross opens its list,@@ -183,6 +208,24 @@ void autoplayPad(input::ControllerState& pad) {if (in(5500, 20)) confirmShot = true;if (in(8000, 20)) confirmHome = true;}+ if (g_autoplay.gridTest && uiSaved) {+ static uint64_t since = 0;+ uint64_t now = platform::nowMs();+ if (!since) since = now;+ uint64_t t = now - since;+ auto in = [&](uint64_t at, uint64_t len) { return t >= at && t < at + len; };+ pad.dpadDown = in(1000, 150) || in(2200, 150) || in(3400, 150) || in(4600, 150) || in(5800, 150) ||+ in(8500, 150) || in(10000, 150);+ pad.dpadRight = in(11200, 150);+ pad.dpadUp = in(13000, 150) || in(14500, 150) || in(16000, 150);+ if (in(7500, 20)) gridShot = "grid1.ppm";+ if (in(12000, 20)) gridShot = "grid2.ppm";+ if (in(17500, 20)) {+ gridShot = "grid_back.ppm";+ g_autoplay.gridTest = false;+ XC_LOGI("AUTOPLAY END: grid test");+ }+ }if (!g_autoplay.pad) return;static std::string lastPressed;std::string pressed;@@ -428,6 +471,10 @@ void autoplayScreens(const ui::Canvas& canvas, uint64_t now) {saveCanvas(tuneShot);tuneShot = nullptr;}+ if (gridShot) {+ saveCanvas(gridShot);+ gridShot = nullptr;+ }if (confirmShot) {confirmShot = false;saveCanvas("confirm2.ppm");diff --git a/src/app/autoplay.h b/src/app/autoplay.hindex f45ba78..7c805f8 100644--- a/src/app/autoplay.h+++ b/src/app/autoplay.h@@ -60,6 +60,7 @@ struct Autoplay {bool updateTest = false; // updatetest: accept the update pop-up, save update.ppm / updating.ppmbool updateSkip = false; // updateskip: "Not now" on the update pop-upbool settingsUpdate = false; // settingsupdate: Settings > Updates, Cross+ bool scrollTest = false; // scrolltest: the right stick and a touchpad swipe page through the lists (logged)bool quickTest = false; // quicktest: cross-gen pairs' badges, MOBA games, the lock on `lockTitle`std::string lockTitle; // locktitle=<xCloud title id>: logged playable or locked at oncebool searchTest = false; // searchtest: lowest price, Game Pass co-op + dubbed, the genres' list@@ -70,6 +71,7 @@ struct Autoplay {bool pickerTest = false; // pickertest: the confirm button's list (confirm.ppm), the light// bar's colour picker moved (picker.ppm), chosen (settings.ppm)bool noRestart = false; // norestart: after an update, close instead of restarting+ bool gridTest = false; // gridtest: navigate to All games grid, verify 2D navigation and capture screenshots};extern Autoplay g_autoplay;extern std::atomic<bool> g_syntheticA; // A held down for the gamediff --git a/src/app/library.cpp b/src/app/library.cppindex 2bf04e9..cc4a6b2 100644--- a/src/app/library.cpp+++ b/src/app/library.cpp@@ -11,6 +11,7 @@#include <algorithm>#include <cstring>+#include <ctime>#include <map>namespace xc::app {@@ -39,6 +40,7 @@ json::Value productToJson(const xcloud::Product& p) {v.set("categories", cats);if (p.detailed) {v.set("d", true);+ v.set("at", p.detailedAt);v.set("modes", static_cast<int64_t>(p.modes));json::Value langs = json::Value::object();for (const auto& [lang, bits] : p.languages) langs.set(lang, static_cast<int64_t>(bits));@@ -60,6 +62,8 @@ xcloud::Product productFromJson(const std::string& id, const json::Value& v) {p.heroUrl = v["hero"].str();for (const auto& c : v["categories"].items()) p.categories.push_back(xcloud::categoryName(c.str()));p.detailed = v["d"].asBool(false);+ // Details from before their date was kept count from now (not all due at once).+ p.detailedAt = v["at"].asInt(static_cast<int64_t>(std::time(nullptr)));p.modes = static_cast<uint32_t>(v["modes"].asInt(0));for (const auto& [lang, bits] : v["langs"].members()) p.languages[lang] = static_cast<uint8_t>(bits.asInt(0));return p;@@ -195,6 +199,7 @@ std::vector<ui::GameRow> Library::rows() const {ui::GameRow row;row.title = r.title;row.gamePassBadges = r.badges;+ row.isGrid = r.isGrid;for (const auto& [pid, tid] : r.items) {ui::GameTile t = tile(pid, tid);if (t.productId.empty() || t.titleId.empty()) continue;@@ -353,7 +358,7 @@ bool Library::load(xcloud::GssvClient& gssv, const std::string& language, const// in "Your games").std::vector<xcloud::Title> recent;if (gssv.listTitles(recent, lastErr, true)) {- RowIds r{ui::tr(ui::Str::JumpBackIn), false, {}};+ RowIds r{ui::tr(ui::Str::JumpBackIn), false, false, {}};std::vector<std::string> ids;for (const auto& t : recent) {if (t.productId.empty()) continue;@@ -386,10 +391,11 @@ bool Library::load(xcloud::GssvClient& gssv, const std::string& language, const{xcloud::sigl::kMostPopular, 40},{xcloud::sigl::kFreeToPlay, 40},{xcloud::sigl::kLeavingSoon, 40},- {xcloud::sigl::kAllGames, 120}};+ {xcloud::sigl::kAllGames, 0}};for (const auto& spec : lists) {xcloud::ProductList list;- if (spec.sigl == xcloud::sigl::kAllGames && !all.productIds.empty()) {+ bool isAllGames = std::string_view(spec.sigl) == xcloud::sigl::kAllGames;+ if (isAllGames && !all.productIds.empty()) {list = all;} else if (!xcloud::fetchList(spec.sigl, market_, language_, list, e)) {XC_LOGW("%s", e.c_str());@@ -415,7 +421,7 @@ bool Library::load(xcloud::GssvClient& gssv, const std::string& language, constXC_LOGI("library: %s: %zu of %zu not in Game Pass, left out", list.title.c_str(),before - list.productIds.size(), before);}- if (list.productIds.size() > spec.limit) list.productIds.resize(spec.limit);+ if (spec.limit > 0 && list.productIds.size() > spec.limit) list.productIds.resize(spec.limit);std::vector<std::string> missing;for (const auto& id : list.productIds)if (!products_.count(id)) missing.push_back(id);@@ -424,7 +430,7 @@ bool Library::load(xcloud::GssvClient& gssv, const std::string& language, constlastErr = e;continue;}- RowIds r{list.title, !freeToPlay, {}};+ RowIds r{list.title, !freeToPlay, isAllGames, {}};for (const auto& id : list.productIds) r.items.emplace_back(id, std::string());layout_.push_back(std::move(r));changed();@@ -528,6 +534,7 @@ void Library::loadCatalogNames(const Changed& changed, const std::atomic<bool>*if (p.description.empty() && !otherLanguage_.count(id)) p.description = old->second.description;if (!p.detailed && old->second.detailed) { // modes and languages don't change with the languagep.detailed = true;+ p.detailedAt = old->second.detailedAt;p.modes = old->second.modes;p.languages = old->second.languages;}@@ -659,6 +666,41 @@ void Library::hydrate(const Changed& changed, const std::atomic<bool>* stop) {ids.insert(ids.end(), allGames_.begin(), allGames_.end());uint64_t t0 = platform::nowMs();fetchFull(ids, changed, stop);+ // The store changes descriptions and details now and then: the oldest+ // few (over 30 days) are fetched again on each start, never all at once.+ constexpr int64_t kRefreshAge = 30 * 24 * 3600;+ constexpr size_t kRefreshPerStart = 40;+ int64_t now = static_cast<int64_t>(std::time(nullptr));+ std::vector<std::pair<int64_t, std::string>> old;+ for (const auto& [id, p] : products_)+ if (p.detailed && p.detailedAt && now - p.detailedAt > kRefreshAge) old.push_back({p.detailedAt, id});+ std::sort(old.begin(), old.end());+ if (old.size() > kRefreshPerStart) old.resize(kRefreshPerStart);+ if (!old.empty() && !(stop && *stop)) {+ std::vector<std::string> refresh;+ for (const auto& [at, id] : old) refresh.push_back(id);+ size_t done = 0;+ for (size_t i = 0; i < refresh.size(); i += 20) {+ std::vector<std::string> batch(refresh.begin() + static_cast<long>(i),+ refresh.begin() + static_cast<long>(std::min(refresh.size(), i + 20)));+ std::map<std::string, xcloud::Product> fresh;+ std::string e;+ if (!xcloud::fetchProducts(batch, market_, language_, fresh, e, true)) {+ XC_LOGW("%s (refresh: next start)", e.c_str());+ break;+ }+ for (const auto& id : batch) {+ auto it = fresh.find(id);+ if (it != fresh.end()) products_[id] = std::move(it->second), ++done;+ else products_[id].detailedAt = now; // gone from the catalog's details: not asked again for a while+ }+ }+ XC_LOGI("library: %zu of %zu old details refreshed (%zu over 30 days in all)", done, refresh.size(),+ static_cast<size_t>(std::count_if(products_.begin(), products_.end(), [&](const auto& kv) {+ return kv.second.detailed && now - kv.second.detailedAt > kRefreshAge;+ })));+ changed();+ }saveCache(); // descriptions, hero art, modes and languages for next timesize_t detailed = 0;for (const auto& [id, p] : products_) detailed += p.detailed;diff --git a/src/app/library.h b/src/app/library.hindex 8f45ae7..db64c38 100644--- a/src/app/library.h+++ b/src/app/library.h@@ -82,6 +82,7 @@ private:struct RowIds {std::string title;bool badges = true;+ bool isGrid = false;std::vector<Item> items;};ui::GameTile tile(const std::string& productId, const std::string& titleId) const;diff --git a/src/app/ps5_main.cpp b/src/app/ps5_main.cppindex f75c79c..84c2521 100644--- a/src/app/ps5_main.cpp+++ b/src/app/ps5_main.cpp@@ -201,6 +201,15 @@ int main(int argc, char** argv) {// Never return from main: the app is closed from the home screen.input::ControllerState prev{}, pad{};Repeater up, down, left, right, dpadLeft, dpadRight;+ // Smooth scrolling: rows / cards still to move (fractions carry over),+ // the touchpad's last point, and its speed for the glide after release.+ struct {+ float rows = 0, cards = 0;+ bool touching = false;+ float x = 0, y = 0;+ float vRows = 0, vCards = 0; // per second+ uint64_t lastMs = 0;+ } scroll;StreamScreen streamScreen(fonts); // the game's menu and what is laid over ituint64_t padsCheckedAt = 0;unsigned padChecks = 0;@@ -217,6 +226,11 @@ int main(int argc, char** argv) {}input::poll(pad);autoplayPad(pad);+ {+ // The triggers' resistance: in a game and in its Settings tester only.+ float l2, r2;+ input::setTriggerResistanceActive(g_ui->screen() == ui::Screen::Streaming || g_ui->triggerTest(l2, r2));+ }uint64_t now = platform::nowMs();if (now - lightBarAt >= 50) { // the light bar: the game in focus, the user's colour or offlightBarAt = now;@@ -274,6 +288,48 @@ int main(int argc, char** argv) {nav.dpadRight = dpadRight.update(pad.dpadRight, now);nav.rawLX = pad.rawLeftX, nav.rawLY = pad.rawLeftY, nav.rawRX = pad.rawRightX, nav.rawRY = pad.rawRightY;nav.l2Analog = pad.triggerL2, nav.r2Analog = pad.triggerR2;+ // Smooth scrolling. The right stick: a speed that follows how far it+ // is pushed (up to ~12 rows / 16 cards a second). The touchpad,+ // touched (not pressed): the list follows the finger (its height ~6+ // rows, its width ~8 cards; the finger up scrolls up), then glides on+ // and slows down after release, like two fingers on a laptop's.+ {+ float dt = scroll.lastMs ? std::min(0.1f, (now - scroll.lastMs) / 1000.0f) : 0.0f;+ scroll.lastMs = now;+ auto speed = [](float v, float top) {+ float m = (std::abs(v) - 0.15f) / 0.85f;+ return m <= 0 ? 0.0f : (v < 0 ? -1.0f : 1.0f) * top * m * m;+ };+ scroll.rows += speed(pad.rightStickY, 12) * dt;+ scroll.cards += speed(pad.rightStickX, 16) * dt;+ constexpr float kRowsPerPad = 6, kCardsPerPad = 8;+ bool touch = pad.touching && !pad.btnTouchpad && g_ui->screen() == ui::Screen::Home;+ if (touch && scroll.touching) {+ float dr = (pad.touchY - scroll.y) * kRowsPerPad, dc = (pad.touchX - scroll.x) * kCardsPerPad;+ scroll.rows += dr;+ scroll.cards += dc;+ if (dt > 0) { // the finger's speed, smoothed+ scroll.vRows = 0.6f * scroll.vRows + 0.4f * dr / dt;+ scroll.vCards = 0.6f * scroll.vCards + 0.4f * dc / dt;+ }+ } else if (!touch && dt > 0) { // the glide, slowing down+ scroll.rows += scroll.vRows * dt;+ scroll.cards += scroll.vCards * dt;+ float decay = std::exp(-4.0f * dt);+ scroll.vRows *= decay;+ scroll.vCards *= decay;+ if (std::abs(scroll.vRows) < 0.8f) scroll.vRows = 0;+ if (std::abs(scroll.vCards) < 0.8f) scroll.vCards = 0;+ }+ if (touch && !scroll.touching) scroll.vRows = scroll.vCards = 0; // a new touch stops a glide+ scroll.touching = touch;+ scroll.x = pad.touchX, scroll.y = pad.touchY;+ if (g_ui->screen() != ui::Screen::Home) scroll.rows = scroll.cards = scroll.vRows = scroll.vCards = 0;+ nav.scrollRows = static_cast<int>(scroll.rows);+ nav.scrollCards = static_cast<int>(scroll.cards);+ scroll.rows -= static_cast<float>(nav.scrollRows);+ scroll.cards -= static_cast<float>(nav.scrollCards);+ }nav.nowMs = now;bool menuCombo = pad.btnOptions && pad.btnTouchpad && !(prev.btnOptions && prev.btnTouchpad);prev = pad;diff --git a/src/app/worker.cpp b/src/app/worker.cppindex 4f82bdf..fb2e5ab 100644--- a/src/app/worker.cpp+++ b/src/app/worker.cpp@@ -535,7 +535,8 @@ void loadLibrary(xcloud::GssvClient& gssv) {});if (!g_autoplay.title.empty() && g_autoplay.title != "BENCH" && g_autoplay.title != "UPDATE" && !g_autoplay.detailTest && !g_autoplay.libraryTest &&!g_autoplay.consolesTab && !g_autoplay.settingsTest &&- !g_autoplay.imeTest && !g_autoplay.vibeTest && !g_autoplay.searchTest && !g_autoplay.quickTest) {+ !g_autoplay.imeTest && !g_autoplay.vibeTest && !g_autoplay.searchTest && !g_autoplay.quickTest && !g_autoplay.scrollTest &&+ !g_autoplay.gridTest) {platform::sleepMs(6000); // leave the home screen up for ui.ppmui::GameTile tile;tile.titleId = g_autoplay.title;diff --git a/src/input/controller.cpp b/src/input/controller.cppindex 5b82331..16a0a38 100644--- a/src/input/controller.cpp+++ b/src/input/controller.cpp@@ -156,7 +156,7 @@ Pad g_pads[kMaxPads];std::atomic<float> g_deadzone[2] = {0.15f, 0.15f};std::atomic<bool> g_circleConfirms{false};std::atomic<int> g_triggerStrength{kTriggerMedium}, g_triggerHz{1}, g_triggerResistance{0};-std::atomic<bool> g_triggerPulses{false}, g_triggerLogging{false};+std::atomic<bool> g_triggerPulses{false}, g_triggerLogging{false}, g_resistanceActive{false};bool g_rumbleLogged = false;inline float normStick(uint8_t val) {@@ -245,7 +245,7 @@ void applyRumble(Pad& pad) {// own) and sent when either changes.v = pad.triggers.current();const uint8_t level[2] = {static_cast<uint8_t>(v >> 8), static_cast<uint8_t>(v)};- int strength = g_triggerStrength, hz = g_triggerHz, resistance = g_triggerResistance;+ int strength = g_triggerStrength, hz = g_triggerHz, resistance = g_resistanceActive ? g_triggerResistance.load() : 0;bool pulses = g_triggerPulses;uint64_t now = platform::nowMs();TriggerCommand want[2];@@ -314,6 +314,7 @@ void setTriggerFeel(int strength, int hzIndex, int resistance, bool pulses) {}void setTriggerLogging(bool on) { g_triggerLogging = on; }+void setTriggerResistanceActive(bool on) { g_resistanceActive = on; }void setDeadzone(float left, float right) {g_deadzone[0] = std::clamp(left, 0.0f, 0.5f);@@ -457,6 +458,7 @@ bool padConnected(int index) { return index == 0; }std::string padUserName(int index) { return index == 0 ? "Player" : ""; }void setTriggerFeel(int, int, int, bool) {}void setTriggerLogging(bool) {}+void setTriggerResistanceActive(bool) {}} // namespace xc::input#endifdiff --git a/src/input/controller.h b/src/input/controller.hindex 1abf19c..f7cfe22 100644--- a/src/input/controller.h+++ b/src/input/controller.h@@ -84,6 +84,9 @@ bool circleConfirms();void setTriggerFeel(int strength, int hzIndex, int resistance, bool pulses);// Logs each time a trigger starts or stops vibrating (the Settings tester).void setTriggerLogging(bool on);+// The resistance (setTriggerFeel) only weighs the triggers while this is on:+// in a game and in the Settings tester, not while browsing the menus.+void setTriggerResistanceActive(bool on);// The light bar eases (~0.4 s) to this colour; reset gives it back to the// system (the player's colour). Any thread; polling applies it.void setLightBar(uint8_t r, uint8_t g, uint8_t b, int pad = 0);diff --git a/src/ui/app_ui.cpp b/src/ui/app_ui.cppindex a88800f..fb28290 100644--- a/src/ui/app_ui.cpp+++ b/src/ui/app_ui.cpp@@ -545,6 +545,21 @@ std::vector<std::pair<std::string, PriceInfo>> AppUi::searchResults(size_t max)return out;}+std::string AppUi::focusDescription() const {+ std::lock_guard<std::mutex> lock(mutex_);+ if (tab_ == Tab::GamePass)+ return "Game Pass row " + std::to_string(focusRow_) + " card " ++ std::to_string(focusCol_.empty() ? 0 : focusCol_[static_cast<size_t>(focusRow_)]);+ if (tab_ == Tab::Library) {+ LibraryLayout L = libraryLayout();+ int f = gridFocus_;+ if (f >= 0 && f < static_cast<int>(L.rowOf.size()))+ return "My games tile " + std::to_string(f) + " (row " + std::to_string(L.rowOf[static_cast<size_t>(f)]) + ")";+ return "My games tile " + std::to_string(f);+ }+ return "consoles";+}+void AppUi::showTab(Tab t) {std::lock_guard<std::mutex> lock(mutex_);tab_ = t;@@ -1071,13 +1086,25 @@ const GameTile* AppUi::focusedTile() const {}void AppUi::retarget() {- rowY_.target = static_cast<float>(focusRow_);- const float span = kW - 2 * kMargin - kCard;- for (size_t r = 0; r < rows_.size(); ++r) {- float left = static_cast<float>(focusCol_[r] * kCardPitch);- Anim& a = rowScroll_[r];- if (left - a.target > span) a.target = left - span;- if (left < a.target) a.target = left;+ if (focusRow_ < 0 || focusRow_ >= static_cast<int>(rows_.size())) return;+ const GameRow& curRow = rows_[static_cast<size_t>(focusRow_)];++ if (curRow.isGrid) {+ constexpr float kGridShift = static_cast<float>(kRowTop - 170) / static_cast<float>(kRowPitch);+ rowY_.target = static_cast<float>(focusRow_) + kGridShift;++ int gridRow = focusCol_[static_cast<size_t>(focusRow_)] / kLibraryCols;+ rowScroll_[static_cast<size_t>(focusRow_)].target = static_cast<float>(std::max(0, gridRow - 1) * kGridPitchY);+ } else {+ rowY_.target = static_cast<float>(focusRow_);+ const float span = kW - 2 * kMargin - kCard;+ for (size_t r = 0; r < rows_.size(); ++r) {+ if (rows_[r].isGrid) continue;+ float left = static_cast<float>(focusCol_[r] * kCardPitch);+ Anim& a = rowScroll_[r];+ if (left - a.target > span) a.target = left - span;+ if (left < a.target) a.target = left;+ }}}@@ -1130,6 +1157,26 @@ AppUi::LibraryLayout AppUi::libraryLayout() const {void AppUi::handleHome(const NavInput& in, UiEvent& ev) {// Caller holds mutex_.+ if ((in.scrollRows || in.scrollCards) && !(searching_ && searchOnKeys_)) {+ // Smooth scrolling: the rows and cards it moved by since the last+ // pass, one step at a time (the view glides after the focus).+ auto steps = [&](int n, bool vertical) {+ NavInput step;+ step.nowMs = in.nowMs;+ (vertical ? (n > 0 ? step.down : step.up) : (n > 0 ? step.right : step.left)) = true;+ for (int k = 0; k < std::abs(n); ++k) {+ // In the search's results, sideways stops at the row's edge+ // (left of it is the keyboard).+ if (searching_ && !vertical && (n < 0 ? resultFocus_ % kResultCols == 0+ : (resultFocus_ + 1) % kResultCols == 0))+ break;+ handleHome(step, ev);+ }+ };+ if (in.scrollRows) steps(in.scrollRows, true);+ if (in.scrollCards) steps(in.scrollCards, false);+ return;+ }if (in.l1 || in.r1) {// Game Pass, Your games, My consoles, round.int n = static_cast<int>(tab_) + (in.r1 ? 1 : 2);@@ -1212,12 +1259,39 @@ void AppUi::handleHome(const NavInput& in, UiEvent& ev) {case Tab::GamePass: {if (rows_.empty()) break;int rows = static_cast<int>(rows_.size());+ const GameRow& curRow = rows_[static_cast<size_t>(focusRow_)];int& col = focusCol_[static_cast<size_t>(focusRow_)];- int cols = static_cast<int>(rows_[static_cast<size_t>(focusRow_)].tiles.size());- if (in.down && focusRow_ + 1 < rows) ++focusRow_;- if (in.up && focusRow_ > 0) --focusRow_;- if (in.right && col + 1 < cols) ++col;- if (in.left && col > 0) --col;+ int count = static_cast<int>(curRow.tiles.size());++ if (curRow.isGrid) {+ if (in.up && col < kLibraryCols) {+ if (focusRow_ > 0) {+ --focusRow_;+ int upCols = static_cast<int>(rows_[static_cast<size_t>(focusRow_)].tiles.size());+ focusCol_[static_cast<size_t>(focusRow_)] = std::clamp(focusCol_[static_cast<size_t>(focusRow_)], 0, upCols - 1);+ }+ } else if (in.down && col + kLibraryCols >= count && col / kLibraryCols == (count - 1) / kLibraryCols) {+ if (focusRow_ + 1 < rows) {+ ++focusRow_;+ int downCols = static_cast<int>(rows_[static_cast<size_t>(focusRow_)].tiles.size());+ focusCol_[static_cast<size_t>(focusRow_)] = std::clamp(focusCol_[static_cast<size_t>(focusRow_)], 0, downCols - 1);+ }+ } else {+ moveInGrid(col, count, kLibraryCols, in);+ }+ } else {+ if (in.down && focusRow_ + 1 < rows) {+ ++focusRow_;+ if (rows_[static_cast<size_t>(focusRow_)].isGrid) {+ int gCols = static_cast<int>(rows_[static_cast<size_t>(focusRow_)].tiles.size());+ int targetCol = std::min(col % kLibraryCols, gCols - 1);+ focusCol_[static_cast<size_t>(focusRow_)] = std::max(0, targetCol);+ }+ }+ if (in.up && focusRow_ > 0) --focusRow_;+ if (in.right && col + 1 < count) ++col;+ if (in.left && col > 0) --col;+ }if (in.up || in.down || in.left || in.right) {retarget();dirty_ = true;@@ -2233,46 +2307,100 @@ void AppUi::drawHome(Canvas& c, uint64_t nowMs) {const GameTile* focus = focusedTile();c.clear(kBg);drawHero(c, nowMs, focus ? focus->heroUrl : std::string(), false);- drawTopBar(c);- drawTabs(c);if (rows_.empty()) {drawCentered(c, fonts_.semibold, tr(Str::NoGames), 500, 32, kGray);drawHints(c, {{kIconOptions, tr(Str::Settings)}, {kIconTouchpad, tr(Str::HoldSignOut)}});+ drawTopBar(c);+ drawTabs(c);return;}if (focus) {- auto title = fonts_.bold.wrap(focus->name, 60, 1100, 1);- if (!title.empty()) fonts_.bold.draw(c, title[0], kMargin, 190, 60, kWhite);- std::string meta = focus->publisher;- for (size_t i = 0; i < focus->categories.size() && i < 2; ++i)- meta += (meta.empty() ? "" : " \xE2\x80\xA2 ") + focus->categories[i];- fonts_.regular.draw(c, meta, kMargin, 272, 24, kGray);- auto desc = fonts_.regular.wrap(focus->description, 22, 860, 2);- for (size_t i = 0; i < desc.size(); ++i)- fonts_.regular.draw(c, desc[i], kMargin, 318 + static_cast<int>(i) * 32, 22, kGray);+ float heroAlpha = 1.0f;+ for (size_t r = 0; r < rows_.size(); ++r) {+ if (rows_[r].isGrid) {+ float dist = static_cast<float>(r) - rowY_.value;+ if (dist < 1.0f) heroAlpha = std::clamp(dist, 0.0f, 1.0f);+ break;+ }+ }+ if (heroAlpha > 0.05f) {+ Color titleColor = withAlpha(kWhite, static_cast<int>(255 * heroAlpha));+ Color grayColor = withAlpha(kGray, static_cast<int>(255 * heroAlpha));+ auto title = fonts_.bold.wrap(focus->name, 60, 1100, 1);+ if (!title.empty()) fonts_.bold.draw(c, title[0], kMargin, 190, 60, titleColor);+ std::string meta = focus->publisher;+ for (size_t i = 0; i < focus->categories.size() && i < 2; ++i)+ meta += (meta.empty() ? "" : " \xE2\x80\xA2 ") + focus->categories[i];+ fonts_.regular.draw(c, meta, kMargin, 272, 24, grayColor);+ auto desc = fonts_.regular.wrap(focus->description, 22, 860, 2);+ for (size_t i = 0; i < desc.size(); ++i)+ fonts_.regular.draw(c, desc[i], kMargin, 318 + static_cast<int>(i) * 32, 22, grayColor);+ }}+ constexpr int kGridW = kLibraryCols * kCardPitch - kCardGap;+ const int gridLeft = (kW - kGridW) / 2;+ int afterGridOffset = 0;+for (size_t r = 0; r < rows_.size(); ++r) {float rel = static_cast<float>(r) - rowY_.value;- if (rel < -0.7f) continue;- int y = kRowTop + static_cast<int>(std::lround(rel * kRowPitch));- if (y > kH) break;+ int y = kRowTop + static_cast<int>(std::lround(rel * kRowPitch)) + afterGridOffset;const GameRow& row = rows_[r];- fonts_.semibold.draw(c, row.title, kMargin, y, 30, kWhite);- int cardY = y + 48;- int scroll = static_cast<int>(std::lround(rowScroll_[r].value));- int firstCol = std::max(0, scroll / kCardPitch - 1);- for (size_t col = static_cast<size_t>(firstCol); col < row.tiles.size(); ++col) {- int x = kMargin + static_cast<int>(col) * kCardPitch - scroll;- if (x > kW) break;- if (x + kCard < 0) continue;- bool focused = static_cast<int>(r) == focusRow_ && static_cast<int>(col) == focusCol_[r];- drawCard(c, row.tiles[col], x, cardY, focused, row.gamePassBadges);- if (hidden_.count(row.tiles[col].productId)) c.fillRect({x, cardY, kCard, kCard}, rgba(0, 0, 0, 120), 10);++ if (row.isGrid) {+ int offset = static_cast<int>(std::lround(rowScroll_[r].value));+ int hy = y - offset;+ int cardY = hy + 48;++ if (hy > 80 && hy < kH) {+ fonts_.bold.draw(c, row.title, gridLeft, hy + 8, 34, kWhite);+ int w = fonts_.bold.measure(row.title, 34);+ fonts_.semibold.draw(c, gamesCount(row.tiles.size()), gridLeft + w + 20, hy + 20, 22, kDim);+ }++ for (size_t i = 0; i < row.tiles.size(); ++i) {+ int c_col = static_cast<int>(i) % kLibraryCols;+ int c_row = static_cast<int>(i) / kLibraryCols;+ int cy = cardY + c_row * kGridPitchY;+ if (cy + kCard + 40 < 140) continue;+ if (cy > kH) break;+ int cx = gridLeft + c_col * kCardPitch;+ bool focused = static_cast<int>(r) == focusRow_ && static_cast<int>(i) == focusCol_[r];+ drawCard(c, row.tiles[i], cx, cy, focused, row.gamePassBadges);+ if (hidden_.count(row.tiles[i].productId)) c.fillRect({cx, cy, kCard, kCard}, rgba(0, 0, 0, 120), 10);+ auto name = fonts_.semibold.wrap(row.tiles[i].name, 20, kCard, 1);+ if (!name.empty()) fonts_.semibold.draw(c, name[0], cx, cy + kCard + 12, 20, focused ? kWhite : kGray);+ }++ int gridHeight = 48 + ((static_cast<int>(row.tiles.size()) + kLibraryCols - 1) / kLibraryCols) * kGridPitchY;+ afterGridOffset += gridHeight - offset - kRowPitch;+ } else {+ if (rel < -0.7f && afterGridOffset == 0) continue;+ if (y > kH && afterGridOffset == 0) break;+ fonts_.semibold.draw(c, row.title, kMargin, y, 30, kWhite);+ int cardY = y + 48;+ int scroll = static_cast<int>(std::lround(rowScroll_[r].value));+ int firstCol = std::max(0, scroll / kCardPitch - 1);+ for (size_t col = static_cast<size_t>(firstCol); col < row.tiles.size(); ++col) {+ int x = kMargin + static_cast<int>(col) * kCardPitch - scroll;+ if (x > kW) break;+ if (x + kCard < 0) continue;+ bool focused = static_cast<int>(r) == focusRow_ && static_cast<int>(col) == focusCol_[r];+ drawCard(c, row.tiles[col], x, cardY, focused, row.gamePassBadges);+ if (hidden_.count(row.tiles[col].productId)) c.fillRect({x, cardY, kCard, kCard}, rgba(0, 0, 0, 120), 10);+ }}}++ constexpr int clipTop = 140;+ c.fillRect({0, 0, kW, clipTop}, kBg);+ c.gradientV({0, clipTop, kW, 16}, kBg, withAlpha(kBg, 0));++ drawTopBar(c);+ drawTabs(c);+// Fade the rows out under the button hints.c.gradientV({0, kH - 190, kW, 110}, withAlpha(kBg, 0), withAlpha(kBg, 245));c.fillRect({0, kH - 80, kW, 80}, withAlpha(kBg, 245));diff --git a/src/ui/app_ui.h b/src/ui/app_ui.hindex d453052..6d9c538 100644--- a/src/ui/app_ui.h+++ b/src/ui/app_ui.h@@ -62,6 +62,7 @@ struct GameRow {std::string title;std::vector<GameTile> tiles;bool gamePassBadges = true;+ bool isGrid = false;};enum class Screen { Splash, SignIn, Home, Details, Launching, Streaming, Error, Settings, Updating };@@ -81,6 +82,9 @@ struct NavInput {bool dpadLeft = false, dpadRight = false;float rawLX = 0, rawLY = 0, rawRX = 0, rawRY = 0;float l2Analog = 0, r2Analog = 0;+ // Smooth scrolling (the right stick, or the touchpad with inertia):+ // rows down (+) / up (-) and cards right (+) / left (-) to move now.+ int scrollRows = 0, scrollCards = 0;uint64_t nowMs = 0;};@@ -226,6 +230,8 @@ public:// `openList` (0 mode, 1 genre, 2 language) open; and the first results.void showFilteredSearch(Tab tab, bool cheapest, int mode, const std::string& genre, int language, int openList = -1);std::vector<std::pair<std::string, PriceInfo>> searchResults(size_t max) const;+ // Autoplay tests: where the focus is ("Game Pass row 2 card 6", ...).+ std::string focusDescription() const;void invalidate();// --- UI thread -----------------------------------------------------------diff --git a/src/xcloud/catalog.cpp b/src/xcloud/catalog.cppindex c53c31b..bb8b410 100644--- a/src/xcloud/catalog.cpp+++ b/src/xcloud/catalog.cpp@@ -2,6 +2,8 @@// Copyright (C) 2026 RafaelNGP#include "xcloud/catalog.h"+#include <ctime>+#include "net/http.h"#include "util/json.h"@@ -86,6 +88,7 @@ bool fetchProducts(const std::vector<std::string>& ids, const std::string& markeif (full) {// How it can be played, from the store's attributes.prod.detailed = true;+ prod.detailedAt = static_cast<int64_t>(std::time(nullptr));for (const auto& a : p["Attributes"].items()) {std::string n = a["Name"].str();if (n == "SinglePlayer") prod.modes |= kModeSingle;diff --git a/src/xcloud/catalog.h b/src/xcloud/catalog.hindex 5507141..971232b 100644--- a/src/xcloud/catalog.h+++ b/src/xcloud/catalog.h@@ -28,6 +28,7 @@ struct Product {// (kMode* bits) and, per language ("en", "pt"...: any of its locales),// what is translated (kLang* bits).bool detailed = false;+ int64_t detailedAt = 0; // when the full details were fetched (unix s)uint32_t modes = 0;std::map<std::string, uint8_t> languages;};