Xbox Cloud Gaming app for PS5 Homebrew
C
Cards: keyboard and mouse from the recent list too (a cache without it left the first row bare), the controller icon on games played with the controller only; the players' pads are the console's controller icon
Rafael Abud Ferreira26845a1562b6
diff --git a/src/app/library.cpp b/src/app/library.cppindex e1a68e7..c2f855b 100644--- a/src/app/library.cpp+++ b/src/app/library.cpp@@ -400,6 +400,9 @@ bool Library::load(xcloud::GssvClient& gssv, const std::string& language, constif (t.productId.empty()) continue;recent_.push_back(t.productId);if (!t.xboxTitleId.empty()) xboxTitleOf_[t.productId] = t.xboxTitleId;+ // Its inputs come with it: the first cards show keyboard and+ // mouse without waiting for the whole list (or a cache that has it).+ if (t.mouseKeyboard) mouseKeyboard_.insert(t.productId);r.items.emplace_back(t.productId, t.titleId);if (!products_.count(t.productId)) ids.push_back(t.productId);}diff --git a/src/ui/app_ui.cpp b/src/ui/app_ui.cppindex 9596643..be608ae 100644--- a/src/ui/app_ui.cpp+++ b/src/ui/app_ui.cpp@@ -2726,13 +2726,15 @@ void AppUi::drawCard(Canvas& c, const GameTile& t, int x, int y, bool focused, b}}// Bottom-right: the console it was made for; one style and width for all.- // Left of it, a small keyboard: the cloud takes mouse and keyboard in it.- if (t.mouseKeyboard) {+ // Left of it, how it's played: keyboard and mouse (the cloud takes them+ // in it) or the controller only.+ if (t.mouseKeyboard || fonts_.hasIcons) {int right = x + kCard - 10 - (platformLabel(t.platform) ? 96 + 6 : 0);Rect k{right - 34, y + kCard - 34, 34, 24};c.fillRect(k, rgba(0, 0, 0, 220), 4);- if (fonts_.hasIcons) // the console's own keyboard-and-mouse icon- fonts_.icons.draw(c, kIconKeyboardMouse, k.x + (k.w - fonts_.icons.measure(kIconKeyboardMouse, 18)) / 2, k.y + 3, 18, kWhite);+ const char* glyph = t.mouseKeyboard ? kIconKeyboardMouse : kIconGamepad;+ if (fonts_.hasIcons) // the console's own icons+ fonts_.icons.draw(c, glyph, k.x + (k.w - fonts_.icons.measure(glyph, 18)) / 2, k.y + 3, 18, kWhite);elsedrawKeyboardGlyph(c, k.x + 6, k.y + 6, 22, kWhite);}diff --git a/src/ui/font.h b/src/ui/font.hindex b027a2b..6ca60dc 100644--- a/src/ui/font.h+++ b/src/ui/font.h@@ -66,6 +66,7 @@ struct Fonts {// Code points of the console's icon font.constexpr const char* kIconKeyboardMouse = "\xEF\xA3\xBE"; // U+F8FE+constexpr const char* kIconGamepad = "\xEF\xA1\xB4"; // U+F874// Next UTF-8 code point from `s` at `i` (advances `i`); U+FFFD on bad input.uint32_t nextCodepoint(std::string_view s, size_t& i);diff --git a/src/ui/pad_icons.cpp b/src/ui/pad_icons.cppindex 28d49ac..6b54fe3 100644--- a/src/ui/pad_icons.cpp+++ b/src/ui/pad_icons.cpp@@ -76,15 +76,18 @@ void drawPadIcon(Canvas& c, const Font& font, int x, int y, int w, int index, bovoid drawSlotIcon(Canvas& c, const Font& font, int x, int y, int w, int index, const PadSlot& slot, Color background,const Font* icons) {- if (!slot.keyboard) {+ if (!slot.keyboard && !icons) {drawPadIcon(c, font, x, y, w, index, slot.connected, background);return;}- // A keyboard (and mouse) in the player's colour, numbered like a pad.- Color col = playerColor(index);- if (icons) { // the console's own keyboard-and-mouse icon+ // The console's own controller or keyboard-and-mouse icon (else a drawn+ // keyboard), in the player's colour (dim when free), numbered below.+ bool on = slot.connected || slot.keyboard;+ Color col = on ? playerColor(index) : rgba(70, 70, 70);+ if (icons) {+ const char* glyph = slot.keyboard ? kIconKeyboardMouse : kIconGamepad;int px2 = w * 9 / 10; // as wide as a pad, centred on its height- icons->draw(c, kIconKeyboardMouse, x + (w - icons->measure(kIconKeyboardMouse, px2)) / 2, y - w / 10, px2, col);+ icons->draw(c, glyph, x + (w - icons->measure(glyph, px2)) / 2, y - w / 10, px2, col);} else {int kh = w * 10 / 24;int top = y + (w * 7 / 10 - kh) / 2;@@ -93,7 +96,8 @@ void drawSlotIcon(Canvas& c, const Font& font, int x, int y, int w, int index, c}std::string n = std::to_string(index + 1);int npx = w * 3 / 10;- font.draw(c, n, x + (w - font.measure(n, npx)) / 2, y + w * 7 / 10 + 4, npx, rgba(255, 255, 255));+ font.draw(c, n, x + (w - font.measure(n, npx)) / 2, y + w * 7 / 10 + 4, npx,+ on ? rgba(255, 255, 255) : rgba(110, 110, 110));}int drawPadRow(Canvas& c, const Font& font, int x, int y, int w, int gap, const PadSlots& pads, Color background,diff --git a/src/ui/pad_icons.h b/src/ui/pad_icons.hindex b719014..deaad87 100644--- a/src/ui/pad_icons.h+++ b/src/ui/pad_icons.h@@ -33,7 +33,8 @@ void drawPadIcon(Canvas& c, const Font& font, int x, int y, int w, int index, boint padIconHeight(int w);// The four side by side, `gap` apart; returns the width taken.-// One slot: its pad, or the keyboard and mouse playing in it.+// One slot: its pad, or the keyboard and mouse playing in it (`icons`: the+// console's icon font, whose controller and keyboard are used; nullptr: drawn).void drawSlotIcon(Canvas& c, const Font& font, int x, int y, int w, int index, const PadSlot& slot, Color background,const Font* icons = nullptr);