Xbox Cloud Gaming app for PS5 Homebrew
C
fix(ui): keep WebUI ABXY buttons static, stabilize search cursor, and persist friends shelf hero art
Rafael Abud Ferreira3ff229490d72
diff --git a/src/app/library.cpp b/src/app/library.cppindex 1ec95b9..ee39e49 100644--- a/src/app/library.cpp+++ b/src/app/library.cpp@@ -317,6 +317,39 @@ ui::GameTile Library::tile(const std::string& productId, const std::string& titlt.titleId = titleId;static const xcloud::Product s_dummy{};auto it = products_.find(productId);+ if (it == products_.end() && !titleId.empty()) {+ for (auto pit = products_.begin(); pit != products_.end(); ++pit) {+ if (pit->second.xcloudTitleId == titleId) {+ it = pit;+ if (t.productId.empty()) t.productId = pit->first;+ break;+ }+ }+ if (it == products_.end()) {+ for (const auto& [cpid, ctid] : cloudTitleOf_) {+ if (ctid == titleId) {+ it = products_.find(cpid);+ if (it != products_.end()) {+ if (t.productId.empty()) t.productId = cpid;+ break;+ }+ }+ }+ }+ if (it == products_.end()) {+ for (const auto& g : kKnownCloudGames) {+ if (g.cloudTitleId && titleId == g.cloudTitleId) {+ if (t.productId.empty()) t.productId = g.productId;+ if (t.name.empty() && g.fallbackTitle) t.name = g.fallbackTitle;+ if (t.publisher.empty() && g.publisher) t.publisher = g.publisher;+ if (t.tileUrl.empty() && g.tileUrl) t.tileUrl = g.tileUrl;+ if (t.heroUrl.empty() && g.heroUrl) t.heroUrl = g.heroUrl;+ if (t.description.empty() && g.description) t.description = g.description;+ break;+ }+ }+ }+ }const xcloud::Product& p = (it != products_.end()) ? it->second : s_dummy;if (t.titleId.empty() || t.titleId == "None") {auto ct = cloudTitleOf_.find(productId);@@ -459,6 +492,15 @@ std::vector<ui::GameRow> Library::rows() const {friendsRow.gamePassBadges = false;friendsRow.isGrid = false;friendsRow.tiles = friendsTiles_;+ for (auto& t : friendsRow.tiles) {+ ui::GameTile fresh = tile(t.productId, t.titleId);+ if (!fresh.heroUrl.empty()) t.heroUrl = fresh.heroUrl;+ if (!fresh.description.empty() && t.description.empty()) t.description = fresh.description;+ if (!fresh.name.empty() && t.name.empty()) t.name = fresh.name;+ if (!fresh.tileUrl.empty() && t.tileUrl.empty()) t.tileUrl = fresh.tileUrl;+ if (!fresh.publisher.empty() && t.publisher.empty()) t.publisher = fresh.publisher;+ if (!fresh.categories.empty() && t.categories.empty()) t.categories = fresh.categories;+ }// Place right after "Jump back in" if present, otherwise at index 0size_t insertIdx = 0;@@ -1350,15 +1392,24 @@ void Library::loadFriends(const std::string& xblAuth, const Changed& changed, coif (!xcloud::fetchFriendsPresence(xblAuth, presence, err, language_)) return;if (stop && *stop) return;- // Map Xbox Live Title ID -> Store Product ID+ // Map Xbox Live Title ID / Cloud Title ID -> Store Product IDstd::map<std::string, std::string> productByXbox;for (const auto& [pid, xid] : xboxTitleOf_) {if (!xid.empty()) productByXbox[xid] = pid;}for (const auto& [pid, prod] : products_) {+ productByXbox[pid] = pid;if (!prod.xboxTitleId.empty() && !productByXbox.count(prod.xboxTitleId)) {productByXbox[prod.xboxTitleId] = pid;}+ if (!prod.xcloudTitleId.empty() && !productByXbox.count(prod.xcloudTitleId)) {+ productByXbox[prod.xcloudTitleId] = pid;+ }+ }+ for (const auto& [pid, cid] : cloudTitleOf_) {+ if (!cid.empty() && !productByXbox.count(cid)) {+ productByXbox[cid] = pid;+ }}// Group friends playing accessible games@@ -1377,9 +1428,29 @@ void Library::loadFriends(const std::string& xblAuth, const Changed& changed, co}std::vector<ui::GameTile> tiles;+ std::vector<std::string> needDetails;for (auto& [pid, friendsList] : friendsByProduct) {ui::GameTile t = tile(pid);if (t.productId.empty() || !t.playable) continue;+ if (t.heroUrl.empty()) {+ auto pit = products_.find(pid);+ if (pit != products_.end() && !pit->second.heroUrl.empty()) {+ t.heroUrl = pit->second.heroUrl;+ } else {+ for (const auto& [otherPid, otherProd] : products_) {+ if (!otherProd.heroUrl.empty() &&+ ((!t.titleId.empty() && otherProd.xcloudTitleId == t.titleId) ||+ (!t.xboxTitleId.empty() && otherProd.xboxTitleId == t.xboxTitleId))) {+ t.heroUrl = otherProd.heroUrl;+ if (t.description.empty()) t.description = otherProd.description;+ break;+ }+ }+ }+ }+ if (t.heroUrl.empty() && !pid.empty()) {+ needDetails.push_back(pid);+ }t.friends = std::move(friendsList);tiles.push_back(std::move(t));}@@ -1388,6 +1459,17 @@ void Library::loadFriends(const std::string& xblAuth, const Changed& changed, coif (!friendsTiles_.empty()) {XC_LOGI("library: %zu friends playing %zu accessible games now", presence.size(), friendsTiles_.size());changed();+ if (!needDetails.empty()) {+ fetchFull(needDetails, changed, stop);+ for (auto& t : friendsTiles_) {+ if (t.heroUrl.empty()) {+ auto fresh = tile(t.productId, t.titleId);+ if (!fresh.heroUrl.empty()) t.heroUrl = fresh.heroUrl;+ if (!fresh.description.empty() && t.description.empty()) t.description = fresh.description;+ }+ }+ changed();+ }}}diff --git a/src/app/library.h b/src/app/library.hindex 1f4655b..2d79e86 100644--- a/src/app/library.h+++ b/src/app/library.h@@ -101,6 +101,8 @@ public:// Delta-sync: discovers new/updated titles, only fetches missing metadata, updates rows in-place.size_t syncDelta(xcloud::GssvClient& gssv, const Changed& changed, std::string& err);void markUnclaimable(const std::string& productId);+ // Generates a tile for a product/title.+ ui::GameTile tile(const std::string& productId, const std::string& titleId = {}) const;private:using Item = std::pair<std::string, std::string>; // productId, titleId@@ -111,7 +113,6 @@ private:std::vector<Item> items;bool recent = false; // "Jump back in"};- ui::GameTile tile(const std::string& productId, const std::string& titleId = {}) const;std::vector<ui::GameTile> tiles(const std::vector<Item>& items) const;// Full details (hero art, description) for `ids` lacking them, in batches,// `changed` after each; false on a network error.diff --git a/src/app/price_loop.cpp b/src/app/price_loop.cppindex f842ffe..7507243 100644--- a/src/app/price_loop.cpp+++ b/src/app/price_loop.cpp@@ -125,6 +125,18 @@ void priceLoop() {}XC_LOGI("details of %s: %s", id.c_str(), ok ? "ok" : err.empty() ? "not in the catalog" : err.c_str());}+ // Focused game on Home whose hero art is missing.+ if (std::string id = market.empty() ? std::string() : g_ui->heroWanted(platform::nowMs()); !id.empty()) {+ std::map<std::string, xcloud::Product> full;+ std::string err;+ bool ok = xcloud::fetchProducts({id}, market, language, full, err, true) && full.count(id);+ if (ok) {+ const auto& p = full[id];+ g_ui->setDetailInfo(id, p.description, p.publisher, p.categories, p.heroUrl,+ p.ratingAge, p.ratingSystem, p.ratingDescriptors);+ }+ XC_LOGI("hero of %s: %s", id.c_str(), ok ? "ok" : err.empty() ? "not in the catalog" : err.c_str());+ }// The open page's queue estimate (a game the account can play).if (std::string title = g_ui->queueWanted(platform::nowMs()); !title.empty()) {std::unique_ptr<xcloud::GssvClient> client;diff --git a/src/app/web_server.cpp b/src/app/web_server.cppindex cca8ba7..12e1637 100644--- a/src/app/web_server.cpp+++ b/src/app/web_server.cpp@@ -371,20 +371,21 @@ input:checked + .slider-sw:before { transform: translateX(20px); }justify-content: center;border-width: 2px;box-shadow: 0 3px 8px rgba(0,0,0,0.5);- transition: transform 0.06s;+ transition: filter 0.06s, box-shadow 0.06s;cursor: pointer;touch-action: none;user-select: none;+ -webkit-user-select: none;+ -webkit-tap-highlight-color: transparent;}.abxy-key:active, .abxy-key.pressed {- transform: scale(0.90) !important;- box-shadow: 0 0 16px rgba(255,255,255,0.8) !important;- filter: brightness(1.3);+ box-shadow: 0 0 16px rgba(255,255,255,0.85) !important;+ filter: brightness(1.35) !important;}-.btn-y { top: 0; left: 50%; transform: translateX(-50%); background: #c68900; border-color: #ffd000; }-.btn-a { bottom: 0; left: 50%; transform: translateX(-50%); background: #0e6b37; border-color: #22c55e; }-.btn-x { top: 50%; left: 0; transform: translateY(-50%); background: #006eb8; border-color: #38bdf8; }-.btn-b { top: 50%; right: 0; transform: translateY(-50%); background: #b80d1b; border-color: #f87171; }+.btn-y { top: 0; left: 52px; background: #c68900; border-color: #ffd000; }+.btn-a { bottom: 0; left: 52px; background: #0e6b37; border-color: #22c55e; }+.btn-x { top: 52px; left: 0; background: #006eb8; border-color: #38bdf8; }+.btn-b { top: 52px; right: 0; background: #b80d1b; border-color: #f87171; }/* Buttons & System Styling */.pad-btn {@@ -3071,6 +3072,10 @@ void resetVirtualGamepads() {for (auto& slot : s_virtualPads) slot = {};}+const char* webServerIndexHtml() {+ return kIndexHtml;+}+void setWebServerHooks(WebServerHooks hooks) {s_hooks = std::move(hooks);}diff --git a/src/app/web_server.h b/src/app/web_server.hindex a309c85..c3e377d 100644--- a/src/app/web_server.h+++ b/src/app/web_server.h@@ -43,6 +43,7 @@ void touchVirtualGamepad(int playerIndex);void switchVirtualGamepadSlot(int newSlot);uint64_t virtualGamepadActiveAt(int playerIndex);void resetVirtualGamepads();+const char* webServerIndexHtml();namespace ws {diff --git a/src/ui/app_ui.cpp b/src/ui/app_ui.cppindex 07d3544..f416e7b 100644--- a/src/ui/app_ui.cpp+++ b/src/ui/app_ui.cpp@@ -104,6 +104,8 @@ int posOf(const std::vector<SettingsRowPos>& rows, int row) {constexpr int kGridPitchY = 300;constexpr int kLibraryCols = 6;constexpr int kResultCols = 4;+// Keeps the focused grid row on screen: scrolls once it passes the second row.+inline float gridTarget(int focus, int cols) { return static_cast<float>(std::max(0, focus / cols - 1) * kGridPitchY); }constexpr int kGridTop = 236; // y of the first card row (search results)constexpr int kLibraryTop = 160; // y where "Your games" starts (its first heading)constexpr int kResultsX = 760;@@ -398,7 +400,7 @@ void AppUi::setProfile(const std::string& gamertag, const std::string& gamerpicUvoid AppUi::setSubscription(const std::string& plan) {std::lock_guard<std::mutex> lock(mutex_);subscription_ = plan;- if (searching_) runSearch();+ if (searching_) runSearch(true);dirty_ = true;}@@ -412,7 +414,7 @@ void AppUi::setMembership(bool member) {void AppUi::setRows(std::vector<GameRow> rows) {std::lock_guard<std::mutex> lock(mutex_);allRows_ = std::move(rows);- rebuild();+ rebuild(true);}void AppUi::setRowsLocked(std::vector<GameRow> rows) {@@ -461,7 +463,7 @@ void AppUi::setOwned(std::vector<GameTile> owned, std::vector<GameTile> purchasaallOwned_ = std::move(owned);allPurchasable_ = std::move(purchasable);ownedKnown_ = known;- rebuild();+ rebuild(true);}namespace {@@ -566,7 +568,7 @@ void AppUi::rebuild(bool keepPosition) {for (int i = 0; libraryTile(i); ++i)if (libraryTile(i)->productId == focused) gridFocus_ = i;}- if (searching_) runSearch();+ if (searching_) runSearch(true);refreshDetail();dirty_ = true;}@@ -621,7 +623,7 @@ void AppUi::setPrefs(const std::vector<std::string>& hidden, LibrarySort sort, cfavorites_ = std::set<std::string>(favorites.begin(), favorites.end());wishlist_ = std::set<std::string>(wishlist.begin(), wishlist.end());librarySort_ = sort;- rebuild();+ rebuild(true);}void AppUi::setPlaytime(int64_t remainingSeconds, int64_t maxSeconds) {@@ -712,9 +714,7 @@ void AppUi::setSearchPools(std::vector<GameTile> gamePass, std::vector<GameTile>std::lock_guard<std::mutex> lock(mutex_);gamePassPool_ = std::move(gamePass);libraryPool_ = std::move(library);- int keep = resultFocus_;- rebuild(); // hidden games may be in the pools only- if (searching_) resultFocus_ = std::min(keep, std::max(0, static_cast<int>(results_.size()) - 1));+ rebuild(true); // hidden games may be in the pools only; keep position in search and library}void AppUi::setRegionLatency(std::map<std::string, int> ms) {@@ -728,8 +728,8 @@ void AppUi::setPrices(const std::map<std::string, PriceInfo>& prices) {for (const auto& [id, p] : prices) prices_[id] = p;// A list ordered or filtered by price fills in as prices arrive (not// while the user moves through it).- if (searching_ && searchOnKeys_ && tab_ == Tab::Library && (filterCheapest_ || filterFree_ || filterWishlist_))- runSearch();+ if (searching_ && tab_ == Tab::Library && (filterCheapest_ || filterFree_ || filterWishlist_))+ runSearch(true);dirty_ = true;}@@ -777,6 +777,59 @@ std::string AppUi::detailWanted(uint64_t nowMs) {return detail_.productId;}+std::string AppUi::heroWanted(uint64_t nowMs) {+ std::lock_guard<std::mutex> lock(mutex_);+ if (screen_ != Screen::Home || searching_ || tab_ != Tab::GamePass) return {};+ const GameTile* focus = focusedTile();+ if (!focus || !focus->heroUrl.empty()) return {};++ std::string pid = focus->productId;+ if (pid.empty() && !focus->titleId.empty()) {+ for (const auto* list : {&gamePassPool_, &libraryPool_, &allOwned_, &allPurchasable_}) {+ for (const auto& t : *list) {+ if (!t.productId.empty() && t.titleId == focus->titleId) {+ pid = t.productId;+ break;+ }+ }+ if (!pid.empty()) break;+ }+ if (pid.empty()) {+ for (const auto& row : allRows_) {+ for (const auto& t : row.tiles) {+ if (!t.productId.empty() && t.titleId == focus->titleId) {+ pid = t.productId;+ break;+ }+ }+ if (!pid.empty()) break;+ }+ }+ if (!pid.empty()) {+ if (focusRow_ >= 0 && focusRow_ < static_cast<int>(rows_.size())) {+ int col = focusCol_[static_cast<size_t>(focusRow_)];+ if (col >= 0 && col < static_cast<int>(rows_[static_cast<size_t>(focusRow_)].tiles.size())) {+ rows_[static_cast<size_t>(focusRow_)].tiles[static_cast<size_t>(col)].productId = pid;+ }+ }+ if (focusRow_ >= 0 && focusRow_ < static_cast<int>(allRows_.size())) {+ int col = focusCol_[static_cast<size_t>(focusRow_)];+ if (col >= 0 && col < static_cast<int>(allRows_[static_cast<size_t>(focusRow_)].tiles.size())) {+ allRows_[static_cast<size_t>(focusRow_)].tiles[static_cast<size_t>(col)].productId = pid;+ }+ }+ }+ }+ if (pid.empty()) return {};++ auto it = detailInfo_.find(pid);+ if (it != detailInfo_.end() && !it->second.heroUrl.empty()) return {};+ if (pid == heroAskedFor_ && nowMs - heroAskedAt_ < 5000) return {};+ heroAskedFor_ = pid;+ heroAskedAt_ = nowMs;+ return pid;+}+std::string AppUi::queueWanted(uint64_t nowMs) {std::lock_guard<std::mutex> lock(mutex_);if (screen_ != Screen::Details || !detail_.playable || detail_.purchasable || detail_.titleId.empty()) return {};@@ -830,20 +883,68 @@ std::string AppUi::tileName(const std::string& productId) const {return {};}+void AppUi::syncHeroToRowsLocked(const std::string& productId, const std::string& titleId, const std::string& heroUrl,+ const std::string& description, const std::string& publisher,+ const std::vector<std::string>& categories) {+ // Caller holds mutex_.+ if (productId.empty() && titleId.empty()) return;+ auto updateTile = [&](GameTile& t) {+ bool match = (!productId.empty() && t.productId == productId) ||+ (!titleId.empty() && t.titleId == titleId);+ if (match) {+ if (t.productId.empty() && !productId.empty()) t.productId = productId;+ if (t.titleId.empty() && !titleId.empty()) t.titleId = titleId;+ if (!heroUrl.empty()) t.heroUrl = heroUrl;+ if (!description.empty() && t.description.empty()) t.description = description;+ if (!publisher.empty() && t.publisher.empty()) t.publisher = publisher;+ if (!categories.empty() && t.categories.empty()) t.categories = categories;+ }+ };+ for (auto& row : rows_) {+ for (auto& t : row.tiles) updateTile(t);+ }+ for (auto& row : allRows_) {+ for (auto& t : row.tiles) updateTile(t);+ }+ for (auto* list : {&owned_, &purchasable_, &allOwned_, &allPurchasable_, &gamePassPool_, &libraryPool_, &results_}) {+ for (auto& t : *list) updateTile(t);+ }+}+void AppUi::setDetailInfo(const std::string& productId, const std::string& description, const std::string& publisher,const std::vector<std::string>& categories, const std::string& heroUrl,const std::string& ratingAge, const std::string& ratingSystem,const std::vector<std::string>& ratingDescriptors) {std::lock_guard<std::mutex> lock(mutex_);detailInfo_[productId] = {description, publisher, heroUrl, categories, ratingAge, ratingSystem, ratingDescriptors};- if (detail_.productId != productId) return;- if (!description.empty()) detail_.description = description;- if (!publisher.empty()) detail_.publisher = publisher;- if (!categories.empty()) detail_.categories = categories;- if (!heroUrl.empty()) detail_.heroUrl = heroUrl;- if (!ratingAge.empty()) detail_.ratingAge = ratingAge;- if (!ratingSystem.empty()) detail_.ratingSystem = ratingSystem;- if (!ratingDescriptors.empty()) detail_.ratingDescriptors = ratingDescriptors;+ std::string matchingTitleId;+ if (detail_.productId == productId || (!detail_.titleId.empty() && !productId.empty() && detail_.productId.empty())) {+ if (detail_.productId.empty()) detail_.productId = productId;+ if (!description.empty()) detail_.description = description;+ if (!publisher.empty()) detail_.publisher = publisher;+ if (!categories.empty()) detail_.categories = categories;+ if (!heroUrl.empty()) detail_.heroUrl = heroUrl;+ if (!ratingAge.empty()) detail_.ratingAge = ratingAge;+ if (!ratingSystem.empty()) detail_.ratingSystem = ratingSystem;+ if (!ratingDescriptors.empty()) detail_.ratingDescriptors = ratingDescriptors;+ matchingTitleId = detail_.titleId;+ }+ syncHeroToRowsLocked(productId, matchingTitleId, heroUrl, description, publisher, categories);+ if (!ratingAge.empty() || !ratingSystem.empty() || !ratingDescriptors.empty()) {+ auto updateRating = [&](GameTile& t) {+ if (t.productId == productId || (!matchingTitleId.empty() && t.titleId == matchingTitleId)) {+ if (!ratingAge.empty() && t.ratingAge.empty()) t.ratingAge = ratingAge;+ if (!ratingSystem.empty() && t.ratingSystem.empty()) t.ratingSystem = ratingSystem;+ if (!ratingDescriptors.empty() && t.ratingDescriptors.empty()) t.ratingDescriptors = ratingDescriptors;+ }+ };+ for (auto& row : rows_) for (auto& t : row.tiles) updateRating(t);+ for (auto& row : allRows_) for (auto& t : row.tiles) updateRating(t);+ for (auto* list : {&owned_, &purchasable_, &allOwned_, &allPurchasable_, &gamePassPool_, &libraryPool_, &results_}) {+ for (auto& t : *list) updateRating(t);+ }+ }+ if (searching_ && (filterMode_ || filterLanguage_)) runSearch(true);dirty_ = true;}@@ -1090,12 +1191,19 @@ static bool matchSearchWord(const std::string& name, const std::string& word) {return false;}-void AppUi::runSearch() {+void AppUi::runSearch(bool keepPosition) {// Caller holds mutex_. The typed words narrow by name; the filters by// price and console. With filters and no words: every game that passes.+ std::string focusedProductId;+ std::string focusedTitleId;+ int oldFocus = resultFocus_;+ float oldScrollVal = resultScroll_.value;+ if (keepPosition && resultFocus_ >= 0 && resultFocus_ < static_cast<int>(results_.size())) {+ focusedProductId = results_[static_cast<size_t>(resultFocus_)].productId;+ focusedTitleId = results_[static_cast<size_t>(resultFocus_)].titleId;+ }+results_.clear();- resultFocus_ = 0;- resultScroll_ = Anim{};std::string q = fold(query_);std::vector<std::string> words;for (size_t i = 0; i < q.size();) {@@ -1105,7 +1213,11 @@ void AppUi::runSearch() {i = j + 1;}bool filtering = anyFilter();- if (words.empty() && !filtering) return;+ if (words.empty() && !filtering) {+ resultFocus_ = 0;+ resultScroll_ = Anim{};+ return;+ }std::string compact = withoutSpaces(q);static const char* kConsoleCodes[] = {"", "XS", "ONE", "360"};struct Hit {@@ -1199,10 +1311,35 @@ void AppUi::runSearch() {});size_t max = words.empty() ? kMaxFilterResults : kMaxResults;for (size_t i = 0; i < hits.size() && i < max; ++i) results_.push_back(*hits[i].tile);+ if (keepPosition && !results_.empty()) {+ int newFocus = -1;+ if (!focusedProductId.empty() || !focusedTitleId.empty()) {+ for (size_t i = 0; i < results_.size(); ++i) {+ if ((!focusedProductId.empty() && results_[i].productId == focusedProductId) ||+ (!focusedTitleId.empty() && results_[i].titleId == focusedTitleId)) {+ newFocus = static_cast<int>(i);+ break;+ }+ }+ }+ if (newFocus >= 0) {+ resultFocus_ = newFocus;+ } else {+ resultFocus_ = std::min(oldFocus, static_cast<int>(results_.size()) - 1);+ }+ resultScroll_.target = gridTarget(resultFocus_, kResultCols);+ resultScroll_.value = oldScrollVal;+ } else {+ resultFocus_ = 0;+ resultScroll_ = Anim{};+ }}void AppUi::showHome(const std::string& toast) {std::lock_guard<std::mutex> lock(mutex_);+ if (screen_ == Screen::Details) {+ syncHeroToRowsLocked(detail_.productId, detail_.titleId, detail_.heroUrl, detail_.description, detail_.publisher, detail_.categories);+ }screen_ = Screen::Home;if (!caps_.console && !toast.empty()) {toast_ = toast;@@ -2248,9 +2385,6 @@ bool moveInGrid(int& focus, int count, int cols, const NavInput& in) {return focus != before;}-// Keeps the focused grid row on screen: scrolls once it passes the second row.-float gridTarget(int focus, int cols) { return static_cast<float>(std::max(0, focus / cols - 1) * kGridPitchY); }-} // namespaceAppUi::LibraryLayout AppUi::libraryLayout() const {@@ -2698,6 +2832,16 @@ std::pair<int, int> AppUi::searchKeyFocus() const {return {keyRow_, keyCol_};}+int AppUi::searchResultFocus() const {+ std::lock_guard<std::mutex> lock(mutex_);+ return resultFocus_;+}++bool AppUi::isSearchOnKeys() const {+ std::lock_guard<std::mutex> lock(mutex_);+ return searchOnKeys_;+}+std::vector<int> AppUi::keyCenters(int row) const {// Caller holds mutex_.std::vector<int> out;@@ -3221,6 +3365,9 @@ UiEvent AppUi::onMouseDown(float x, float y, int button) {return ev;}if (screen_ == Screen::Details || screen_ == Screen::Settings) {+ if (screen_ == Screen::Details) {+ syncHeroToRowsLocked(detail_.productId, detail_.titleId, detail_.heroUrl, detail_.description, detail_.publisher, detail_.categories);+ }screen_ = Screen::Home;dirty_ = true;return ev;@@ -3861,6 +4008,7 @@ UiEvent AppUi::handle(const NavInput& in) {if (in.r3 && !isAcquired(detail_)) toggleWishlist(detail_, ev);if (in.l3 && !detail_.xboxTitleId.empty()) openAchievements();if (in.back) {+ syncHeroToRowsLocked(detail_.productId, detail_.titleId, detail_.heroUrl, detail_.description, detail_.publisher, detail_.categories);screen_ = Screen::Home;dirty_ = true;}@@ -4867,7 +5015,58 @@ void AppUi::drawHome(Canvas& c, uint64_t nowMs) {if (tab_ == Tab::Consoles) return drawConsoles(c, nowMs);const GameTile* focus = focusedTile();c.clear(kBg);- drawHero(c, nowMs, focus ? focus->heroUrl : std::string(), false);+ std::string hero;+ if (focus) {+ hero = focus->heroUrl;+ if (hero.empty() && !focus->productId.empty()) {+ auto it = detailInfo_.find(focus->productId);+ if (it != detailInfo_.end() && !it->second.heroUrl.empty()) {+ hero = it->second.heroUrl;+ }+ }+ if (hero.empty()) {+ auto matchHero = [&](const GameTile& t) -> bool {+ if (!t.heroUrl.empty()) {+ if (!focus->productId.empty() && t.productId == focus->productId) return true;+ if (!focus->titleId.empty() && t.titleId == focus->titleId) return true;+ if (!focus->xboxTitleId.empty() && t.xboxTitleId == focus->xboxTitleId) return true;+ }+ return false;+ };+ const GameTile* matched = nullptr;+ for (const auto& r : rows_) {+ for (const auto& t : r.tiles) {+ if (matchHero(t)) { matched = &t; break; }+ }+ if (matched) break;+ }+ if (!matched) {+ for (const auto& r : allRows_) {+ for (const auto& t : r.tiles) {+ if (matchHero(t)) { matched = &t; break; }+ }+ if (matched) break;+ }+ }+ if (!matched) {+ for (const auto* list : {&gamePassPool_, &libraryPool_, &allOwned_, &allPurchasable_}) {+ for (const auto& t : *list) {+ if (matchHero(t)) { matched = &t; break; }+ }+ if (matched) break;+ }+ }+ if (matched) {+ hero = matched->heroUrl;+ syncHeroToRowsLocked(matched->productId, matched->titleId, matched->heroUrl,+ matched->description, matched->publisher, matched->categories);+ }+ }+ if (!hero.empty()) {+ syncHeroToRowsLocked(focus->productId, focus->titleId, hero);+ }+ }+ drawHero(c, nowMs, hero, false);if (rows_.empty()) {drawCentered(c, fonts_.semibold, tr(Str::NoGames), 500, 32, kGray);diff --git a/src/ui/app_ui.h b/src/ui/app_ui.hindex 76ef120..f98cb92 100644--- a/src/ui/app_ui.h+++ b/src/ui/app_ui.h@@ -338,6 +338,9 @@ public:// The game whose page is open, if its description or hero art hasn't// arrived; asked again every 5 s while missing (empty otherwise).std::string detailWanted(uint64_t nowMs);+ // Focused game on the Home screen whose hero art is missing; asked again+ // every 5 s while missing (empty otherwise).+ std::string heroWanted(uint64_t nowMs);// The open page's game (xCloud title id) whose queue estimate is due// (one a minute per game); empty when none.std::string queueWanted(uint64_t nowMs);@@ -450,6 +453,8 @@ public:void showFilteredSearch(Tab tab, bool cheapest, int mode, const std::string& genre, int language, int openList = -1);// The search keyboard's focus (row, column), for the tests.std::pair<int, int> searchKeyFocus() const;+ int searchResultFocus() const;+ bool isSearchOnKeys() const;std::vector<std::pair<std::string, PriceInfo>> searchResults(size_t max) const;void chooseFilter(Filter f, int index);std::vector<Filter> filterRow(int row) const;@@ -553,7 +558,10 @@ private:// (letters, wide keys, the two rows of filters), as drawn: up / down// go to the nearest one on screen.std::vector<int> keyCenters(int row) const;- void runSearch();+ void runSearch(bool keepPosition = false);+ void syncHeroToRowsLocked(const std::string& productId, const std::string& titleId, const std::string& heroUrl,+ const std::string& description = "", const std::string& publisher = "",+ const std::vector<std::string>& categories = {});void openDetails(const GameTile& tile);void refreshDetail();void drawDetails(Canvas& c, uint64_t nowMs);@@ -678,6 +686,8 @@ private:std::set<std::string> unclaimable_;std::string detailAskedFor_;uint64_t detailAskedAt_ = 0;+ std::string heroAskedFor_;+ uint64_t heroAskedAt_ = 0;std::string queueAskedFor_, queueTitle_;uint64_t queueAskedAt_ = 0;int queueSeconds_ = -1; // for queueTitle_diff --git a/tests/test_main.cpp b/tests/test_main.cppindex 8748cae..7034973 100644--- a/tests/test_main.cpp+++ b/tests/test_main.cpp@@ -5179,7 +5179,173 @@ static void testCallOfDutyModernWarfare4CatalogAndRefresh() {std::system(("rm -rf " + testDir).c_str());}+static void testBlock1Corrections() {+ using namespace xc;++ // 1. WebUI Facebuttons ABXY static positioning & no transform on active/pressed+ {+ const char* html = app::webServerIndexHtml();+ CHECK(html != nullptr);+ std::string htmlStr(html);+ CHECK(htmlStr.find(".btn-y { top: 0; left: 52px;") != std::string::npos);+ CHECK(htmlStr.find(".btn-a { bottom: 0; left: 52px;") != std::string::npos);+ CHECK(htmlStr.find(".btn-x { top: 52px; left: 0;") != std::string::npos);+ CHECK(htmlStr.find(".btn-b { top: 52px; right: 0;") != std::string::npos);+ // Ensure no transform in abxy-key:active or abxy-key.pressed+ size_t abxyActivePos = htmlStr.find(".abxy-key:active, .abxy-key.pressed");+ CHECK(abxyActivePos != std::string::npos);+ size_t blockEnd = htmlStr.find("}", abxyActivePos);+ CHECK(blockEnd != std::string::npos);+ std::string abxyBlock = htmlStr.substr(abxyActivePos, blockEnd - abxyActivePos);+ CHECK(abxyBlock.find("transform") == std::string::npos);+ CHECK(abxyBlock.find("scale") == std::string::npos);+ CHECK(abxyBlock.find("translate") == std::string::npos);+ CHECK(htmlStr.find("-webkit-tap-highlight-color: transparent;") != std::string::npos);+ }++ // 2. Search cursor stability across background updates (pools, prices, delta-sync, setOwned, setRows)+ {+ ui::Fonts fonts;+ ui::ImageCache images([] {});+ ui::AppUi app(fonts, images);++ std::vector<ui::GameTile> pool;+ for (int i = 0; i < 12; ++i) {+ ui::GameTile t;+ t.productId = "GAME_ID_" + std::to_string(i);+ t.titleId = "TITLE_" + std::to_string(i);+ t.name = "Action Game " + std::to_string(i);+ t.playable = true;+ pool.push_back(t);+ }+ app.setSearchPools(pool, {});++ // Open search with query "Action"+ app.showFilteredSearch(ui::Tab::GamePass, false, 0, "", 0, -1);+ app.typeText("Action\n"); // \n moves into results grid+ CHECK(!app.isSearchOnKeys());+ CHECK(app.searchResultFocus() == 0);++ // Move cursor in grid to item 2+ ui::NavInput navRight;+ navRight.right = true;+ app.handle(navRight);+ CHECK(app.searchResultFocus() == 1);+ app.handle(navRight);+ CHECK(app.searchResultFocus() == 2);++ // Simulate background pool update (e.g. hydration/delta-sync)+ app.setSearchPools(pool, {});+ // Focus MUST NOT reset to 0! It should be preserved at 2.+ CHECK(!app.isSearchOnKeys());+ CHECK(app.searchResultFocus() == 2);++ // Simulate background price arrival+ std::map<std::string, ui::PriceInfo> prices;+ prices["GAME_ID_2"] = ui::PriceInfo{"$19.99", "$29.99", 19.99, 29.99};+ app.setPrices(prices);+ CHECK(app.searchResultFocus() == 2);++ // Simulate background ownership update (delta sync)+ app.setOwned({pool[0], pool[1], pool[2]}, {}, true);+ CHECK(app.searchResultFocus() == 2);++ // Simulate background rows update+ ui::GameRow r;+ r.title = "Featured";+ r.tiles = pool;+ app.setRows({r});+ CHECK(app.searchResultFocus() == 2);+ }++ // 3. Friends playing shelf: hero art fetch, resolution, and persistence across Details & Rebuild+ {+ ui::Fonts fonts;+ ui::ImageCache images([] {});+ ui::AppUi app(fonts, images);++ ui::GameTile friendTile;+ friendTile.productId = "PROD_FRIEND_01";+ friendTile.titleId = "TITLE_FRIEND_01";+ friendTile.name = "Friend's Favorite";+ friendTile.playable = true;+ friendTile.heroUrl = ""; // Initially empty+ friendTile.friends = {{"FriendTag", "http://example.com/pic.jpg"}};++ ui::GameRow friendsRow;+ friendsRow.title = "Friends playing now";+ friendsRow.tiles = {friendTile};+ app.setRows({friendsRow});+ app.showHome();++ // 3a. On Home screen with tile focused, heroWanted requests the missing heroUrl+ CHECK(app.heroWanted(100) == "PROD_FRIEND_01");++ // 3b. Detail arrives via setDetailInfo+ std::string heroUrl = "https://images.example.com/hero_friend_01.jpg";+ app.setDetailInfo("PROD_FRIEND_01", "Friend game description", "Studio A", {"Co-Op"}, heroUrl, "E", "ESRB", {});++ // 3c. After details arrived, heroWanted no longer asks for it+ CHECK(app.heroWanted(200).empty());++ // 3d. User opens Details screen, then presses back to Home+ app.showDetails(friendTile);+ CHECK(app.screen() == ui::Screen::Details);++ ui::NavInput navBack;+ navBack.back = true;+ app.handle(navBack);+ CHECK(app.screen() == ui::Screen::Home);++ // Verify the tile on the Friends shelf preserves the heroUrl!+ ui::GameTile resultTile;+ CHECK(app.findTile("TITLE_FRIEND_01", resultTile));+ CHECK(resultTile.heroUrl == heroUrl);++ // 3e. Crucial: Background rebuild (e.g. delta-sync or setOwned) MUST NOT wipe out heroUrl!+ app.setOwned({}, {}, true);+ CHECK(app.findTile("TITLE_FRIEND_01", resultTile));+ CHECK(resultTile.heroUrl == heroUrl);++ // 3f. Tile with partial metadata (only titleId, empty productId) resolves productId via pool+ ui::GameTile partialTile;+ partialTile.productId = ""; // Empty productId+ partialTile.titleId = "TITLE_PARTIAL_99";+ partialTile.name = "Partial Metadata Game";+ partialTile.playable = true;+ partialTile.heroUrl = "";++ ui::GameTile catalogTile;+ catalogTile.productId = "PROD_PARTIAL_99";+ catalogTile.titleId = "TITLE_PARTIAL_99";+ catalogTile.name = "Partial Metadata Game";+ catalogTile.heroUrl = "";+ catalogTile.playable = true;++ ui::GameRow partialRow;+ partialRow.title = "Friends playing partial";+ partialRow.tiles = {partialTile};++ app.setSearchPools({catalogTile}, {});+ app.setRows({partialRow});+ app.showHome();++ // heroWanted must successfully resolve the productId "PROD_PARTIAL_99" from the catalog pool!+ CHECK(app.heroWanted(300) == "PROD_PARTIAL_99");+ }++ // 4. Library::tile resolution by titleId+ {+ app::Library lib;+ ui::GameTile resolved = lib.tile("", "CALLOFDUTYHQ");+ CHECK(!resolved.productId.empty());+ CHECK(resolved.productId == "9NCPSQQD1Z66" || resolved.productId == "9N201KQXS5BM" || resolved.productId == "9NNFG8BQRCXL");+ CHECK(!resolved.heroUrl.empty());+ }+}+int main() {+ testBlock1Corrections();testCallOfDutyModernWarfare4CatalogAndRefresh();testBlock3Features();testWishlist();