Skip to content

Xbox Cloud Gaming app for PS5 Homebrew

C

WIP: capability-driven UI, toasts, desktop wording (interrupted by the session limit; to be finished)

Rafael Abud Ferreiraca0ff683f2f6
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b6c9745..00be2cc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -82,6 +82,7 @@ add_library(xcloud_ui STATIC
src/ui/image_cache.cpp
src/ui/app_ui.cpp
src/ui/stream_menu.cpp
+ src/ui/toast_view.cpp
src/ui/pad_icons.cpp
src/ui/accent_color.cpp
src/ui/brand.cpp
diff --git a/src/app/app_core.cpp b/src/app/app_core.cpp
index b71ba5d..b680efe 100644
--- a/src/app/app_core.cpp
+++ b/src/app/app_core.cpp
@@ -18,6 +18,7 @@
#include "app/stream_screen.h"
#include "display/display.h"
#include "input/controller.h"
+#include "input/input_ext.h"
#include "input/kbm.h"
#include "input/keyboard_nav.h"
#include "ui/input_mode.h"
@@ -116,6 +117,31 @@ bool saveSettings(const ui::SettingsChoice& choice) {
return languageChanged;
}
+// What the screens offer (ui::UiCaps): the pads' features (input_ext.h),
+// the display's and the platform's. The PS5 offers every option as it
+// always has: its pads are DualSense, and what its display can't honour at
+// the moment does nothing there, as before (an upscaler on the CPU
+// fallback; 120 Hz then decided at start-up).
+ui::UiCaps uiCaps() {
+ const shell::Caps sc = shell::caps();
+ const display::DisplayCaps dc = display::caps();
+ const input::PadCaps pc = input::anyPadCaps();
+ ui::UiCaps c;
+ c.lightBar = pc.lightBar;
+ c.triggerRumble = pc.triggerRumble;
+ c.adaptiveTriggers = pc.adaptiveTriggers;
+ c.gyro = pc.gyro;
+ c.touchpad = pc.touchpad;
+ c.upscalers = sc.console || dc.upscalers;
+ c.sharpen = sc.console || dc.sharpen;
+ c.deband = sc.console || dc.deband;
+ c.highRefresh = sc.console || dc.highRefreshSwitch;
+ c.console = sc.console;
+ c.openUrl = sc.openUrl;
+ c.selfUpdate = sc.selfUpdate;
+ return c;
+}
+
// --- Input ---------------------------------------------------------------------
// D-pad / left stick with key repeat: first press, then every 110 ms after
@@ -283,6 +309,7 @@ bool coreStartup() {
: g_settings.librarySort == "console" ? ui::LibrarySort::Console
: ui::LibrarySort::Recent);
}
+ g_ui->setCaps(uiCaps());
g_core->canvas.emplace(display::kWidth, display::kHeight);
if (!net::initTls(g_autoplay.badCa ? platform::assetDir() + "/missing.pem" : platform::caBundlePath())) {
@@ -297,6 +324,7 @@ bool coreStartup() {
startWorker();
}
g_core->streamScreen.emplace(fonts);
+ g_core->streamScreen->setCaps(uiCaps());
crash::startWatchdog(15000); // a main loop stuck for 15 s leaves a marker
return true;
}
@@ -331,7 +359,9 @@ bool Core::frame() {
ui::Screen now = g_ui->screen();
if (now == ui::Screen::Home || now == ui::Screen::Details || now == ui::Screen::Settings) {
clockTold = true;
- platform::notify(ui::trf(ui::Str::ClockWrongNotice, net::todayText()), "the console's clock looks wrong (notification)");
+ platform::notify(ui::trf(shell::caps().console ? ui::Str::ClockWrongNotice : ui::Str::ClockWrongNoticePc,
+ net::todayText()),
+ "the console's clock looks wrong (notification)");
}
}
// After an update: the new version, started in place of this one.
@@ -376,7 +406,10 @@ bool Core::frame() {
}
mouseButtonsBefore = kbm.buttons;
std::erase_if(swallowedKeys, [&](uint8_t vk) { return !std::binary_search(kbm.held.begin(), kbm.held.end(), vk); });
- if ((!inGame || streamScreen->menuOpen()) && !capturing) {
+ // On a desktop the digits are typed for other things too: Ctrl + 1-4 there.
+ static const bool playerKeysNeedCtrl = !shell::caps().console;
+ bool ctrlHeld = std::binary_search(kbm.held.begin(), kbm.held.end(), uint8_t{0x11});
+ if ((!inGame || streamScreen->menuOpen()) && !capturing && (!playerKeysNeedCtrl || ctrlHeld)) {
for (const auto& k : kbm.keys) {
if (!k.pressed || k.vk < '1' || k.vk > '4') continue;
int player = k.vk - '1';
@@ -453,6 +486,10 @@ bool Core::frame() {
}
g_ui->setPads(slots);
streamScreen->setPads(slots);
+ // The pads that came or went may change what the screens offer.
+ ui::UiCaps caps = uiCaps();
+ g_ui->setCaps(caps);
+ streamScreen->setCaps(caps);
}
ui::NavInput nav;
@@ -617,6 +654,12 @@ bool Core::frame() {
g_command = kSignIn;
break;
case ui::Action::Report: openReport(ev.reportWhat, false, ui::tr(ui::Str::ReportProblem)); break;
+ case ui::Action::OpenUrl: {
+ // A desktop: the sign-in page, the report form, the release page.
+ bool ok = shell::openUrl(ev.url);
+ XC_LOGI("browser: %s (a link of %zu characters)", ok ? "opened" : "could not be opened", ev.url.size());
+ break;
+ }
case ui::Action::None: break;
}
diff --git a/src/app/stream_screen.cpp b/src/app/stream_screen.cpp
index d888e3f..ff9f146 100644
--- a/src/app/stream_screen.cpp
+++ b/src/app/stream_screen.cpp
@@ -5,13 +5,17 @@
#include "app/app_state.h"
#include "app/autoplay.h"
+#include "app/shell.h"
#include "app/stream_player.h"
#include "display/display.h"
+#include "input/input_ext.h"
#include "input/kbm.h"
#include "input/keyboard_nav.h"
#include "media/audio_out.h"
#include "platform/platform.h"
+#include "platform/toasts.h"
#include "ui/strings.h"
+#include "ui/toast_view.h"
#include "util/log.h"
#include <algorithm>
@@ -79,6 +83,18 @@ void StreamScreen::setPads(const ui::PadSlots& slots) {
if (menu_.isOpen()) overlaySeq_ = 0;
}
+void StreamScreen::setCaps(const ui::UiCaps& caps) {
+ if (caps == menu_.capabilities()) return;
+ menu_.setCapabilities(caps);
+ if (menu_.isOpen()) overlaySeq_ = 0;
+}
+
+void StreamScreen::setMouseCaptured_(bool captured) {
+ if (captured == mouseCaptured_) return;
+ mouseCaptured_ = captured;
+ input::kbmSetCaptured(captured);
+}
+
void StreamScreen::applyDeband_() { display::setDeband(deband_ == 3 ? autoDeband_.level() : deband_); }
void StreamScreen::update(const input::ControllerState& pad, ui::NavInput nav, bool menuCombo) {
@@ -428,6 +444,15 @@ void StreamScreen::update(const input::ControllerState& pad, ui::NavInput nav, b
}
if (on) g_player->sendInput(other, i);
}
+ // The window holds the mouse while the keyboard and mouse go to the
+ // game (natively, or as a player's controller): not with the app's
+ // menu (or a system keyboard) up, nor while another window has the
+ // focus (the desktop shell lets go of it at once then). A no-op on
+ // the PS5.
+ setMouseCaptured_((kbm_.keyboard || kbm_.mouse) && !menu_.isOpen() && g_keyboardFor.empty() &&
+ shell::hasFocus());
+ } else {
+ setMouseCaptured_(false);
}
// The overlay: the menu, else the statistics line, redrawn when
// the numbers or the menu change.
@@ -450,8 +475,12 @@ void StreamScreen::update(const input::ControllerState& pad, ui::NavInput nav, b
}
uint64_t nowMs = platform::nowMs();
bool menuRedraw = menu_.isOpen() && (nowMs - lastMenuRedrawMs_ >= 40);
- if (overlaySeq_ != seq + 1 || menuRedraw) {
+ // A desktop's toasts take the overlay while they last (the menu still
+ // comes first); the PS5's notifications are the system's.
+ uint64_t toasts = platform::toastsEnabled() ? platform::toasts().version(nowMs) : 0;
+ if (overlaySeq_ != seq + 1 || menuRedraw || toasts != toastsShown_) {
overlaySeq_ = seq + 1;
+ toastsShown_ = toasts;
if (menuRedraw) lastMenuRedrawMs_ = nowMs;
ui::StreamInfo info;
{
@@ -465,6 +494,9 @@ void StreamScreen::update(const input::ControllerState& pad, ui::NavInput nav, b
menu_.setMicMuted(micMuted);
ui::Canvas c = menu_.renderMenu(info);
display::setOverlay(c.data(), ui::StreamMenu::kMenuX, ui::StreamMenu::kMenuY, c.width(), c.height(), 235);
+ } else if (auto shown = toasts ? platform::toasts().visible(nowMs) : std::vector<std::string>(); !shown.empty()) {
+ ui::Canvas c = ui::renderToastPanel(fonts_, shown);
+ display::setOverlay(c.data(), (static_cast<int>(display::kWidth) - c.width()) / 2, 28, c.width(), c.height(), 235);
} else if (showStats_ && seq) {
ui::Canvas c = menu_.renderStats(info);
display::setOverlay(c.data(), ui::StreamMenu::kStatsX, ui::StreamMenu::kStatsY, c.width(), c.height(), 200);
@@ -492,6 +524,7 @@ int keyboardPadSlot(bool keyboardConnected) {
}
void StreamScreen::idle() {
+ setMouseCaptured_(false); // the stream ended: the mouse is the menus' again
keysInGame_.clear();
kbSlotAttached_ = -1;
mouseStick_ = {};
diff --git a/src/app/stream_screen.h b/src/app/stream_screen.h
index 78e49d6..0fb144c 100644
--- a/src/app/stream_screen.h
+++ b/src/app/stream_screen.h
@@ -4,7 +4,7 @@
// TOUCHPAD, or a swipe), the touchpad's Xbox button, the controllers sent to
// the game, the console keyboard for its text fields, the picture settings
// (sharpness, upscaling, block smoothing with "auto") and what is laid over
-// the picture (the menu or the statistics line).
+// the picture (the menu or the statistics line, and a desktop's toasts).
#pragma once
#include "app/auto_deband.h"
@@ -26,7 +26,7 @@ int keyboardPadSlot(bool keyboardConnected);
class StreamScreen {
public:
- explicit StreamScreen(const ui::Fonts& fonts) : menu_(fonts) {}
+ explicit StreamScreen(const ui::Fonts& fonts) : fonts_(fonts), menu_(fonts) {}
// The controllers' slots, for the menu.
void setPads(const ui::PadSlots& slots);
@@ -39,13 +39,19 @@ public:
bool menuOpen() const;
// The hints changed device (keyboard / controller): the overlay again.
void redrawMenu();
+ // What the display and the pads can do: the game menu hides the rest.
+ void setCaps(const ui::UiCaps& caps);
// Each pass on any other screen: what the stream left is cleared, and a
// console keyboard still up is closed.
void idle();
private:
void applyDeband_();
+ // The mouse held by the window (input::kbmSetCaptured) while it should
+ // be: a game has the keyboard and mouse, its menu closed, the window focused.
+ void setMouseCaptured_(bool captured);
+ const ui::Fonts& fonts_;
ui::StreamMenu menu_;
const StreamPlayer* overlayPlayer_ = nullptr;
int streamResolution_ = 0; // as SettingsChoice::resolution
@@ -80,6 +86,8 @@ private:
std::vector<uint8_t> keysInGame_; // keys the game was told are down
bool wasStreaming_ = false;
uint64_t lastMenuRedrawMs_ = 0;
+ uint64_t toastsShown_ = 0; // platform::toasts()'s version in the overlay
+ bool mouseCaptured_ = false; // as last asked of input::kbmSetCaptured
};
} // namespace xc::app
diff --git a/src/app/worker.cpp b/src/app/worker.cpp
index 626c08b..b1f338d 100644
--- a/src/app/worker.cpp
+++ b/src/app/worker.cpp
@@ -95,7 +95,8 @@ std::string stream(xcloud::GssvClient& gssv) {
if (g_settings.gestureHints < 3) {
++g_settings.gestureHints;
g_settings.save(settingsPath());
- platform::notify(ui::tr(ui::Str::GestureHint));
+ // (Without a touchpad: the buttons and keys that do the same.)
+ platform::notify(ui::tr(g_ui->caps().touchpad ? ui::Str::GestureHint : ui::Str::GestureHintButtons));
}
}
@@ -427,10 +428,13 @@ void checkForUpdate() {
std::string err;
bool found = findLatestRelease(r, err, g_autoplay.updateFeed);
XC_LOGI("latest release: %s (this is %s)", found ? r.tag.c_str() : err.c_str(), XC_APP_VERSION);
- bool offer = found && isNewerVersion(r.tag, XC_APP_VERSION) && !r.zipUrl.empty() && !r.sigUrl.empty();
- if (found && isNewerVersion(r.tag, XC_APP_VERSION) && !offer) XC_LOGW("%s has no signed package", r.tag.c_str());
- if (offer && !shell::canSelfUpdate()) {
- // This build doesn't install updates itself (only the PS5's does).
+ bool newer = found && isNewerVersion(r.tag, XC_APP_VERSION);
+ bool offer = newer && !r.zipUrl.empty() && !r.sigUrl.empty();
+ if (newer && !offer) XC_LOGW("%s has no signed package", r.tag.c_str());
+ const bool selfUpdate = shell::canSelfUpdate();
+ if (newer && !selfUpdate) {
+ // This build doesn't install updates itself (only the PS5's does):
+ // Settings names the new version and opens its page instead.
XC_LOGI("%s is out: this build doesn't update itself", r.tag.c_str());
offer = false;
}
@@ -438,7 +442,7 @@ void checkForUpdate() {
std::lock_guard<std::mutex> lock(g_releaseMutex);
g_release = offer ? r : Release{};
}
- g_ui->setUpdateState(XC_APP_VERSION, offer ? r.tag : std::string(), false);
+ g_ui->setUpdateState(XC_APP_VERSION, offer || (newer && !selfUpdate) ? r.tag : std::string(), false);
bool skipped;
{
std::lock_guard<std::mutex> lock(g_settingsMutex);
@@ -550,7 +554,7 @@ void signInAndLoad(auth::AuthManager& am, xcloud::GssvClient& gssv) {
} else if (net::lastTlsProblem() == net::TlsProblem::Clock) {
// The console's clock: a certificate isn't valid at its date (the
// log line above has the details).
- g_ui->showError(ui::trf(ui::Str::ClockWrong, net::todayText()));
+ g_ui->showError(ui::trf(shell::caps().console ? ui::Str::ClockWrong : ui::Str::ClockWrongPc, net::todayText()));
} else if (net::lastTlsProblem() == net::TlsProblem::Untrusted ||
net::lastTlsProblem() == net::TlsProblem::NameMismatch) {
g_ui->showError(ui::tr(ui::Str::ConnectionIntercepted));
diff --git a/src/ui/app_ui.cpp b/src/ui/app_ui.cpp
index a2a7441..77dee5b 100644
--- a/src/ui/app_ui.cpp
+++ b/src/ui/app_ui.cpp
@@ -7,8 +7,10 @@
#include "xcloud/catalog.h"
#include "ui/accent_color.h"
+#include "platform/toasts.h"
#include "ui/brand.h"
#include "ui/strings.h"
+#include "ui/toast_view.h"
#include "qrcodegen.h"
@@ -59,11 +61,6 @@ constexpr int kResolutionOrder[3] = {1, 0, 2};
constexpr int kSettingsOrder[kSettingRows] = {0, 8, 1, 9, 10, 2, 11, 3, 4, 5, 6, 12, 7};
constexpr bool kSettingsGroupStart[kSettingRows] = {false, false, true, false, false, false, true,
true, false, false, false, false, true};
-int settingsPos(int row) {
- for (int i = 0; i < kSettingRows; ++i)
- if (kSettingsOrder[i] == row) return i;
- return 0;
-}
// The game settings' rows on screen (ids: 0 profile, 1 upscaler, 2
// sharpness, 3 block smoothing, 4 resolution, 5 dead zone, 6 triggers, 7
// confirm, 8 120 Hz, 9 keyboard keys, 10 back to the default).
@@ -71,6 +68,30 @@ constexpr int kGameRowOrder[11] = {0, 4, 8, 1, 2, 3, 5, 6, 7, 9, 10};
constexpr bool kGameGroupStart[11] = {false, true, false, true, false, false, true, false, false, false, true};
// The keyboard keys' screen: two columns of inputs, then "Reset to default".
constexpr int kKeysPerColumn = input::kKeyActions / 2;
+// Updates on a desktop: the newest release's page (the app doesn't install it there).
+constexpr const char* kReleasesPage = "https://github.com/RafaelNGP/xbox-cloud-gaming-ps5/releases/latest";
+
+// The rows of `order` that `shown` keeps. A group starts on screen where the
+// row above belongs to another group (a hidden group leaves no gap).
+template <size_t N, class Shown>
+std::vector<SettingsRowPos> filterRows(const int (&order)[N], const bool (&groupStart)[N], Shown shown) {
+ std::vector<SettingsRowPos> out;
+ int group = 0, lastGroup = -1;
+ for (size_t pos = 0; pos < N; ++pos) {
+ if (groupStart[pos]) ++group;
+ if (!shown(order[pos])) continue;
+ out.push_back({order[pos], !out.empty() && group != lastGroup});
+ lastGroup = group;
+ }
+ return out;
+}
+
+// Where `row` is in `rows` (0 when it isn't there).
+int posOf(const std::vector<SettingsRowPos>& rows, int row) {
+ for (size_t i = 0; i < rows.size(); ++i)
+ if (rows[i].row == row) return static_cast<int>(i);
+ return 0;
+}
// Grids ("Your games", search results): cards with the name below.
constexpr int kGridPitchY = 300;
@@ -213,6 +234,31 @@ constexpr uint64_t kSignOutHoldMs = 5000;
} // namespace
+std::vector<SettingsRowPos> visibleSettingsRows(const UiCaps& caps) {
+ return filterRows(kSettingsOrder, kSettingsGroupStart, [&](int row) {
+ switch (row) {
+ case 4: return caps.triggerRumble || caps.adaptiveTriggers; // trigger vibration and its tester
+ case 6: return caps.lightBar;
+ case 9: return caps.highRefresh;
+ default: return true;
+ }
+ });
+}
+
+std::vector<SettingsRowPos> visibleGameSettingsRows(const UiCaps& caps, bool custom) {
+ return filterRows(kGameRowOrder, kGameGroupStart, [&](int row) {
+ switch (row) {
+ case 1: return caps.upscalers;
+ case 2: return caps.sharpen;
+ case 3: return caps.deband;
+ case 6: return caps.triggerRumble || caps.adaptiveTriggers;
+ case 8: return caps.highRefresh;
+ case 10: return custom;
+ default: return true;
+ }
+ });
+}
+
std::string loginCountryName(const std::string& country) {
static const std::pair<const char*, Str> kNames[] = {
{"br", Str::CountryBR}, {"jp", Str::CountryJP}, {"kr", Str::CountryKR}, {"pl", Str::CountryPL}, {"us", Str::CountryUS}};
@@ -1076,7 +1122,7 @@ void AppUi::handleTester(const NavInput& in) {
if (now[i] != testSticks_[i]) testSticks_[i] = now[i], dirty_ = true;
} else {
if (in.up && testerRow_ > 0) --testerRow_, dirty_ = true;
- if (in.down && testerRow_ < 3) ++testerRow_, dirty_ = true;
+ if (in.down && testerRow_ < triggerTesterRows() - 1) ++testerRow_, dirty_ = true;
int delta = (in.right ? 1 : 0) - (in.left ? 1 : 0);
if (delta && testerRow_ == 0)
settings_.triggerStrength = std::clamp(settings_.triggerStrength + delta, 0, input::kTriggerStrengths - 1);
@@ -1353,7 +1399,7 @@ std::vector<std::string> AppUi::settingOptions(int row) const {
out = {tr(settings_.keyMap == input::defaultKeyMap() ? Str::ProfileDefault : Str::ProfileCustom)};
} else if (row == 8) {
- out.push_back(tr(Str::LoginCountryOff));
+ out.push_back(loginCountryOffText());
for (const char* country : kLoginCountries) out.push_back(loginCountryName(country));
} else {
// Automatic first, then the regions in the login's order.
@@ -1445,6 +1491,47 @@ void AppUi::invalidate() {
dirty_ = true;
}
+void AppUi::setCaps(const UiCaps& caps) {
+ std::lock_guard<std::mutex> lock(mutex_);
+ if (caps == caps_) return;
+ caps_ = caps;
+ dirty_ = true;
+ // A pad without what a row is for came in (or the one with it left): the
+ // focus goes to the row after it, and what the row had open closes.
+ const auto rows = visibleSettingsRows(caps_);
+ auto shown = [&](int row) {
+ return std::any_of(rows.begin(), rows.end(), [&](const SettingsRowPos& r) { return r.row == row; });
+ };
+ if (!shown(settingsRow_)) {
+ int pos = 0, next = -1;
+ for (int i = 0; i < kSettingRows; ++i)
+ if (kSettingsOrder[i] == settingsRow_) pos = i;
+ for (int i = pos; i < kSettingRows && next < 0; ++i)
+ if (shown(kSettingsOrder[i])) next = kSettingsOrder[i];
+ for (int i = pos; i >= 0 && next < 0; --i)
+ if (shown(kSettingsOrder[i])) next = kSettingsOrder[i];
+ settingsRow_ = next < 0 ? 0 : next; // the language row is always there
+ dropdownOpen_ = pickerOpen_ = false;
+ if (tester_ == Tester::Triggers && !gameSettingsOpen_) tester_ = Tester::None, settings_ = testerBackup_;
+ }
+ if (tester_ == Tester::Triggers && !caps_.triggerRumble && !caps_.adaptiveTriggers) {
+ if (gameSettingsOpen_) settings_ = testerBackup_;
+ tester_ = Tester::None;
+ }
+ testerRow_ = std::min(testerRow_, triggerTesterRows() - 1);
+ int gameRows = static_cast<int>(visibleGameSettingsRows(caps_, activeGameHasCustom_).size());
+ gameSettingsRow_ = std::min(gameSettingsRow_, gameRows - 1);
+}
+
+UiCaps AppUi::caps() const {
+ std::lock_guard<std::mutex> lock(mutex_);
+ return caps_;
+}
+
+const char* AppUi::loginCountryOffText() const {
+ return tr(caps_.console ? Str::LoginCountryOff : Str::LoginCountryOffPc);
+}
+
const GameTile* AppUi::focusedTile() const {
if (focusRow_ < 0 || focusRow_ >= static_cast<int>(rows_.size())) return nullptr;
const auto& row = rows_[static_cast<size_t>(focusRow_)];
@@ -1956,7 +2043,9 @@ void AppUi::handleGameSettings(const NavInput& in, UiEvent& ev) {
handleTester(in);
return;
}
- int rowCount = activeGameHasCustom_ ? 11 : 10;
+ // The rows on screen (gameSettingsRow_ is a position among them).
+ const auto rows = visibleGameSettingsRows(caps_, activeGameHasCustom_);
+ const int rowCount = static_cast<int>(rows.size());
if (in.up) {
gameSettingsRow_ = (gameSettingsRow_ + rowCount - 1) % rowCount;
dirty_ = true;
@@ -1965,7 +2054,7 @@ void AppUi::handleGameSettings(const NavInput& in, UiEvent& ev) {
gameSettingsRow_ = (gameSettingsRow_ + 1) % rowCount;
dirty_ = true;
}
- const int rowId = kGameRowOrder[std::clamp(gameSettingsRow_, 0, 10)];
+ const int rowId = rows[static_cast<size_t>(std::clamp(gameSettingsRow_, 0, rowCount - 1))].row;
if (in.left || in.right) {
int dir = in.right ? 1 : -1;
switch (rowId) {
@@ -2136,7 +2225,13 @@ UiEvent AppUi::handle(const NavInput& in) {
std::lock_guard<std::mutex> lock(mutex_);
UiEvent ev;
if (reportOpen_) { // the report's QR code: Circle (or Cross) closes it
- if (in.back || in.accept) reportOpen_ = false, dirty_ = true;
+ if (in.accept && caps_.openUrl) {
+ // A desktop: Cross opens the form in the browser (the panel stays).
+ ev.action = Action::OpenUrl;
+ ev.url = reportUrl_;
+ } else if (in.back || in.accept) {
+ reportOpen_ = false, dirty_ = true;
+ }
return ev;
}
if (screen_ == Screen::Home && updatePrompt_) {
@@ -2165,6 +2260,13 @@ UiEvent AppUi::handle(const NavInput& in) {
}
switch (screen_) {
case Screen::Home: handleHome(in, ev); break;
+ case Screen::SignIn:
+ // A desktop: Cross (Enter) opens the sign-in page in the browser.
+ if (in.accept && caps_.openUrl) {
+ ev.action = Action::OpenUrl;
+ ev.url = codeUrl_.empty() ? "https://www.microsoft.com/link" : codeUrl_;
+ }
+ break;
case Screen::Settings:
if (pickerOpen_) {
handleColourPicker(in);
@@ -2186,18 +2288,28 @@ UiEvent AppUi::handle(const NavInput& in) {
dirty_ = true;
break;
}
- if (int pos = settingsPos(settingsRow_); in.down && pos < kSettingRows - 1)
- settingsRow_ = kSettingsOrder[pos + 1], dirty_ = true;
- else if (in.up && pos > 0)
- settingsRow_ = kSettingsOrder[pos - 1], dirty_ = true;
+ if (auto rows = visibleSettingsRows(caps_); true) { // the rows on screen, in their order
+ int pos = posOf(rows, settingsRow_);
+ if (in.down && pos + 1 < static_cast<int>(rows.size()))
+ settingsRow_ = rows[static_cast<size_t>(pos + 1)].row, dirty_ = true;
+ else if (in.up && pos > 0)
+ settingsRow_ = rows[static_cast<size_t>(pos - 1)].row, dirty_ = true;
+ }
if (in.right) changeSetting(+1);
if (in.left) changeSetting(-1);
if (in.accept && (settingsRow_ == 3 || settingsRow_ == 4 || settingsRow_ == 12)) {
// Dead zone, trigger vibration, keyboard keys: their own screens instead of a list.
openTester(settingsRow_ == 3 ? Tester::Sticks : settingsRow_ == 4 ? Tester::Triggers : Tester::Keys);
} else if (in.accept && settingsRow_ == 7) {
- // Updates: a newer version is installed (the settings saved first).
- if (!updateAvailable_.empty() && !updateChecking_) {
+ // Updates: a newer version is installed (the settings saved
+ // first). Where the app doesn't install it, the release's
+ // page opens in the browser instead.
+ if (!caps_.selfUpdate) {
+ if (caps_.openUrl) {
+ ev.action = Action::OpenUrl;
+ ev.url = kReleasesPage;
+ }
+ } else if (!updateAvailable_.empty() && !updateChecking_) {
ev.action = Action::UpdateNow;
ev.settings = settings_;
}
@@ -2301,6 +2413,8 @@ bool AppUi::needsRedraw(uint64_t nowMs) const {
std::lock_guard<std::mutex> lock(mutex_);
if (screen_ == Screen::Streaming) return false;
if (dirty_ || animating_) return true;
+ // A desktop's toast came or went (the PS5 sends system notifications).
+ if (platform::toastsEnabled() && platform::toasts().version(nowMs) != toastsDrawn_) return true;
// Spinners keep moving (about 30 fps is enough).
bool spinner = screen_ == Screen::Splash || screen_ == Screen::SignIn || screen_ == Screen::Launching ||
screen_ == Screen::Updating;
@@ -2566,6 +2680,7 @@ void AppUi::drawSignIn(Canvas& c, uint64_t nowMs) {
int w = fonts_.regular.measure(tr(Str::SignInScan), 26);
fonts_.regular.draw(c, tr(Str::SignInScan), box.x + (box.w - w) / 2, box.y + box.h + 24, 26, kGray);
}
+ if (caps_.openUrl) drawHints(c, {{kIconCross, tr(Str::OpenInBrowser)}}); // a desktop: the page in the browser
}
void AppUi::drawTabs(Canvas& c) {
@@ -3329,7 +3444,8 @@ 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::GestureHint), 900, 22, kDim);
+ // The touchpad's gestures, or the buttons and keys that do the same.
+ drawCentered(c, fonts_.regular, tr(caps_.touchpad ? Str::GestureHint : Str::GestureHintButtons), 900, 22, kDim);
drawHints(c, {{kIconCircle, tr(Str::Cancel)}});
}
@@ -3368,9 +3484,8 @@ void AppUi::drawSettings(Canvas& c) {
constexpr int kRowW = 1200, kRowH = 46, kGap = 5, kGroupGap = 16;
Rect rows[kSettingRows]; // by row id
int y = 236;
- for (int pos = 0; pos < kSettingRows; ++pos) {
- const int i = kSettingsOrder[pos];
- if (kSettingsGroupStart[pos]) y += kGroupGap;
+ for (const auto& [i, groupStart] : visibleSettingsRows(caps_)) { // what caps_ rules out is hidden
+ if (groupStart) y += kGroupGap;
Rect r{kMargin, y, kRowW, kRowH};
rows[i] = r;
bool focused = i == settingsRow_;
@@ -3380,9 +3495,10 @@ void AppUi::drawSettings(Canvas& c) {
fonts_.semibold.draw(c, labels[i], r.x + 36, ty, 28, kWhite);
if (i == 7) {
// Updates: the state; Cross updates when there is a newer version.
- std::string value = updateChecking_ ? tr(Str::UpdateChecking)
- : !updateAvailable_.empty() ? trf(Str::UpdateReady, updateAvailable_)
- : trf(Str::UpToDate, "v" + updateCurrent_);
+ std::string value = updateChecking_ ? tr(Str::UpdateChecking)
+ : !updateAvailable_.empty()
+ ? trf(caps_.selfUpdate ? Str::UpdateReady : Str::UpdateReadyPc, updateAvailable_)
+ : trf(Str::UpToDate, "v" + updateCurrent_);
Color color = !updateAvailable_.empty() && !updateChecking_ ? rgba(120, 220, 120) : focused ? kWhite : kGray;
int w = fonts_.regular.measure(value, 28);
fonts_.regular.draw(c, value, r.x + r.w - 44 - w, fonts_.regular.centeredY(r.y, r.h, 28), 28, color);
@@ -3506,7 +3622,10 @@ void AppUi::drawReport(Canvas& c) {
}
}
c.fillRect({0, kH - 80, kW, 80}, kBg);
- drawHints(c, {{kIconCircle, tr(Str::Back)}});
+ if (caps_.openUrl) // a desktop: Cross opens the form in the browser
+ drawHints(c, {{kIconCross, tr(Str::OpenInBrowser)}, {kIconCircle, tr(Str::Back)}});
+ else
+ drawHints(c, {{kIconCircle, tr(Str::Back)}});
}
void AppUi::drawCountryPicker(Canvas& c) {
@@ -3526,7 +3645,7 @@ void AppUi::drawCountryPicker(Canvas& c) {
Rect item{panel.x + 48, panel.y + listY + i * kItemH, panel.w - 96, kItemH};
bool on = i == countryIndex_;
if (on) c.fillRect(item, kWhite, 12);
- std::string label = i ? loginCountryName(kLoginCountries[i - 1]) : tr(Str::LoginCountryOff);
+ std::string label = i ? loginCountryName(kLoginCountries[i - 1]) : loginCountryOffText();
fonts_.semibold.draw(c, label, item.x + 24, fonts_.semibold.centeredY(item.y, item.h, 26), 26,
on ? kBg : (i == sel ? kWhite : kGray));
if (i == sel) { // a check mark on the current choice
@@ -3619,7 +3738,9 @@ void AppUi::drawStickTester(Canvas& c) {
}
void AppUi::drawTriggerTester(Canvas& c) {
- Rect panel = drawModal(c, 1100, 830, tr(Str::TriggerRumble));
+ // Without adaptive triggers, no resistance or style rows: the panel shorter by them.
+ const int rows = triggerTesterRows(), lessY = (4 - rows) * 84;
+ Rect panel = drawModal(c, 1100, 830 - lessY, tr(Str::TriggerRumble));
// The two choices, as Settings' rows: up / down picks one, left / right changes it.
const char* strengths[] = {tr(Str::Deactivated), tr(Str::TriggerLight), tr(Str::TriggerMedium), tr(Str::TriggerStrong),
tr(Str::TriggerMax)};
@@ -3632,7 +3753,7 @@ void AppUi::drawTriggerTester(Canvas& c) {
std::string(freqs[settings_.triggerHz]) + " (" + std::to_string(hz) + " Hz)",
strengths[settings_.triggerResistance], // off, light, medium, strong
tr(settings_.triggerPulses ? Str::StylePulses : Str::StyleVibration)};
- for (int i = 0; i < 4; ++i) {
+ for (int i = 0; i < rows; ++i) {
Rect r{panel.x + 56, panel.y + 120 + i * 84, panel.w - 112, 70};
bool on = i == testerRow_;
c.fillRect(r, on ? rgba(255, 255, 255, 36) : rgba(255, 255, 255, 14), 16);
@@ -3646,7 +3767,7 @@ void AppUi::drawTriggerTester(Canvas& c) {
const float pressed[2] = {testL2_, testR2_};
for (int t = 0; t < 2; ++t) {
constexpr int kBarW = 90, kBarH = 170;
- int bx = panel.x + panel.w / 2 + (t ? 80 : -80 - kBarW), by = panel.y + 490;
+ int bx = panel.x + panel.w / 2 + (t ? 80 : -80 - kBarW), by = panel.y + 490 - lessY;
c.fillRect({bx, by, kBarW, kBarH}, rgba(255, 255, 255, 20), 16);
int fill = static_cast<int>(kBarH * std::clamp(pressed[t], 0.0f, 1.0f));
int level = input::triggerAmplitude(static_cast<uint8_t>(std::lround(pressed[t] * 255)), settings_.triggerStrength);
@@ -3867,15 +3988,22 @@ void AppUi::drawGameSettings(Canvas& c) {
}
}
constexpr int kModalW = 1140, kModalH = 860;
- Rect panel = drawModal(c, kModalW, kModalH, title);
-
- int rowCount = activeGameHasCustom_ ? 11 : 10;
constexpr int kRowH = 52, kGap = 7, kGroupGap = 12;
+ // The rows caps_ allows; the panel loses the height of those it hides
+ // (the same as ever with all of them, "Reset to default" or not).
+ const auto rows = visibleGameSettingsRows(caps_, activeGameHasCustom_);
+ const auto most = visibleGameSettingsRows(caps_, true), all = visibleGameSettingsRows(UiCaps{}, true);
+ auto groups = [](const std::vector<SettingsRowPos>& v) {
+ return static_cast<int>(std::count_if(v.begin(), v.end(), [](const SettingsRowPos& r) { return r.groupStart; }));
+ };
+ const int modalH = kModalH - static_cast<int>(all.size() - most.size()) * (kRowH + kGap) -
+ (groups(all) - groups(most)) * kGroupGap;
+ Rect panel = drawModal(c, kModalW, modalH, title);
int y = panel.y + 106;
- for (int pos = 0; pos < rowCount; ++pos) {
- const int i = kGameRowOrder[pos];
- if (kGameGroupStart[pos]) y += kGroupGap;
+ for (int pos = 0; pos < static_cast<int>(rows.size()); ++pos) {
+ const int i = rows[static_cast<size_t>(pos)].row;
+ if (rows[static_cast<size_t>(pos)].groupStart) y += kGroupGap;
Rect r{panel.x + 50, y, panel.w - 100, kRowH};
bool focused = (pos == gameSettingsRow_);
c.fillRect(r, focused ? rgba(255, 255, 255, 36) : rgba(255, 255, 255, 14), 14);
@@ -3996,6 +4124,11 @@ void AppUi::render(Canvas& c, uint64_t nowMs) {
if (reportOpen_) drawReport(c);
if ((screen_ == Screen::Home && !updatePrompt_) || screen_ == Screen::Error) drawSignOutHold(c, nowMs);
if (!toast_.empty()) animating_ = true; // to expire it
+ if (platform::toastsEnabled()) {
+ // platform::notify() on a desktop: over everything, under the top bar's right side.
+ toastsDrawn_ = platform::toasts().version(nowMs);
+ drawToasts(c, fonts_, platform::toasts().visible(nowMs), kW - kMargin, 132);
+ }
}
} // namespace xc::ui
diff --git a/src/ui/app_ui.h b/src/ui/app_ui.h
index 0f404e6..8541e5c 100644
--- a/src/ui/app_ui.h
+++ b/src/ui/app_ui.h
@@ -121,6 +121,39 @@ struct SettingsChoice {
input::KeyMap keyMap = input::defaultKeyMap(); // the keyboard as a player's controller
};
+// What this system and its pads can do, filled in by the app from the pads'
+// capabilities (input/input_ext.h), display::caps() and shell::caps(): the
+// screens hide the options that can't work here and word the rest for the
+// platform. The defaults are the PS5's, where every option shows.
+struct UiCaps {
+ bool lightBar = true; // a pad with a light bar
+ bool triggerRumble = true; // vibration in the triggers (DualSense, Xbox impulse triggers)
+ bool adaptiveTriggers = true; // the DualSense's resistance and pulses
+ bool gyro = true; // gyro aiming
+ bool touchpad = true; // the touchpad's gestures (else the buttons and keys that do the same)
+ bool upscalers = true; // FSR / Anime4K
+ bool sharpen = true;
+ bool deband = true; // block smoothing
+ bool highRefresh = true; // a 120 Hz output setting
+ bool console = true; // "this console" and the PS5 menus' paths (else "this computer")
+ bool openUrl = false; // a link on screen opens in the browser (Cross / Enter)
+ bool selfUpdate = true; // Updates installs the new version (else Cross opens its page)
+ bool operator==(const UiCaps&) const = default;
+};
+
+// A row of Settings (or of a game's settings) as shown: its id, and whether
+// a group of alike rows starts there (a gap above it).
+struct SettingsRowPos {
+ int row = 0;
+ bool groupStart = false;
+};
+// Settings' rows on screen with `caps`, in order: those it rules out are
+// hidden (their setting stays as it is in settings.json).
+std::vector<SettingsRowPos> visibleSettingsRows(const UiCaps& caps);
+// The same for a game's settings (row ids as AppUi draws them); "Reset to
+// default" only with a profile of its own (`custom`).
+std::vector<SettingsRowPos> visibleGameSettingsRows(const UiCaps& caps, bool custom);
+
// The largest stick dead zone Settings offers, in percent of the travel.
constexpr int kMaxDeadzone = 30;
constexpr int kSettingRows = 13; // language, resolution, region, dead zone, triggers, confirm, light bar, updates,
@@ -138,7 +171,8 @@ enum class Action {
None, Play, SignOut, Retry, CancelLaunch, SettingsChanged, PrefsChanged, ConsolesShown, UpdateNow, UpdateLater,
GameSettingsChanged,
Report, // "Report a problem" (Triangle on an error or in Settings): reportWhat is the error shown
- LoginCountry // the sign-in country changed (settings): save them and sign in again
+ LoginCountry, // the sign-in country changed (settings): save them and sign in again
+ OpenUrl // a link on screen to open in the browser (UiCaps::openUrl): `url`
};
// How "Your games" is sorted (R3).
@@ -160,6 +194,7 @@ struct UiEvent {
std::vector<std::string> hidden;
LibrarySort librarySort = LibrarySort::Recent;
std::string reportWhat; // Report: the error on screen (empty from Settings)
+ std::string url; // OpenUrl
};
// "SOUTHCENTRALUS" -> "South Central US".
@@ -302,6 +337,10 @@ public:
// Autoplay tests: where the focus is ("Game Pass row 2 card 6", ...).
std::string focusDescription() const;
void invalidate();
+ // The capabilities in force (UiCaps); the focus leaves a row that goes
+ // away. Any thread.
+ void setCaps(const UiCaps& caps);
+ UiCaps caps() const;
// --- UI thread -----------------------------------------------------------
UiEvent handle(const NavInput& in);
@@ -414,11 +453,18 @@ private:
int settingSelected(int row) const;
void applySetting(int row, int index);
void drawCentered(Canvas& c, const Font& f, const std::string& text, int y, int px, Color color);
+ // The sign-in country's "off" choice, worded for the platform (caller holds mutex_).
+ const char* loginCountryOffText() const;
+ // The trigger tester's rows: intensity and frequency, then resistance
+ // and style with adaptive triggers.
+ int triggerTesterRows() const { return caps_.adaptiveTriggers ? 4 : 2; }
const Fonts& fonts_;
ImageCache& images_;
mutable std::mutex mutex_;
+ UiCaps caps_;
+ uint64_t toastsDrawn_ = 0; // platform::toasts()'s version last drawn
Screen screen_ = Screen::Splash;
bool dirty_ = true;
std::string status_;
diff --git a/src/ui/stream_menu.cpp b/src/ui/stream_menu.cpp
index cf608b1..7b975bb 100644
--- a/src/ui/stream_menu.cpp
+++ b/src/ui/stream_menu.cpp
@@ -32,6 +32,23 @@ std::string fmt(const char* f, double v) {
} // namespace
+bool StreamMenu::itemShown(int item) const {
+ switch (item) {
+ case Upscaler: return caps_.upscalers;
+ case Sharpness: return caps_.sharpen;
+ case Deband: return caps_.deband;
+ case Triggers: return caps_.triggerRumble || caps_.adaptiveTriggers;
+ case GyroItem:
+ case GyroLevelItem: return caps_.gyro;
+ default: return true;
+ }
+}
+
+void StreamMenu::setCapabilities(const UiCaps& caps) {
+ caps_ = caps;
+ while (!itemShown(selected_)) selected_ = (selected_ + 1) % ItemCount; // off a row that went away
+}
+
void StreamMenu::setProfileValues(int resolution, int sharpness, int deband, int upscaler,
int triggerStrength, int deadzone, bool circleConfirms,
bool hasCustomProfile) {
@@ -72,8 +89,9 @@ MenuAction StreamMenu::handle(const NavInput& in) {
open_ = false;
return MenuAction::Close;
}
- if (in.up) selected_ = (selected_ + ItemCount - 1) % ItemCount;
- if (in.down) selected_ = (selected_ + 1) % ItemCount;
+ // Up / down over the items shown (the Xbox button always is).
+ if (in.up) do selected_ = (selected_ + ItemCount - 1) % ItemCount; while (!itemShown(selected_));
+ if (in.down) do selected_ = (selected_ + 1) % ItemCount; while (!itemShown(selected_));
if (selected_ == Profile && (in.left || in.right || in.accept)) {
hasCustomProfile_ = !hasCustomProfile_;
return MenuAction::ProfileToggle;
@@ -153,8 +171,10 @@ Canvas StreamMenu::renderMenu(const StreamInfo& info) const {
// The items: the selected one white, like the Xbox guide.
constexpr int kRowH = 40, kTop = 84, kPx = 20;
+ int shown = 0; // the items on screen so far
for (int i = 0; i < ItemCount; ++i) {
- Rect row{kPad - 16, kTop + i * kRowH, kMenuW - 2 * (kPad - 16), kRowH - 4};
+ if (!itemShown(i)) continue;
+ Rect row{kPad - 16, kTop + shown++ * kRowH, kMenuW - 2 * (kPad - 16), kRowH - 4};
bool sel = i == selected_;
if (sel) c.fillRect(row, kWhite, 8);
Color fg = sel ? kDark : kWhite;
@@ -229,7 +249,7 @@ Canvas StreamMenu::renderMenu(const StreamInfo& info) const {
fonts_.semibold.draw(c, value, row.x + row.w - 16 - w, ty, kPx, sel ? kDark : kGray);
}
}
- int y = kTop + ItemCount * kRowH + 6;
+ int y = kTop + shown * kRowH + 6;
if (resolutionAsked_) {
fonts_.regular.draw(c, tr(Str::ResolutionNote), kPad, y, 16, kDim);
y += 22;
@@ -321,7 +341,9 @@ Canvas StreamMenu::renderMenu(const StreamInfo& info) const {
int hy = kMenuH - 50, x = kPad;
{
// The touchpad's gestures, small, above the button hints.
- auto lines = fonts_.regular.wrap(tr(g_keyboardHints ? Str::MenuKeyHint : Str::MenuGestureHint), 16, kMenuW - 2 * kPad, 2);
+ // (Without a touchpad: the buttons and keys that do the same.)
+ Str hint = g_keyboardHints ? Str::MenuKeyHint : caps_.touchpad ? Str::MenuGestureHint : Str::MenuButtonHint;
+ auto lines = fonts_.regular.wrap(tr(hint), 16, kMenuW - 2 * kPad, 2);
int gy = hy - 14 - static_cast<int>(lines.size()) * 22;
for (const auto& l : lines) {
fonts_.regular.draw(c, l, kPad, gy, 16, kDim);
diff --git a/src/ui/stream_menu.h b/src/ui/stream_menu.h
index a430f0b..23b5c2a 100644
--- a/src/ui/stream_menu.h
+++ b/src/ui/stream_menu.h
@@ -83,6 +83,12 @@ public:
bool hasCustomProfile);
// The controllers in use, under the connection.
void setPads(const PadSlots& pads) { pads_ = pads; }
+ // What the display and the pads can do (UiCaps, all by default as on
+ // the PS5): the upscaler, sharpness and block smoothing need the
+ // display's; trigger vibration and gyro aiming a pad with them; the
+ // footer names the buttons when no pad has a touchpad.
+ void setCapabilities(const UiCaps& caps);
+ const UiCaps& capabilities() const { return caps_; }
Canvas renderMenu(const StreamInfo& info) const;
Canvas renderStats(const StreamInfo& info) const;
@@ -107,7 +113,11 @@ private:
ItemCount
};
+ // Whether `item` is in the menu with caps_.
+ bool itemShown(int item) const;
+
const Fonts& fonts_;
+ UiCaps caps_;
bool open_ = false, stats_ = false;
int selected_ = XboxButton;
int resolution_ = 0, applied_ = 0;
diff --git a/src/ui/strings.cpp b/src/ui/strings.cpp
index aab6e31..ead7839 100644
--- a/src/ui/strings.cpp
+++ b/src/ui/strings.cpp
@@ -285,6 +285,13 @@ constexpr Column kEnglish = {
"Always", // GyroAlways
"While aiming (L2)", // GyroAiming
"Gyro intensity", // GyroIntensity
+ "Secure connections were refused because this computer's date and time look wrong (it says %s). Correct them in the system's settings, then try again.", // ClockWrongPc
+ "This computer's date and time look wrong (%s): some content can't load. Correct them in the system's settings.", // ClockWrongNoticePc
+ "Off (this computer's)", // LoginCountryOffPc
+ "Open in the browser", // OpenInBrowser
+ "%s available: download", // UpdateReadyPc
+ "Menu: START + BACK or F12 · Xbox button: Guide or Home", // GestureHintButtons
+ "START + BACK or F12: this menu · Guide or Home: Xbox button", // MenuButtonHint
};
constexpr Column kPortugueseBR = {
@@ -540,6 +547,13 @@ constexpr Column kPortugueseBR = {
"Sempre", // GyroAlways
"Ao mirar (L2)", // GyroAiming
"Intensidade do giroscópio", // GyroIntensity
+ "As conexões seguras foram recusadas porque a data e a hora deste computador parecem erradas (ele diz %s). Acerte nas configurações do sistema e tente de novo.", // ClockWrongPc
+ "A data e a hora deste computador parecem erradas (%s): parte do conteúdo não carrega. Acerte nas configurações do sistema.", // ClockWrongNoticePc
+ "Desativado (o do computador)", // LoginCountryOffPc
+ "Abrir no navegador", // OpenInBrowser
+ "%s disponível: baixar", // UpdateReadyPc
+ "Menu: START + BACK ou F12 · Botão Xbox: Guide ou Home", // GestureHintButtons
+ "START + BACK ou F12: este menu · Guide ou Home: botão Xbox", // MenuButtonHint
};
constexpr Column kSpanish = {
@@ -795,6 +809,13 @@ constexpr Column kSpanish = {
"Siempre", // GyroAlways
"Al apuntar (L2)", // GyroAiming
"Intensidad del giroscopio", // GyroIntensity
+ "Se rechazaron las conexiones seguras porque la fecha y la hora de este ordenador parecen incorrectas (indica %s). Corrígelas en los ajustes del sistema y vuelve a intentarlo.", // ClockWrongPc
+ "La fecha y la hora de este ordenador parecen incorrectas (%s): parte del contenido no carga. Corrígelas en los ajustes del sistema.", // ClockWrongNoticePc
+ "Desactivado (el del ordenador)", // LoginCountryOffPc
+ "Abrir en el navegador", // OpenInBrowser
+ "%s disponible: descargar", // UpdateReadyPc
+ "Menú: START + BACK o F12 · Botón Xbox: Guide o Inicio", // GestureHintButtons
+ "START + BACK o F12: este menú · Guide o Inicio: botón Xbox", // MenuButtonHint
};
constexpr Column kFrench = {
@@ -1050,6 +1071,13 @@ constexpr Column kFrench = {
"Toujours", // GyroAlways
"En visant (L2)", // GyroAiming
"Intensité du gyroscope", // GyroIntensity
+ "Les connexions sécurisées ont été refusées car la date et l'heure de cet ordinateur semblent fausses (il indique %s). Corrigez-les dans les paramètres du système, puis réessayez.", // ClockWrongPc
+ "La date et l'heure de cet ordinateur semblent fausses (%s) : une partie du contenu ne se charge pas. Corrigez-les dans les paramètres du système.", // ClockWrongNoticePc
+ "Désactivé (celui de l'ordinateur)", // LoginCountryOffPc
+ "Ouvrir dans le navigateur", // OpenInBrowser
+ "%s disponible : télécharger", // UpdateReadyPc
+ "Menu : START + BACK ou F12 · Bouton Xbox : Guide ou Origine", // GestureHintButtons
+ "START + BACK ou F12 : ce menu · Guide ou Origine : bouton Xbox", // MenuButtonHint
};
constexpr Column kGerman = {
@@ -1305,6 +1333,13 @@ constexpr Column kGerman = {
"Immer", // GyroAlways
"Beim Zielen (L2)", // GyroAiming
"Gyro-Stärke", // GyroIntensity
+ "Sichere Verbindungen wurden abgelehnt, weil Datum und Uhrzeit dieses Computers falsch zu sein scheinen (er zeigt %s). Korrigiere sie in den Systemeinstellungen und versuche es erneut.", // ClockWrongPc
+ "Datum und Uhrzeit dieses Computers scheinen falsch zu sein (%s): Einige Inhalte laden nicht. Korrigiere sie in den Systemeinstellungen.", // ClockWrongNoticePc
+ "Aus (das des Computers)", // LoginCountryOffPc
+ "Im Browser öffnen", // OpenInBrowser
+ "%s verfügbar: herunterladen", // UpdateReadyPc
+ "Menü: START + BACK oder F12 · Xbox-Taste: Guide oder Pos1", // GestureHintButtons
+ "START + BACK oder F12: dieses Menü · Guide oder Pos1: Xbox-Taste", // MenuButtonHint
};
constexpr Column kItalian = {
@@ -1560,6 +1595,13 @@ constexpr Column kItalian = {
"Sempre", // GyroAlways
"Mirando (L2)", // GyroAiming
"Intensità giroscopio", // GyroIntensity
+ "Le connessioni sicure sono state rifiutate perché la data e l'ora di questo computer sembrano errate (indica %s). Correggile nelle impostazioni di sistema, poi riprova.", // ClockWrongPc
+ "La data e l'ora di questo computer sembrano errate (%s): alcuni contenuti non si caricano. Correggile nelle impostazioni di sistema.", // ClockWrongNoticePc
+ "Disattivato (quello del computer)", // LoginCountryOffPc
+ "Apri nel browser", // OpenInBrowser
+ "%s disponibile: scarica", // UpdateReadyPc
+ "Menu: START + BACK o F12 · Pulsante Xbox: Guide o Home", // GestureHintButtons
+ "START + BACK o F12: questo menu · Guide o Home: pulsante Xbox", // MenuButtonHint
};
constexpr std::array<const Column*, kLangs> kTable = {&kEnglish, &kPortugueseBR, &kSpanish,
diff --git a/src/ui/strings.h b/src/ui/strings.h
index 273ff94..7f31caa 100644
--- a/src/ui/strings.h
+++ b/src/ui/strings.h
@@ -262,6 +262,13 @@ enum class Str {
GyroAlways, // ... on all the time
GyroAiming, // ... only while L2 is held
GyroIntensity, // in-game menu: how far a turn moves the aim
+ ClockWrongPc, // ClockWrong on a desktop: "this computer", no PS5 menu path; "%s" = its date
+ ClockWrongNoticePc, // ClockWrongNotice on a desktop; "%s" = the date
+ LoginCountryOffPc, // LoginCountryOff on a desktop: the computer's own country
+ OpenInBrowser, // hint (sign-in code, report QR code): Cross / Enter opens the page in the browser
+ UpdateReadyPc, // Settings > Updates on a desktop: "%s" = the new version; Cross opens its page
+ GestureHintButtons, // GestureHint for pads without a touchpad: the buttons and keys that do the same
+ MenuButtonHint, // MenuGestureHint for pads without a touchpad
Count
};
diff --git a/src/ui/toast_view.cpp b/src/ui/toast_view.cpp
new file mode 100644
index 0000000..8db4e37
--- /dev/null
+++ b/src/ui/toast_view.cpp
@@ -0,0 +1,77 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// Copyright (C) 2026 RafaelNGP
+// The in-app notices' look (ui/toast_view.h).
+#include "ui/toast_view.h"
+
+#include <algorithm>
+
+namespace xc::ui {
+
+namespace {
+
+constexpr int kPx = 24, kLineH = 34, kPadX = 28, kPadY = 16, kMaxTextW = 640, kGap = 12;
+constexpr Color kPanel = rgba(40, 40, 40, 240);
+constexpr Color kAccent = rgba(16, 124, 16); // the app's green, down the left edge
+constexpr Color kText = rgba(255, 255, 255);
+
+std::vector<std::string> lines(const Fonts& fonts, const std::string& text) {
+ return fonts.semibold.wrap(text, kPx, kMaxTextW, 3);
+}
+
+int widest(const Fonts& fonts, const std::vector<std::string>& ls) {
+ int w = 0;
+ for (const auto& l : ls) w = std::max(w, fonts.semibold.measure(l, kPx));
+ return w;
+}
+
+} // namespace
+
+void drawToasts(Canvas& c, const Fonts& fonts, const std::vector<std::string>& texts, int right, int top) {
+ int y = top;
+ for (const auto& text : texts) {
+ auto ls = lines(fonts, text);
+ if (ls.empty()) continue;
+ int w = widest(fonts, ls) + 2 * kPadX, h = static_cast<int>(ls.size()) * kLineH + 2 * kPadY;
+ Rect r{right - w, y, w, h};
+ c.fillRect({r.x + 4, r.y + 6, r.w, r.h}, rgba(0, 0, 0, 110), 18); // shadow
+ c.fillRect(r, kPanel, 18);
+ c.fillRect({r.x, r.y + 14, 5, r.h - 28}, kAccent, 2);
+ int ty = r.y + kPadY;
+ for (const auto& l : ls) {
+ fonts.semibold.draw(c, l, r.x + kPadX, ty, kPx, kText);
+ ty += kLineH;
+ }
+ y += h + kGap;
+ }
+}
+
+Canvas renderToastPanel(const Fonts& fonts, const std::vector<std::string>& texts) {
+ // One opaque panel (an overlay is a single rectangle): the notices one
+ // under the other, a thin line between them.
+ std::vector<std::vector<std::string>> all;
+ int w = 0, h = 2 * kPadY;
+ for (const auto& text : texts) {
+ auto ls = lines(fonts, text);
+ if (ls.empty()) continue;
+ w = std::max(w, widest(fonts, ls));
+ h += static_cast<int>(ls.size()) * kLineH + (all.empty() ? 0 : kGap);
+ all.push_back(std::move(ls));
+ }
+ Canvas c(std::max(1, w + 2 * kPadX), std::max(1, h));
+ c.clear(rgba(30, 30, 30));
+ c.fillRect({0, 0, 5, c.height()}, kAccent);
+ int y = kPadY;
+ for (size_t i = 0; i < all.size(); ++i) {
+ if (i) {
+ c.fillRect({kPadX, y + kGap / 2 - 1, c.width() - 2 * kPadX, 1}, rgba(255, 255, 255, 40));
+ y += kGap;
+ }
+ for (const auto& l : all[i]) {
+ fonts.semibold.draw(c, l, kPadX, y, kPx, kText);
+ y += kLineH;
+ }
+ }
+ return c;
+}
+
+} // namespace xc::ui
diff --git a/src/ui/toast_view.h b/src/ui/toast_view.h
new file mode 100644
index 0000000..47b330c
--- /dev/null
+++ b/src/ui/toast_view.h
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// Copyright (C) 2026 RafaelNGP
+// How the in-app notices (platform/toasts.h: platform::notify() in the
+// desktop app) are drawn: over the menus, and over a game as its overlay.
+#pragma once
+
+#include "ui/canvas.h"
+#include "ui/font.h"
+
+#include <string>
+#include <vector>
+
+namespace xc::ui {
+
+// A rounded panel per notice, stacked down from `top`, right-aligned to
+// `right`; nothing when `texts` is empty.
+void drawToasts(Canvas& c, const Fonts& fonts, const std::vector<std::string>& texts, int right, int top);
+// The notices in one panel of their own, for display::setOverlay() while a
+// game streams (`texts` not empty).
+Canvas renderToastPanel(const Fonts& fonts, const std::vector<std::string>& texts);
+
+} // namespace xc::ui