Skip to content

Xbox Cloud Gaming app for PS5 Homebrew

C

Sign in as another country when xCloud refuses the sign-in

Rafael Abud Ferreira84158455cb7f
diff --git a/ROADMAP.md b/ROADMAP.md
index b1f9647..7e1ac92 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -4,7 +4,7 @@ Where PSBox Cloud Gaming goes next, most valuable first. Each item says why it
matters, what "done" looks like, and how it is measured on the console.
Status: **next** (being worked on), **planned**, **later**, **dropped**.
-Last update: 2026-10-13, after v0.9.5.
+Last update: 2026-10-14, after v0.9.5.
## Now
@@ -178,7 +178,7 @@ is rolled back at the next start), then the app restarts itself
| **next** Built-in certificates as a fallback | When `assets/cacert.pem` is missing or unreadable (an incomplete copy: #20, #38), secure connections fail and nothing works; a copy inside `eboot.bin` is used then, and the log says so (the install stays visibly broken in reports) | small |
| **next** "Report a problem" with a QR code | On error screens, in Settings and in the game menu: a QR code opens the GitHub bug form on the phone, filled in (version, firmware, the error, the log's error/warning lines and last lines, ~3 KB, filtered once more for private data). No token in the app; works with the PS5 offline | medium |
| **next** Unexpected-close detection | The next start notices the last session didn't end normally and offers a report with the end of that session's log (what it was doing, not why it closed) | small |
-| Region bypass (unsupported countries), opt-in | Offered only where it is needed: when the xCloud login is refused for the region, the error says so and offers "Try through another region (experimental)": a warning (against Microsoft's terms, may stop working, account risk, more latency), a country, Confirm; then the login is retried with `X-Forwarded-For` (as Better xCloud), on that request only. Off by default; changed or turned off later in Settings > Server region. First: learn the refusal's exact answer (a test with a secondary account). Also: Options on the error screen opens Settings | small |
+| **next** Region bypass (unsupported countries), opt-in | Built, to be checked on the console. Offered only where it is needed: when the xCloud login is refused (any 4xx answer, as Better xCloud), the error says the country may not be offered (or no Game Pass Ultimate: the service doesn't say which) and offers "Sign in as another country" (Square): a warning (Microsoft doesn't allow it, at your own risk, more delay), Off or one of Brazil, Japan, South Korea, Poland, United States, Cross. The login is then retried with `X-Forwarded-For` (Better xCloud's addresses), on that request only; the address is never logged. Refused again as a country: the error says it is probably the subscription. Off by default; changed later in Settings > Sign-in country (Options on that error opens it). Still to do: learn the refusal's exact answer with a secondary account | small |
| USB keyboard & mouse + badges (v1.0+) | Some xCloud games accept native keyboard and mouse input; deferred to v1.0+ | medium |
| Dedicated voice chat output routing | Route voice chat audio independently to DualSense controller speaker or headset while keeping game audio on TV (if xCloud exposes separate voice track) | medium |
diff --git a/src/app/autoplay.cpp b/src/app/autoplay.cpp
index f9a36f7..41ef940 100644
--- a/src/app/autoplay.cpp
+++ b/src/app/autoplay.cpp
@@ -11,6 +11,7 @@
#include "platform/platform.h"
#include "ui/canvas.h"
#include "ui/stream_menu.h"
+#include "ui/strings.h"
#include "util/log.h"
#include <cmath>
@@ -34,6 +35,7 @@ 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 screenshot
const char* gameSettingsShot = nullptr; // "gamesettingstest": save screenshot
+const char* regionShot = nullptr; // "regiontest": save this screen next
bool acceptUpdate = false; // "updatetest": Cross on the pop-up, next pass ("updateskip": Circle)
} // namespace
@@ -97,6 +99,7 @@ void loadAutoplay() {
if (opt == "publishertest") g_autoplay.publisherTest = true;
if (opt == "friendstest") g_autoplay.friendsTest = true;
if (opt == "streammenutest") g_autoplay.streamMenuTest = true;
+ if (opt == "regiontest") g_autoplay.regionTest = true;
if (opt == "norestart") g_autoplay.noRestart = true;
if (opt.rfind("threads=", 0) == 0) g_autoplay.decodeThreads = std::atoi(opt.c_str() + 8);
}
@@ -347,6 +350,35 @@ void autoplayPad(input::ControllerState& pad) {
}
void autoplayNav(ui::NavInput& nav, bool& menuCombo, uint64_t now) {
+ if (g_autoplay.regionTest && uiSaved) {
+ // The refused sign-in's screens, as the user goes through them; Circle
+ // leaves each, so the sign-in country stays as it was.
+ static uint64_t since = 0;
+ static int step = 0;
+ if (!since) since = now;
+ static const unsigned kAt[] = {500, 1500, 2000, 2400, 3200, 3700, 4200, 5000, 5500, 6500};
+ if (step < 10 && now - since >= kAt[step]) {
+ nav = ui::NavInput{};
+ switch (step) {
+ case 0: g_ui->showRegionRefused(ui::tr(ui::Str::RegionRefused)); break;
+ case 1: regionShot = "region.ppm"; break;
+ case 2: nav.square = true; break;
+ case 3: nav.down = true; break;
+ case 4: regionShot = "region_picker.ppm"; break;
+ case 5: nav.back = true; break;
+ case 6: nav.options = true; break;
+ case 7: regionShot = "region_settings.ppm"; break;
+ case 8: nav.back = true; break;
+ case 9:
+ regionShot = "region_back.ppm";
+ g_autoplay.regionTest = false;
+ XC_LOGI("AUTOPLAY END: region test, back on the %s screen",
+ g_ui->screen() == ui::Screen::Error ? "error" : "WRONG");
+ break;
+ }
+ ++step;
+ }
+ }
if (g_autoplay.settingsUpdate && uiSaved && !g_ui->updateOffered()) {
// Settings, down to Updates (the last row), Cross.
static uint64_t since = 0;
@@ -570,6 +602,10 @@ void autoplayScreens(const ui::Canvas& canvas, uint64_t now) {
saveCanvas(gridShot);
gridShot = nullptr;
}
+ if (regionShot) {
+ saveCanvas(regionShot);
+ regionShot = nullptr;
+ }
if (gameSettingsShot) {
saveCanvas(gameSettingsShot);
gameSettingsShot = nullptr;
diff --git a/src/app/autoplay.h b/src/app/autoplay.h
index 9fd8224..2bd2b6e 100644
--- a/src/app/autoplay.h
+++ b/src/app/autoplay.h
@@ -77,6 +77,9 @@ struct Autoplay {
bool publisherTest = false; // publishertest: test publisher filter dropdown and search results
bool friendsTest = false; // friendstest: test friends playing row and card badge
bool streamMenuTest = false; // streammenutest: render StreamMenu with mic and audio route options
+ bool regionTest = false; // regiontest: the refused sign-in (region.ppm), its country list (region_picker.ppm,
+ // closed unchanged), Settings on the sign-in country (region_settings.ppm), back
+ // (region_back.ppm). The sign-in country is never changed.
};
extern Autoplay g_autoplay;
extern std::atomic<bool> g_syntheticA; // A held down for the game
diff --git a/src/app/cli_main.cpp b/src/app/cli_main.cpp
index 755c0c0..09afde7 100644
--- a/src/app/cli_main.cpp
+++ b/src/app/cli_main.cpp
@@ -638,6 +638,62 @@ int main(int argc, char** argv) {
app.showReport(url, ui::tr(ui::Str::CrashedLastTime));
save("report_crash");
return 0;
+ } else if (cmd == "ui-region" && argi < argc) {
+ // Offline: the refused sign-in, its country list, Settings on the
+ // sign-in country, and the events each answer gives.
+ ui::Fonts fonts;
+ if (!fonts.load("assets/fonts")) return 1;
+ ui::ImageCache images([] {});
+ ui::AppUi app(fonts, images);
+ ui::Canvas canvas(1920, 1080);
+ if (argi + 1 < argc) ui::setLanguage(ui::languageFromCode(argv[argi + 1]));
+ auto save = [&](const std::string& name) {
+ app.render(canvas, 1000);
+ std::string path = std::string(argv[argi]) + "/" + name + ".png";
+ stbi_write_png(path.c_str(), canvas.width(), canvas.height(), 4, canvas.data(), canvas.width() * 4);
+ std::printf("wrote %s\n", path.c_str());
+ };
+ auto press = [&](auto set) {
+ ui::NavInput n;
+ set(n);
+ return app.handle(n);
+ };
+ int failures = 0;
+ auto check = [&](bool ok, const char* what) {
+ std::printf("%s: %s\n", ok ? "ok" : "FAILED", what);
+ failures += !ok;
+ };
+ app.showRegionRefused(ui::tr(ui::Str::RegionRefused));
+ save("region_error");
+ press([](ui::NavInput& n) { n.square = true; });
+ press([](ui::NavInput& n) { n.down = true; });
+ save("region_picker");
+ auto ev = press([](ui::NavInput& n) { n.accept = true; });
+ check(ev.action == ui::Action::LoginCountry && ev.settings.loginCountry == "br", "Cross on Brazil: sign in as br");
+ app.showRegionRefused(ui::trf(ui::Str::RegionRefusedAs, ui::loginCountryName("br")));
+ save("region_error_as");
+ press([](ui::NavInput& n) { n.square = true; });
+ ev = press([](ui::NavInput& n) { n.back = true; });
+ check(ev.action == ui::Action::None, "Circle on the list: nothing");
+ press([](ui::NavInput& n) { n.options = true; });
+ check(app.screen() == ui::Screen::Settings, "Options: Settings");
+ save("region_settings");
+ press([](ui::NavInput& n) { n.accept = true; });
+ save("region_settings_list");
+ press([](ui::NavInput& n) { n.up = true; });
+ press([](ui::NavInput& n) { n.accept = true; }); // "Off"
+ ev = press([](ui::NavInput& n) { n.back = true; });
+ check(ev.action == ui::Action::LoginCountry && ev.settings.loginCountry.empty(), "Settings, Off, Circle: sign in again");
+ check(app.screen() == ui::Screen::Error, "back on the error");
+ press([](ui::NavInput& n) { n.options = true; });
+ ev = press([](ui::NavInput& n) { n.back = true; });
+ check(ev.action == ui::Action::SettingsChanged, "Settings unchanged: no new sign-in");
+ app.showError("Sign-in failed: no connection");
+ press([](ui::NavInput& n) { n.square = true; });
+ press([](ui::NavInput& n) { n.options = true; });
+ check(app.screen() == ui::Screen::Error, "other errors: no list, no Settings");
+ save("region_plain_error");
+ return failures ? 1 : 0;
} else if (cmd == "ui-settings" && argi < argc) {
// Offline: Settings with the region list open, then the language list.
ui::Fonts fonts;
diff --git a/src/app/ps5_main.cpp b/src/app/ps5_main.cpp
index 5d10fbc..2093ebd 100644
--- a/src/app/ps5_main.cpp
+++ b/src/app/ps5_main.cpp
@@ -104,6 +104,7 @@ bool saveSettings(const ui::SettingsChoice& choice) {
g_settings.language = code;
g_settings.resolution = choice.resolution == 1 ? "720p" : choice.resolution == 2 ? "best" : "1080p";
g_settings.region = choice.region;
+ g_settings.loginCountry = choice.loginCountry;
g_settings.deadzoneLeft = choice.deadzone[0];
g_settings.deadzoneRight = choice.deadzone[1];
g_settings.triggerStrength = choice.triggerStrength;
@@ -198,6 +199,7 @@ int main(int argc, char** argv) {
choice.language = static_cast<int>(ui::language());
choice.resolution = g_settings.resolution == "720p" ? 1 : (g_settings.resolution == "1440p" || g_settings.resolution == "best") ? 2 : 0;
choice.region = g_settings.region;
+ choice.loginCountry = g_settings.loginCountry;
choice.deadzone[0] = std::clamp(g_settings.deadzoneLeft, 0, ui::kMaxDeadzone);
choice.deadzone[1] = std::clamp(g_settings.deadzoneRight, 0, ui::kMaxDeadzone);
choice.triggerStrength = g_settings.triggerStrength;
@@ -473,6 +475,12 @@ int main(int argc, char** argv) {
break;
}
case ui::Action::UpdateLater: skipOfferedUpdate(); break;
+ case ui::Action::LoginCountry:
+ // A new sign-in, as the country chosen (or the console's own).
+ saveSettings(ev.settings);
+ XC_LOGI("sign-in country: %s", ev.settings.loginCountry.empty() ? "off" : ev.settings.loginCountry.c_str());
+ g_command = kSignIn;
+ break;
case ui::Action::Report: openReport(ev.reportWhat, false, ui::tr(ui::Str::ReportProblem)); break;
case ui::Action::None: break;
}
diff --git a/src/app/settings.cpp b/src/app/settings.cpp
index 67a9177..0143199 100644
--- a/src/app/settings.cpp
+++ b/src/app/settings.cpp
@@ -20,6 +20,7 @@ bool Settings::load(const std::string& path) {
language = (*j)["language"].str(language);
resolution = (*j)["resolution"].str(resolution);
region = (*j)["region"].str(region);
+ loginCountry = (*j)["loginCountry"].str(loginCountry);
if (resolution != "720p" && resolution != "1440p" && resolution != "best") resolution = "1080p";
hidden.clear();
for (const auto& id : (*j)["hidden"].items())
@@ -127,6 +128,7 @@ bool Settings::save(const std::string& path) const {
v.set("language", language);
v.set("resolution", resolution);
v.set("region", region);
+ v.set("loginCountry", loginCountry);
json::Value rtt = json::Value::object();
for (const auto& [name, ms] : regionRtt) rtt.set(name, ms);
v.set("regionRtt", rtt);
diff --git a/src/app/settings.h b/src/app/settings.h
index a491adc..760e2ee 100644
--- a/src/app/settings.h
+++ b/src/app/settings.h
@@ -34,6 +34,8 @@ struct Settings {
std::string language = "en"; // ui::languageCode()
std::string resolution = "1080p"; // "1080p", "720p" or "1440p" (experimental)
std::string region; // gssv region name; empty = automatic
+ // "Sign in as another country" (xcloud::loginCountryAddress): "" off.
+ std::string loginCountry;
// Round trip to the stream server measured in past sessions, per region (ms).
std::map<std::string, int> regionRtt;
// Games hidden with Square (product ids), and the "Your games" order
diff --git a/src/app/worker.cpp b/src/app/worker.cpp
index 50cd174..9e11074 100644
--- a/src/app/worker.cpp
+++ b/src/app/worker.cpp
@@ -461,9 +461,23 @@ void signInAndLoad(auth::AuthManager& am, xcloud::GssvClient& gssv) {
g_ui->showSplash(ui::tr(am.hasStoredAccount() ? ui::Str::SigningIn : ui::Str::RequestingCode));
std::string err;
auto onCode = [](const auth::DeviceCode& dc) { g_ui->showSignIn(dc.userCode, dc.verificationUri); };
+ std::string country;
+ {
+ std::lock_guard<std::mutex> lock(g_settingsMutex);
+ country = g_settings.loginCountry;
+ }
+ gssv.setLoginCountry(country);
if (!am.signIn(gssv, onCode, err, &g_cancel)) {
XC_LOGE("sign-in failed: %s", err.c_str());
- g_ui->showError(ui::trf(ui::Str::SignInFailed, err));
+ if (gssv.loginRefused()) {
+ // xCloud said no: maybe not offered in this country. Offers to
+ // sign in as another (or, already as one, says it's likely the
+ // subscription).
+ g_ui->showRegionRefused(country.empty() ? ui::tr(ui::Str::RegionRefused)
+ : ui::trf(ui::Str::RegionRefusedAs, ui::loginCountryName(country)));
+ } else {
+ g_ui->showError(ui::trf(ui::Str::SignInFailed, err));
+ }
if (!g_autoplay.title.empty()) XC_LOGI("AUTOPLAY END: sign-in failed");
return;
}
@@ -565,7 +579,8 @@ void loadLibrary(xcloud::GssvClient& gssv) {
!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.crashTest && !g_autoplay.scrollTest &&
- !g_autoplay.gridTest && !g_autoplay.gameSettingsTest && !g_autoplay.publisherTest && !g_autoplay.friendsTest) {
+ !g_autoplay.gridTest && !g_autoplay.gameSettingsTest && !g_autoplay.publisherTest && !g_autoplay.friendsTest &&
+ !g_autoplay.regionTest) {
platform::sleepMs(6000); // leave the home screen up for ui.ppm
ui::GameTile tile;
tile.titleId = g_autoplay.title;
diff --git a/src/ui/app_ui.cpp b/src/ui/app_ui.cpp
index 369fad3..e649122 100644
--- a/src/ui/app_ui.cpp
+++ b/src/ui/app_ui.cpp
@@ -190,6 +190,14 @@ constexpr uint64_t kSignOutHoldMs = 5000;
} // namespace
+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}};
+ for (const auto& [code, name] : kNames)
+ if (country == code) return tr(name);
+ return {};
+}
+
std::string prettyRegion(const std::string& name) {
// Longer words first where one starts another (SOUTHEAST before SOUTH).
static const char* kWords[] = {"SOUTHEAST", "NORTHEAST", "SWITZERLAND", "CENTRAL", "AUSTRALIA", "GERMANY",
@@ -836,6 +844,17 @@ void AppUi::showError(const std::string& message) {
screen_ = Screen::Error;
error_ = message;
errorGame_ = {};
+ regionRefused_ = countryPickerOpen_ = false;
+ dirty_ = true;
+}
+
+void AppUi::showRegionRefused(const std::string& message) {
+ std::lock_guard<std::mutex> lock(mutex_);
+ screen_ = Screen::Error;
+ error_ = message;
+ errorGame_ = {};
+ regionRefused_ = true;
+ countryPickerOpen_ = false;
dirty_ = true;
}
@@ -844,6 +863,7 @@ void AppUi::showPlayError(const std::string& message, const GameTile& game) {
screen_ = Screen::Error;
error_ = message;
errorGame_ = game;
+ regionRefused_ = countryPickerOpen_ = false;
dirty_ = true;
}
@@ -1177,6 +1197,9 @@ std::vector<std::string> AppUi::settingOptions(int row) const {
out = {tr(Str::LightBarGame), tr(Str::LightBarCustom), tr(Str::Deactivated)};
} else if (row == 7) {
// Updates: Cross acts, no list.
+ } else if (row == 8) {
+ out.push_back(tr(Str::LoginCountryOff));
+ for (const char* country : kLoginCountries) out.push_back(loginCountryName(country));
} else {
// Automatic first, then the regions in the login's order.
out.push_back(withMs(trf(Str::RegionAuto, defaultRegion_.empty() ? "-" : prettyRegion(defaultRegion_)),
@@ -1198,6 +1221,11 @@ int AppUi::settingSelected(int row) const {
if (row == 5) return settings_.circleConfirms ? 1 : 0;
if (row == 6) return settings_.lightBarMode;
if (row == 7) return 0;
+ if (row == 8) {
+ for (size_t i = 0; i < std::size(kLoginCountries); ++i)
+ if (settings_.loginCountry == kLoginCountries[i]) return static_cast<int>(i) + 1;
+ return 0;
+ }
for (size_t i = 0; i < regions_.size(); ++i)
if (regions_[i] == settings_.region) return static_cast<int>(i) + 1;
return 0;
@@ -1220,6 +1248,8 @@ void AppUi::applySetting(int row, int index) {
} else if (row == 6) {
settings_.lightBarMode = index;
} else if (row == 7) {
+ } else if (row == 8) {
+ settings_.loginCountry = index == 0 ? std::string() : kLoginCountries[index - 1];
} else {
settings_.region = index == 0 ? std::string() : regions_[static_cast<size_t>(index - 1)];
}
@@ -1354,6 +1384,8 @@ void AppUi::handleHome(const NavInput& in, UiEvent& ev) {
if (in.options) {
screen_ = Screen::Settings;
settingsRow_ = 0;
+ settingsFromError_ = false;
+ settingsCountry_ = settings_.loginCountry;
dropdownOpen_ = false;
filterList_ = -1;
dirty_ = true;
@@ -1901,6 +1933,20 @@ UiEvent AppUi::handle(const NavInput& in) {
}
return ev;
}
+ if (countryPickerOpen_) {
+ // "Sign in as another country": up / down, Cross signs in as the
+ // one chosen, Circle closes it unchanged.
+ int n = 1 + static_cast<int>(std::size(kLoginCountries));
+ if (in.down && countryIndex_ + 1 < n) ++countryIndex_, dirty_ = true;
+ if (in.up && countryIndex_ > 0) --countryIndex_, dirty_ = true;
+ if (in.accept) {
+ settings_.loginCountry = countryIndex_ ? kLoginCountries[countryIndex_ - 1] : "";
+ ev.action = Action::LoginCountry;
+ ev.settings = settings_;
+ }
+ if (in.accept || in.back) countryPickerOpen_ = false, dirty_ = true;
+ return ev;
+ }
switch (screen_) {
case Screen::Home: handleHome(in, ev); break;
case Screen::Settings:
@@ -1944,9 +1990,11 @@ UiEvent AppUi::handle(const NavInput& in) {
dirty_ = true;
}
if (in.back || in.options) {
- screen_ = Screen::Home;
+ // Back where Settings was opened. A new sign-in country
+ // takes a new sign-in.
+ screen_ = settingsFromError_ ? Screen::Error : Screen::Home;
dirty_ = true;
- ev.action = Action::SettingsChanged;
+ ev.action = settings_.loginCountry != settingsCountry_ ? Action::LoginCountry : Action::SettingsChanged;
ev.settings = settings_;
} else if (in.triangle) {
ev.action = Action::Report; // "Report a problem"
@@ -1992,6 +2040,18 @@ UiEvent AppUi::handle(const NavInput& in) {
} else if (in.accept) {
ev.action = Action::Retry;
}
+ if (regionRefused_ && in.square) {
+ countryPickerOpen_ = true;
+ countryIndex_ = settingSelected(8);
+ dirty_ = true;
+ } else if (regionRefused_ && in.options) { // Settings, on the sign-in country
+ screen_ = Screen::Settings;
+ settingsRow_ = 8;
+ settingsFromError_ = true;
+ settingsCountry_ = settings_.loginCountry;
+ dropdownOpen_ = false;
+ dirty_ = true;
+ }
if (in.triangle) { // "Report a problem", with the error shown
ev.action = Action::Report;
ev.reportWhat = error_;
@@ -3007,6 +3067,10 @@ void AppUi::drawError(Canvas& c) {
}
if (!errorGame_.titleId.empty())
drawHints(c, {{kIconCross, tr(Str::TryAgain)}, {kIconTriangle, tr(Str::ReportProblem)}, {kIconCircle, tr(Str::Back)}});
+ else if (regionRefused_)
+ drawHints(c, {{kIconCross, tr(Str::TryAgain)}, {kIconSquare, tr(Str::TryOtherCountry)},
+ {kIconOptions, tr(Str::Settings)}, {kIconTriangle, tr(Str::ReportProblem)},
+ {kIconTouchpad, tr(Str::HoldSignOut)}});
else
drawHints(c, {{kIconCross, tr(Str::TryAgain)}, {kIconTriangle, tr(Str::ReportProblem)},
{kIconTouchpad, tr(Str::HoldSignOut)}});
@@ -3018,8 +3082,8 @@ void AppUi::drawSettings(Canvas& c) {
fonts_.bold.draw(c, tr(Str::Settings), kMargin, 170, 60, kWhite);
const char* labels[kSettingRows] = {tr(Str::Language), tr(Str::Resolution), tr(Str::Region),
tr(Str::Deadzone), tr(Str::TriggerRumble), tr(Str::ConfirmButton),
- tr(Str::LightBar), tr(Str::Updates)};
- constexpr int kRowW = 1200, kRowH = 66;
+ tr(Str::LightBar), tr(Str::Updates), tr(Str::LoginCountry)};
+ constexpr int kRowW = 1200, kRowH = 60;
Rect rows[kSettingRows];
int y = 262;
for (int i = 0; i < kSettingRows; ++i) {
@@ -3087,7 +3151,7 @@ void AppUi::drawSettings(Canvas& c) {
Rect panel{row.x + row.w - kListW, row.y + row.h + 8, kListW, visible * kItemH + 16};
if (panel.y + panel.h > kH - 100) panel.y = std::max(120, kH - 100 - panel.h);
c.fillRect({panel.x + 6, panel.y + 10, panel.w, panel.h}, rgba(0, 0, 0, 120), 18); // shadow
- c.fillRect(panel, rgba(38, 38, 38, 250), 18);
+ c.fillRect(panel, rgba(38, 38, 38), 18);
c.strokeRect(panel, rgba(255, 255, 255, 50), 2, 18);
for (int k = 0; k < visible; ++k) {
int i = dropdownTop_ + k;
@@ -3153,6 +3217,34 @@ void AppUi::drawReport(Canvas& c) {
drawHints(c, {{kIconCircle, tr(Str::Back)}});
}
+void AppUi::drawCountryPicker(Canvas& c) {
+ // Over the refused sign-in: the warning, then the countries.
+ constexpr int kPanelW = 1100, kItemH = 58;
+ auto warning = fonts_.regular.wrap(tr(Str::LoginCountryWarning), 26, kPanelW - 112, 6);
+ int n = 1 + static_cast<int>(std::size(kLoginCountries));
+ int listY = 124 + static_cast<int>(warning.size()) * 36 + 24;
+ Rect panel = drawModal(c, kPanelW, listY + n * kItemH + 40, tr(Str::TryOtherCountry));
+ int y = panel.y + 124;
+ for (const auto& line : warning) {
+ fonts_.regular.draw(c, line, panel.x + 56, y, 26, kGray);
+ y += 36;
+ }
+ int sel = settingSelected(8);
+ for (int i = 0; i < n; ++i) {
+ 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);
+ 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
+ float cx = static_cast<float>(item.x + item.w - 36), cy = static_cast<float>(item.y + item.h / 2);
+ c.line(cx - 10, cy, cx - 3, cy + 7, 3, on ? kBg : kGreen);
+ c.line(cx - 3, cy + 7, cx + 10, cy - 7, 3, on ? kBg : kGreen);
+ }
+ }
+}
+
void AppUi::drawUpdatePrompt(Canvas& c) {
c.fillRect({0, 0, kW, kH}, rgba(0, 0, 0, 160));
constexpr int kPanelW = 960, kPanelH = 340, kButtonW = 360, kButtonH = 72;
@@ -3524,6 +3616,7 @@ void AppUi::render(Canvas& c, uint64_t nowMs) {
case Screen::Streaming: break;
}
if (screen_ == Screen::Home && updatePrompt_) drawUpdatePrompt(c);
+ if (screen_ == Screen::Error && countryPickerOpen_) drawCountryPicker(c);
if (reportOpen_) drawReport(c);
if ((screen_ == Screen::Home && !updatePrompt_) || screen_ == Screen::Error) drawSignOutHold(c, nowMs);
if (!toast_.empty()) animating_ = true; // to expire it
diff --git a/src/ui/app_ui.h b/src/ui/app_ui.h
index caa7ddf..9efabce 100644
--- a/src/ui/app_ui.h
+++ b/src/ui/app_ui.h
@@ -101,6 +101,7 @@ struct SettingsChoice {
int language = 0; // ui::Language
int resolution = 0; // 0 = 1080p, 1 = 720p, 2 = 1440p (experimental)
std::string region; // gssv region name; empty = automatic
+ std::string loginCountry; // "Sign in as another country" (kLoginCountries); empty = off
int deadzone[2] = {15, 15}; // left, right stick: percent of the travel, 0..kMaxDeadzone
int triggerStrength = 2; // 0 off .. 4 max (input/tuning.h)
int triggerHz = 1; // index into input::kTriggerHz
@@ -116,7 +117,13 @@ struct SettingsChoice {
// The largest stick dead zone Settings offers, in percent of the travel.
constexpr int kMaxDeadzone = 30;
-constexpr int kSettingRows = 8; // language, resolution, region, dead zone, triggers, confirm, light bar, updates
+constexpr int kSettingRows = 9; // language, resolution, region, dead zone, triggers, confirm, light bar, updates,
+ // sign-in country
+
+// The countries "Sign in as another country" offers (xcloud::loginCountryAddress).
+constexpr const char* kLoginCountries[] = {"br", "jp", "kr", "pl", "us"};
+// "br" -> "Brazil", in the UI's language ("" for an unknown code).
+std::string loginCountryName(const std::string& country);
// ConsolesShown: "My consoles" opened (its list is refreshed). UpdateNow
// (with the settings, saved first when it came from Settings) / UpdateLater:
@@ -124,7 +131,8 @@ constexpr int kSettingRows = 8; // language, resolution, region, dead zone, tri
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
+ 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
};
// How "Your games" is sorted (R3).
@@ -212,6 +220,9 @@ public:
// A game that could not start but may on another try (a free game got
// on the phone meanwhile): Cross plays it again, Circle opens its page.
void showPlayError(const std::string& message, const GameTile& game);
+ // The sign-in refused by xCloud: an error that also offers to sign in as
+ // another country (Square), and Settings (Options).
+ void showRegionRefused(const std::string& message);
void setSettings(const SettingsChoice& choice);
// Per-game settings
void setPerGameSettings(const std::map<std::string, app::GameProfile>& perGame);
@@ -344,6 +355,7 @@ private:
void drawSettings(Canvas& c);
void drawUpdatePrompt(Canvas& c);
void drawReport(Canvas& c);
+ void drawCountryPicker(Canvas& c);
// The light bar's colour picker (Settings > Light bar > Custom colour).
void openColourPicker(int previousMode);
void handleColourPicker(const NavInput& in);
@@ -435,6 +447,11 @@ private:
std::string updateCurrent_, updateAvailable_;
bool updateChecking_ = false;
bool reportOpen_ = false; // the report's QR code is up
+ bool regionRefused_ = false; // the error is showRegionRefused()'s
+ bool countryPickerOpen_ = false;
+ int countryIndex_ = 0; // 0 off, then kLoginCountries
+ bool settingsFromError_ = false; // Circle goes back to the error
+ std::string settingsCountry_; // the sign-in country when Settings opened
std::string reportUrl_, reportHeading_;
bool updatePrompt_ = false; // the pop-up is up (on the home screen)
int promptFocus_ = 0; // 0 Update now, 1 Not now
diff --git a/src/ui/strings.cpp b/src/ui/strings.cpp
index fca31a4..bdb042d 100644
--- a/src/ui/strings.cpp
+++ b/src/ui/strings.cpp
@@ -245,6 +245,17 @@ constexpr Column kEnglish = {
"Scan it with your phone: GitHub's bug form opens, filled in. You review it before sending it.", // ReportScan
"It includes the app's version, the error and lines of its log, without personal data.", // ReportIncludes
"PSBox closed unexpectedly last time", // CrashedLastTime
+ "Sign-in country", // LoginCountry
+ "Off (this console's)", // LoginCountryOff
+ "Sign in as another country", // TryOtherCountry
+ "xCloud will be told the sign-in comes from the chosen country. Microsoft doesn't allow this: use it at your own risk. Games may then come from servers far away, with more delay. You can change it later in Settings.", // LoginCountryWarning
+ "xCloud refused the sign-in. Cloud gaming may not be offered in your country, or the account may not have Game Pass Ultimate.", // RegionRefused
+ "xCloud refused the sign-in, even as %s. The account probably doesn't have Game Pass Ultimate.", // RegionRefusedAs
+ "Brazil", // CountryBR
+ "Japan", // CountryJP
+ "South Korea", // CountryKR
+ "Poland", // CountryPL
+ "United States", // CountryUS
};
constexpr Column kPortugueseBR = {
@@ -460,6 +471,17 @@ constexpr Column kPortugueseBR = {
"Escaneie com o celular: o formulário de bug do GitHub abre preenchido. Você revisa antes de enviar.",
"Inclui a versão do app, o erro e linhas do log, sem dados pessoais.",
"O PSBox fechou inesperadamente da última vez",
+ "País do login",
+ "Desativado (o do console)",
+ "Entrar como outro país",
+ "O xCloud será informado de que o login vem do país escolhido. A Microsoft não permite isso: use por sua conta e risco. Os jogos podem vir de servidores distantes, com mais atraso. Dá para mudar depois em Configurações.",
+ "O xCloud recusou o login. O jogo na nuvem pode não ser oferecido no seu país, ou a conta pode não ter o Game Pass Ultimate.",
+ "O xCloud recusou o login, mesmo como %s. Provavelmente a conta não tem o Game Pass Ultimate.",
+ "Brasil",
+ "Japão",
+ "Coreia do Sul",
+ "Polônia",
+ "Estados Unidos",
};
constexpr Column kSpanish = {
@@ -675,6 +697,17 @@ constexpr Column kSpanish = {
"Escanéalo con el móvil: se abre el formulario de errores de GitHub, ya rellenado. Lo revisas antes de enviarlo.",
"Incluye la versión de la app, el error y líneas del registro, sin datos personales.",
"PSBox se cerró inesperadamente la última vez",
+ "País de inicio de sesión",
+ "Desactivado (el de la consola)",
+ "Entrar como otro país",
+ "Se le dirá a xCloud que el inicio de sesión viene del país elegido. Microsoft no lo permite: úsalo bajo tu propio riesgo. Los juegos pueden venir de servidores lejanos, con más retraso. Puedes cambiarlo luego en Ajustes.",
+ "xCloud rechazó el inicio de sesión. Puede que el juego en la nube no se ofrezca en tu país o que la cuenta no tenga Game Pass Ultimate.",
+ "xCloud rechazó el inicio de sesión, incluso como %s. Probablemente la cuenta no tenga Game Pass Ultimate.",
+ "Brasil",
+ "Japón",
+ "Corea del Sur",
+ "Polonia",
+ "Estados Unidos",
};
constexpr Column kFrench = {
@@ -890,6 +923,17 @@ constexpr Column kFrench = {
"Scannez-le avec votre téléphone : le formulaire de bug de GitHub s'ouvre, déjà rempli. Vous le relisez avant de l'envoyer.",
"Il contient la version de l'app, l'erreur et des lignes du journal, sans données personnelles.",
"PSBox s'est fermé de façon inattendue la dernière fois",
+ "Pays de connexion",
+ "Désactivé (celui de la console)",
+ "Se connecter depuis un autre pays",
+ "xCloud sera informé que la connexion vient du pays choisi. Microsoft ne l'autorise pas : utilisez-le à vos risques. Les jeux peuvent alors venir de serveurs éloignés, avec plus de latence. Modifiable plus tard dans Paramètres.",
+ "xCloud a refusé la connexion. Le jeu dans le cloud n'est peut-être pas proposé dans votre pays, ou le compte n'a pas le Game Pass Ultimate.",
+ "xCloud a refusé la connexion, même en choisissant %s. Le compte n'a probablement pas le Game Pass Ultimate.",
+ "Brésil",
+ "Japon",
+ "Corée du Sud",
+ "Pologne",
+ "États-Unis",
};
constexpr Column kGerman = {
@@ -1105,6 +1149,17 @@ constexpr Column kGerman = {
"Mit dem Handy scannen: Das Fehlerformular auf GitHub öffnet sich ausgefüllt. Du prüfst es vor dem Senden.",
"Enthalten sind die App-Version, der Fehler und Zeilen des Logs, ohne persönliche Daten.",
"PSBox wurde beim letzten Mal unerwartet beendet",
+ "Anmeldeland",
+ "Aus (das der Konsole)",
+ "Als anderes Land anmelden",
+ "xCloud wird mitgeteilt, dass die Anmeldung aus dem gewählten Land kommt. Microsoft erlaubt das nicht: Nutzung auf eigenes Risiko. Spiele kommen dann eventuell von weit entfernten Servern, mit mehr Verzögerung. Später in den Einstellungen änderbar.",
+ "xCloud hat die Anmeldung abgelehnt. Cloud Gaming wird in deinem Land vielleicht nicht angeboten, oder das Konto hat kein Game Pass Ultimate.",
+ "xCloud hat die Anmeldung abgelehnt, auch mit %s. Das Konto hat wahrscheinlich kein Game Pass Ultimate.",
+ "Brasilien",
+ "Japan",
+ "Südkorea",
+ "Polen",
+ "USA",
};
constexpr Column kItalian = {
@@ -1320,6 +1375,17 @@ constexpr Column kItalian = {
"Inquadralo con il telefono: si apre il modulo dei bug di GitHub già compilato. Lo controlli prima di inviarlo.",
"Include la versione dell'app, l'errore e righe del log, senza dati personali.",
"PSBox si è chiuso inaspettatamente l'ultima volta",
+ "Paese di accesso",
+ "Disattivato (quello della console)",
+ "Accedi come un altro paese",
+ "A xCloud verrà detto che l'accesso arriva dal paese scelto. Microsoft non lo consente: usalo a tuo rischio. I giochi potrebbero arrivare da server lontani, con più ritardo. Puoi cambiarlo poi in Impostazioni.",
+ "xCloud ha rifiutato l'accesso. Il cloud gaming potrebbe non essere offerto nel tuo paese, oppure l'account non ha Game Pass Ultimate.",
+ "xCloud ha rifiutato l'accesso, anche scegliendo %s. Probabilmente l'account non ha Game Pass Ultimate.",
+ "Brasile",
+ "Giappone",
+ "Corea del Sud",
+ "Polonia",
+ "Stati Uniti",
};
constexpr std::array<const Column*, kLangs> kTable = {&kEnglish, &kPortugueseBR, &kSpanish,
diff --git a/src/ui/strings.h b/src/ui/strings.h
index 95949c3..dace723 100644
--- a/src/ui/strings.h
+++ b/src/ui/strings.h
@@ -222,6 +222,17 @@ enum class Str {
ReportScan, // the report panel
ReportIncludes,
CrashedLastTime, // the report panel's heading after a crash
+ LoginCountry, // Settings row: "Sign in as another country"
+ LoginCountryOff, // its choice "off": the console's own country
+ TryOtherCountry, // button hint on the refused sign-in
+ LoginCountryWarning, // the country list's warning
+ RegionRefused, // the sign-in refused by xCloud
+ RegionRefusedAs, // "%s" = the country it was tried as
+ CountryBR,
+ CountryJP,
+ CountryKR,
+ CountryPL,
+ CountryUS,
Count
};
diff --git a/src/xcloud/gssv.cpp b/src/xcloud/gssv.cpp
index 5f21a3a..9f21fa3 100644
--- a/src/xcloud/gssv.cpp
+++ b/src/xcloud/gssv.cpp
@@ -216,6 +216,20 @@ static net::Request authed(Resolution res, const GssvLogin& l, std::string metho
return req;
}
+const char* loginCountryAddress(const std::string& country) {
+ static const struct {
+ const char* country;
+ const char* address;
+ } kAddresses[] = {{"br", "169.150.198.66"},
+ {"jp", "138.199.21.239"},
+ {"kr", "121.125.60.151"},
+ {"pl", "45.134.212.66"},
+ {"us", "143.244.47.65"}};
+ for (const auto& a : kAddresses)
+ if (country == a.country) return a.address;
+ return nullptr;
+}
+
bool GssvClient::login(const auth::XblToken& gssvXsts, std::string& err) {
json::Value body = json::Value::object();
body.set("token", gssvXsts.token);
@@ -226,7 +240,12 @@ bool GssvClient::login(const auth::XblToken& gssvXsts, std::string& err) {
req.url = "https://" + offering_ + ".gssv-play-prod.xboxlive.com/v2/login/user";
req.headers = {{"Content-Type", "application/json"}, {"x-gssv-client", kClientHeader}};
req.body = body.dump();
+ if (const char* address = loginCountryAddress(loginCountry_)) {
+ req.headers.emplace_back("X-Forwarded-For", address);
+ XC_LOGI("xCloud login as country %s", loginCountry_.c_str()); // not the address
+ }
auto r = net::perform(req);
+ loginStatus_ = r.status;
auto j = json::parse(r.body);
if (!r.ok() || !j || !(*j)["gsToken"].isString()) {
err = "xCloud login failed: " + describe(r);
diff --git a/src/xcloud/gssv.h b/src/xcloud/gssv.h
index d21c5e9..69637dc 100644
--- a/src/xcloud/gssv.h
+++ b/src/xcloud/gssv.h
@@ -75,12 +75,29 @@ struct IceCandidate {
// streams at a higher bitrate (Better xCloud's "1080p (HQ)").
enum class Resolution { P1080, P720, P1440, P1080HQ };
+// "Sign in as another country": xCloud is offered by country, which the
+// login (/v2/login/user) decides from where the request comes from. With one
+// of these chosen, that request alone says it comes from an address in the
+// country (X-Forwarded-For), as Better xCloud does (its list, MIT licence,
+// (c) redphx). Off unless the user picks one, after the login was refused.
+// The country codes ("br", "jp", "kr", "pl", "us"); nullptr for "" or an
+// unknown one.
+const char* loginCountryAddress(const std::string& country);
+
class GssvClient {
public:
// `offering` is "xgpuweb" (Game Pass cloud) or "xhome" (own console).
explicit GssvClient(std::string offering = "xgpuweb") : offering_(std::move(offering)) {}
bool login(const auth::XblToken& gssvXsts, std::string& err);
+ // Sign in as `country` (loginCountryAddress); "" is the console's own.
+ // Set before each sign-in: it also forgets the last login's status.
+ void setLoginCountry(const std::string& country) { loginCountry_ = country, loginStatus_ = 0; }
+ // The last login's HTTP status (0: no answer). The service answered
+ // and said no: the country may not be offered (or no Game Pass Ultimate;
+ // it doesn't say which).
+ int loginStatus() const { return loginStatus_; }
+ bool loginRefused() const { return loginStatus_ >= 400 && loginStatus_ < 500; }
const GssvLogin& session() const { return login_; }
void setRegion(const Region& r) { region_ = r; }
void setResolution(Resolution r) { resolution_ = r; }
@@ -120,6 +137,8 @@ private:
std::string sessionUrl(const std::string& suffix) const;
std::string offering_;
+ std::string loginCountry_;
+ int loginStatus_ = 0;
Resolution resolution_ = Resolution::P1080;
GssvLogin login_;
Region region_;
diff --git a/tests/test_main.cpp b/tests/test_main.cpp
index d35d457..901b852 100644
--- a/tests/test_main.cpp
+++ b/tests/test_main.cpp
@@ -18,6 +18,7 @@
#include "ui/stream_menu.h"
#include "ui/strings.h"
#include "util/json.h"
+#include "xcloud/gssv.h"
#include "xcloud/prices.h"
#include "xcloud/regions.h"
@@ -142,6 +143,32 @@ static void testTeredo() {
CHECK(!stream::decodeTeredo("10.0.0.1", ip, port));
}
+static void testLoginCountry() {
+ // Every country the UI offers has an address and a name; off and
+ // anything else sends none.
+ for (const char* country : ui::kLoginCountries) {
+ const char* address = xcloud::loginCountryAddress(country);
+ CHECK(address && std::string(address).find('.') != std::string::npos);
+ CHECK(!ui::loginCountryName(country).empty());
+ }
+ CHECK(!xcloud::loginCountryAddress("") && !xcloud::loginCountryAddress("xx") && !xcloud::loginCountryAddress("BR"));
+ CHECK(ui::loginCountryName("xx").empty());
+ // Saved, and off when the file has none.
+ std::string path = "/tmp/xcloud-tests-country.json";
+ app::Settings s;
+ s.loginCountry = "jp";
+ CHECK(s.save(path));
+ app::Settings back;
+ CHECK(back.load(path) && back.loginCountry == "jp");
+ xc::platform::writeFileAtomic(path, "{}");
+ app::Settings none;
+ CHECK(none.load(path) && none.loginCountry.empty());
+ std::remove(path.c_str());
+ // No login yet, or a new sign-in: not refused.
+ xcloud::GssvClient gssv;
+ CHECK(!gssv.loginRefused() && gssv.loginStatus() == 0);
+}
+
static void testStrings() {
using namespace ui;
auto placeholders = [](const std::string& t) {
@@ -619,6 +646,7 @@ int main() {
testReport();
testCrashGuard();
testBuiltinCa();
+ testLoginCountry();
testAudioEncoder();
testAutoDeband();
testControllerTuning();