Skip to content

Xbox Cloud Gaming app for PS5 Homebrew

C

DualSense light bar in the colour of the game in focus

Rafael Abud Ferreiraaa5baf1dc75d
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d348866..c4474ca 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -65,6 +65,7 @@ add_library(xcloud_ui STATIC
src/ui/app_ui.cpp
src/ui/stream_menu.cpp
src/ui/pad_icons.cpp
+ src/ui/accent_color.cpp
src/ui/brand.cpp
src/app/library.cpp
src/app/settings.cpp
diff --git a/src/app/ps5_main.cpp b/src/app/ps5_main.cpp
index 0b83d28..743e05e 100644
--- a/src/app/ps5_main.cpp
+++ b/src/app/ps5_main.cpp
@@ -780,6 +780,7 @@ int main(int argc, char** argv) {
choice.deadzone = deadzoneIndex(g_settings.deadzone);
choice.triggerRumble = g_settings.triggerRumble;
choice.circleConfirms = g_settings.circleConfirms;
+ choice.lightBar = g_settings.lightBar;
g_ui->setSettings(choice);
applyControllerSettings();
g_ui->setRegionLatency(g_settings.regionRtt);
@@ -812,7 +813,9 @@ int main(int argc, char** argv) {
bool padAttached[input::kMaxPads] = {}; // controllers 1..3 announced to the stream
uint32_t playerReconnects = 0;
uint64_t padsCheckedAt = 0;
- unsigned padChecks = 0; // false from the menu/keyboard until the buttons are let go
+ unsigned padChecks = 0;
+ uint64_t lightBarAt = 0;
+ bool lightBarSet = false; // false from the menu/keyboard until the buttons are let go
uint32_t overlaySeq = 0; // g_infoSeq + 1 when drawn; 0 = redraw
uint64_t homeSince = 0, launchSince = 0;
bool uiSaved = false, launchSaved = false;
@@ -821,6 +824,22 @@ int main(int argc, char** argv) {
// Autoplay runs unattended: the physical pad must not interfere.
if (!g_autoplayTitle.empty()) pad = input::ControllerState{};
uint64_t now = platform::nowMs();
+ if (now - lightBarAt >= 100) { // the light bar follows the game in focus
+ lightBarAt = now;
+ bool on;
+ {
+ std::lock_guard<std::mutex> lock(g_settingsMutex);
+ on = g_settings.lightBar;
+ }
+ ui::Color c;
+ if (!on) {
+ if (lightBarSet) input::resetLightBar(0);
+ lightBarSet = false;
+ } else if (g_ui->accentColor(c)) {
+ input::setLightBar(static_cast<uint8_t>(c), static_cast<uint8_t>(c >> 8), static_cast<uint8_t>(c >> 16));
+ lightBarSet = true;
+ }
+ }
if (now - padsCheckedAt >= 500) { // other players signing in or out
padsCheckedAt = now;
if (++padChecks % 2 == 0) input::refreshPads();
@@ -1034,6 +1053,7 @@ int main(int argc, char** argv) {
g_settings.deadzone = ui::kDeadzonePercent[ev.settings.deadzone];
g_settings.triggerRumble = ev.settings.triggerRumble;
g_settings.circleConfirms = ev.settings.circleConfirms;
+ g_settings.lightBar = ev.settings.lightBar;
if (!g_settings.save(settingsPath())) XC_LOGW("could not save settings");
XC_LOGI("settings saved: language %s, %s, region %s", code.c_str(), g_settings.resolution.c_str(),
g_settings.region.empty() ? "auto" : g_settings.region.c_str());
diff --git a/src/app/settings.cpp b/src/app/settings.cpp
index bae46a6..f1747e1 100644
--- a/src/app/settings.cpp
+++ b/src/app/settings.cpp
@@ -28,6 +28,7 @@ bool Settings::load(const std::string& path) {
deadzone = static_cast<int>(std::clamp<int64_t>((*j)["deadzone"].asInt(deadzone), 0, 50));
triggerRumble = (*j)["triggerRumble"].asBool(triggerRumble);
circleConfirms = (*j)["circleConfirms"].asBool(circleConfirms);
+ lightBar = (*j)["lightBar"].asBool(lightBar);
regionRtt.clear();
for (const auto& [name, ms] : (*j)["regionRtt"].members())
if (ms.asInt() > 0) regionRtt[name] = static_cast<int>(ms.asInt());
@@ -52,6 +53,7 @@ bool Settings::save(const std::string& path) const {
v.set("deadzone", deadzone);
v.set("triggerRumble", triggerRumble);
v.set("circleConfirms", circleConfirms);
+ v.set("lightBar", lightBar);
return platform::writeFileAtomic(path, v.dump());
}
diff --git a/src/app/settings.h b/src/app/settings.h
index 7dcd7c7..6a904fb 100644
--- a/src/app/settings.h
+++ b/src/app/settings.h
@@ -30,6 +30,8 @@ struct Settings {
int deadzone = 15;
bool triggerRumble = true;
bool circleConfirms = false;
+ // The DualSense light bar takes the colour of the game in focus.
+ bool lightBar = true;
bool load(const std::string& path);
bool save(const std::string& path) const;
diff --git a/src/input/controller.cpp b/src/input/controller.cpp
index b1eca57..5e867c0 100644
--- a/src/input/controller.cpp
+++ b/src/input/controller.cpp
@@ -90,6 +90,11 @@ struct ScePadTriggerEffectParam {
};
static_assert(sizeof(ScePadTriggerEffectParam) == 120, "ScePadTriggerEffectParam layout");
int scePadSetTriggerEffect(int32_t handle, const ScePadTriggerEffectParam* param);
+struct ScePadColor {
+ uint8_t r, g, b, reserved;
+};
+int scePadSetLightBar(int32_t handle, const ScePadColor* color);
+int scePadResetLightBar(int32_t handle);
}
namespace xc::input {
@@ -138,6 +143,12 @@ struct Pad {
std::atomic<bool> connected{false}; // the last poll's answer
char name[32] = {}; // the user's, read when opened
Rumble motors, triggers;
+ // Light bar: wanted colour (r << 16 | g << 8 | b, bit 24 = set) and the
+ // one shown, easing towards it.
+ std::atomic<uint32_t> lightWanted{0};
+ uint32_t lightApplied = 0;
+ float light[3] = {0, 0, 0};
+ bool lightStarted = false;
};
Pad g_pads[kMaxPads];
std::atomic<float> g_deadzone{0.15f};
@@ -179,6 +190,9 @@ void closePad(Pad& pad, int slot) {
ScePadTriggerEffectParam none{};
none.triggerMask = 3;
scePadSetTriggerEffect(pad.handle, &none);
+ if (pad.lightApplied) scePadResetLightBar(pad.handle);
+ pad.lightApplied = 0;
+ pad.lightStarted = false;
scePadClose(pad.handle);
XC_LOGI("pad %d closed (user %d)", slot, pad.userId);
pad.handle = -1;
@@ -187,6 +201,35 @@ void closePad(Pad& pad, int slot) {
pad.name[0] = 0;
}
+void applyLightBar(Pad& pad) {
+ uint32_t want = pad.lightWanted;
+ if (!(want & (1u << 24))) {
+ if (pad.lightApplied) { // reset: the system's colour again
+ scePadResetLightBar(pad.handle);
+ pad.lightApplied = 0;
+ pad.lightStarted = false;
+ }
+ return;
+ }
+ const float target[3] = {static_cast<float>((want >> 16) & 0xFF), static_cast<float>((want >> 8) & 0xFF),
+ static_cast<float>(want & 0xFF)};
+ if (!pad.lightStarted) {
+ std::copy(target, target + 3, pad.light);
+ pad.lightStarted = true;
+ }
+ // ~120 polls a second: 4 % of the way each, most of it in ~0.4 s.
+ for (int i = 0; i < 3; ++i) pad.light[i] += (target[i] - pad.light[i]) * 0.04f;
+ ScePadColor c{static_cast<uint8_t>(std::lround(pad.light[0])), static_cast<uint8_t>(std::lround(pad.light[1])),
+ static_cast<uint8_t>(std::lround(pad.light[2])), 0};
+ uint32_t shown = (1u << 24) | (uint32_t(c.r) << 16) | (uint32_t(c.g) << 8) | c.b;
+ if (shown == pad.lightApplied) return;
+ int rc = scePadSetLightBar(pad.handle, &c);
+ static bool logged = false;
+ if (!logged || rc != 0) XC_LOGI("scePadSetLightBar(%u, %u, %u): 0x%08x", c.r, c.g, c.b, static_cast<unsigned>(rc));
+ logged = true;
+ pad.lightApplied = shown;
+}
+
void applyRumble(Pad& pad) {
uint32_t v;
if (pad.motors.due(v)) {
@@ -225,6 +268,14 @@ void setTriggerRumble(uint8_t left, uint8_t right, uint32_t durationMs, int pad)
void setCircleConfirms(bool on) { g_circleConfirms = on; }
+void setLightBar(uint8_t r, uint8_t g, uint8_t b, int pad) {
+ if (pad >= 0 && pad < kMaxPads) g_pads[pad].lightWanted = (1u << 24) | (uint32_t(r) << 16) | (uint32_t(g) << 8) | b;
+}
+
+void resetLightBar(int pad) {
+ if (pad >= 0 && pad < kMaxPads) g_pads[pad].lightWanted = 0;
+}
+
bool padConnected(int index) { return index >= 0 && index < kMaxPads && g_pads[index].connected; }
std::string padUserName(int index) {
@@ -299,6 +350,7 @@ bool pollPad(int index, ControllerState& out) {
if (index < 0 || index >= kMaxPads || g_pads[index].handle < 0) return false;
Pad& slot = g_pads[index];
applyRumble(slot);
+ applyLightBar(slot);
ScePadData pad{};
int rc = scePadReadState(slot.handle, &pad);
slot.connected = rc == 0 && pad.connected;
@@ -360,6 +412,8 @@ void setRumble(uint8_t, uint8_t, uint32_t, int) {}
void setTriggerRumble(uint8_t, uint8_t, uint32_t, int) {}
void setDeadzone(float) {}
void setCircleConfirms(bool) {}
+void setLightBar(uint8_t, uint8_t, uint8_t, int) {}
+void resetLightBar(int) {}
bool padConnected(int index) { return index == 0; }
std::string padUserName(int index) { return index == 0 ? "Player" : ""; }
void setTriggerRumbleEnabled(bool) {}
diff --git a/src/input/controller.h b/src/input/controller.h
index 3b8e2cc..dfd279a 100644
--- a/src/input/controller.h
+++ b/src/input/controller.h
@@ -69,5 +69,9 @@ void setDeadzone(float deadzone);
void setCircleConfirms(bool on);
// Off: setTriggerRumble() is ignored.
void setTriggerRumbleEnabled(bool on);
+// The light bar eases (~0.4 s) to this colour; reset gives it back to the
+// system (the player's colour). Any thread; polling applies it.
+void setLightBar(uint8_t r, uint8_t g, uint8_t b, int pad = 0);
+void resetLightBar(int pad = 0);
} // namespace xc::input
diff --git a/src/ui/accent_color.cpp b/src/ui/accent_color.cpp
new file mode 100644
index 0000000..6859879
--- /dev/null
+++ b/src/ui/accent_color.cpp
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// Copyright (C) 2026 RafaelNGP
+#include "ui/accent_color.h"
+
+#include <algorithm>
+#include <array>
+#include <cmath>
+
+namespace xc::ui {
+
+bool dominantColor(const Image& img, Color& out) {
+ if (img.w <= 0 || img.h <= 0 || img.px.empty()) return false;
+ // Hues in 24 bins, each pixel weighted by how saturated and bright it is:
+ // a poster's big dark background counts for little, its colour for a lot.
+ constexpr int kBins = 24;
+ std::array<double, kBins> weight{};
+ std::array<std::array<double, 3>, kBins> sum{};
+ const int step = std::max(1, std::min(img.w, img.h) / 48);
+ for (int y = 0; y < img.h; y += step)
+ for (int x = 0; x < img.w; x += step) {
+ uint32_t p = img.px[static_cast<size_t>(y) * img.w + x];
+ if ((p >> 24) < 128) continue; // transparent
+ double r = (p & 0xFF) / 255.0, g = ((p >> 8) & 0xFF) / 255.0, b = ((p >> 16) & 0xFF) / 255.0;
+ double mx = std::max({r, g, b}), mn = std::min({r, g, b});
+ double sat = mx > 0 ? (mx - mn) / mx : 0;
+ if (sat < 0.25 || mx < 0.2) continue;
+ double hue;
+ double d = mx - mn;
+ if (mx == r) hue = std::fmod((g - b) / d + 6.0, 6.0);
+ else if (mx == g) hue = (b - r) / d + 2.0;
+ else hue = (r - g) / d + 4.0;
+ int bin = std::min(kBins - 1, static_cast<int>(hue / 6.0 * kBins));
+ double w = sat * sat * mx;
+ weight[bin] += w;
+ sum[bin][0] += r * w;
+ sum[bin][1] += g * w;
+ sum[bin][2] += b * w;
+ }
+ int best = static_cast<int>(std::max_element(weight.begin(), weight.end()) - weight.begin());
+ // Too little colour overall (a black and white poster): no answer.
+ double total = 0;
+ for (double w : weight) total += w;
+ int samples = ((img.w + step - 1) / step) * ((img.h + step - 1) / step);
+ if (weight[best] <= 0 || total < samples * 0.01) return false;
+ double r = sum[best][0] / weight[best], g = sum[best][1] / weight[best], b = sum[best][2] / weight[best];
+ // An LED shows hue, not shade: strongest channel at full, and the weakest
+ // pulled down so it doesn't wash out to white.
+ double mx = std::max({r, g, b}), mn = std::min({r, g, b});
+ auto shape = [&](double c) {
+ double t = mx > mn ? (c - mn) / (mx - mn) : 1.0; // 0 for the weakest, 1 for the strongest
+ return static_cast<uint8_t>(std::lround(255.0 * (0.15 + 0.85 * t)));
+ };
+ out = rgba(shape(r), shape(g), shape(b));
+ return true;
+}
+
+} // namespace xc::ui
diff --git a/src/ui/accent_color.h b/src/ui/accent_color.h
new file mode 100644
index 0000000..63239c6
--- /dev/null
+++ b/src/ui/accent_color.h
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// Copyright (C) 2026 RafaelNGP
+// A picture's dominant colour, for the DualSense light bar.
+#pragma once
+
+#include "ui/canvas.h"
+
+namespace xc::ui {
+
+// The most present saturated colour of `img`, brightened for an LED (its
+// strongest channel at full). False when the picture has no colour to speak
+// of (greys, black and white): the caller keeps its default.
+bool dominantColor(const Image& img, Color& out);
+
+} // namespace xc::ui
diff --git a/src/ui/app_ui.cpp b/src/ui/app_ui.cpp
index 666d8ea..1c3838a 100644
--- a/src/ui/app_ui.cpp
+++ b/src/ui/app_ui.cpp
@@ -2,6 +2,8 @@
// Copyright (C) 2026 RafaelNGP
#include "ui/app_ui.h"
+#include "ui/accent_color.h"
+
#include "ui/brand.h"
#include "ui/strings.h"
@@ -641,6 +643,37 @@ void AppUi::setPads(const PadSlots& pads) {
dirty_ = true;
}
+bool AppUi::accentColor(Color& out) {
+ std::lock_guard<std::mutex> lock(mutex_);
+ const GameTile* t = nullptr;
+ switch (screen_) {
+ case Screen::Details: t = &detail_; break;
+ case Screen::Launching:
+ case Screen::Streaming: t = &launching_; break;
+ case Screen::Home:
+ if (searching_) {
+ if (!searchOnKeys_ && resultFocus_ >= 0 && resultFocus_ < static_cast<int>(results_.size()))
+ t = &results_[static_cast<size_t>(resultFocus_)];
+ } else {
+ t = tab_ == Tab::Library ? libraryTile(gridFocus_) : focusedTile();
+ }
+ break;
+ default: break;
+ }
+ if (!t || t->tileUrl.empty()) return false;
+ auto it = accents_.find(t->tileUrl);
+ if (it == accents_.end()) {
+ auto img = images_.get(t->tileUrl, kCard, kCard); // the card's own, already loaded
+ if (!img) return false;
+ Color c;
+ // No colour in the art (black and white): the Xbox green.
+ if (!dominantColor(*img, c)) c = rgba(40, 210, 40);
+ it = accents_.emplace(t->tileUrl, c).first;
+ }
+ out = it->second;
+ return true;
+}
+
void AppUi::drawPads(Canvas& c) {
// Bottom left, on the line of the button hints (which are right-aligned).
drawPadRow(c, fonts_.bold, kMargin, kH - 70, 54, 14, pads_);
@@ -671,6 +704,8 @@ std::vector<std::string> AppUi::settingOptions(int row) const {
out = {tr(Str::Activated), tr(Str::Deactivated)};
} else if (row == 5) {
out = {tr(Str::ButtonCross), tr(Str::ButtonCircle)};
+ } else if (row == 6) {
+ out = {tr(Str::Activated), tr(Str::Deactivated)};
} else {
// Automatic first, then the regions in the login's order.
out.push_back(withMs(trf(Str::RegionAuto, defaultRegion_.empty() ? "-" : prettyRegion(defaultRegion_)),
@@ -689,6 +724,7 @@ int AppUi::settingSelected(int row) const {
if (row == 3) return settings_.deadzone;
if (row == 4) return settings_.triggerRumble ? 0 : 1;
if (row == 5) return settings_.circleConfirms ? 1 : 0;
+ if (row == 6) return settings_.lightBar ? 0 : 1;
for (size_t i = 0; i < regions_.size(); ++i)
if (regions_[i] == settings_.region) return static_cast<int>(i) + 1;
return 0;
@@ -707,6 +743,8 @@ void AppUi::applySetting(int row, int index) {
settings_.triggerRumble = index == 0;
} else if (row == 5) {
settings_.circleConfirms = index == 1;
+ } else if (row == 6) {
+ settings_.lightBar = index == 0;
} else {
settings_.region = index == 0 ? std::string() : regions_[static_cast<size_t>(index - 1)];
}
@@ -1755,10 +1793,11 @@ void AppUi::drawSettings(Canvas& c) {
drawTopBar(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)};
- constexpr int kRowW = 1200, kRowH = 76;
+ tr(Str::Deadzone), tr(Str::TriggerRumble), tr(Str::ConfirmButton),
+ tr(Str::LightBar)};
+ constexpr int kRowW = 1200, kRowH = 70;
Rect rows[kSettingRows];
- int y = 270;
+ int y = 262;
for (int i = 0; i < kSettingRows; ++i) {
Rect r{kMargin, y, kRowW, kRowH};
rows[i] = r;
@@ -1777,7 +1816,7 @@ void AppUi::drawSettings(Canvas& c) {
int w = fonts_.regular.measure(value, 30);
fonts_.regular.draw(c, value, r.x + r.w - 76 - w, fonts_.regular.centeredY(r.y, r.h, 30), 30,
focused ? kWhite : kGray);
- y += kRowH + 16;
+ y += kRowH + 14;
}
for (const auto& line : fonts_.regular.wrap(tr(Str::SettingsNote), 24, kRowW, 2)) {
fonts_.regular.draw(c, line, kMargin, y + 20, 24, kDim);
diff --git a/src/ui/app_ui.h b/src/ui/app_ui.h
index 4c5bda2..ed7392a 100644
--- a/src/ui/app_ui.h
+++ b/src/ui/app_ui.h
@@ -71,11 +71,12 @@ struct SettingsChoice {
int deadzone = 3; // index into kDeadzonePercent (15 %)
bool triggerRumble = true;
bool circleConfirms = false; // Circle is Xbox A (and Cross is B)
+ bool lightBar = true; // the light bar takes the game's colour
};
// The stick dead zones Settings offers, in percent of the travel.
constexpr int kDeadzonePercent[] = {0, 5, 10, 15, 20, 25};
-constexpr int kSettingRows = 6; // language, resolution, region, dead zone, triggers, confirm
+constexpr int kSettingRows = 7; // language, resolution, region, dead zone, triggers, confirm, light bar
enum class Action { None, Play, SignOut, Retry, CancelLaunch, SettingsChanged, PrefsChanged };
@@ -150,6 +151,9 @@ public:
void setCircleConfirms(bool on);
// The controllers in use (bottom left of the home screen).
void setPads(const PadSlots& pads);
+ // The colour of the game in focus (or being played), from its art, for
+ // the DualSense light bar; false while there is none to show.
+ bool accentColor(Color& out);
// Regions offered by the account's xCloud login; `defaultRegion` is the
// one "Automatic" picks.
void setRegions(std::vector<std::string> regions, const std::string& defaultRegion);
@@ -272,6 +276,7 @@ private:
SettingsChoice settings_;
bool circleConfirms_ = false;
PadSlots pads_{};
+ std::map<std::string, Color> accents_; // tile art url -> its colour
std::vector<std::string> regions_;
std::string defaultRegion_;
std::map<std::string, int> regionMs_;
diff --git a/src/ui/strings.cpp b/src/ui/strings.cpp
index 2311381..756387a 100644
--- a/src/ui/strings.cpp
+++ b/src/ui/strings.cpp
@@ -149,6 +149,7 @@ constexpr Column kEnglish = {
"On screen after", // StatOnScreen
"Connection lost: reconnecting...", // Reconnecting
"Reconnected", // Reconnected
+ "Light bar in the game's colour", // LightBar
};
constexpr Column kPortugueseBR = {
@@ -268,6 +269,7 @@ constexpr Column kPortugueseBR = {
"Na tela após",
"Conexão perdida: reconectando...",
"Reconectado",
+ "Barra de luz com a cor do jogo",
};
constexpr Column kSpanish = {
@@ -387,6 +389,7 @@ constexpr Column kSpanish = {
"En pantalla tras",
"Conexión perdida: reconectando...",
"Reconectado",
+ "Barra de luz con el color del juego",
};
constexpr Column kFrench = {
@@ -506,6 +509,7 @@ constexpr Column kFrench = {
"À l'écran après",
"Connexion perdue : reconnexion...",
"Reconnecté",
+ "Barre lumineuse aux couleurs du jeu",
};
constexpr Column kGerman = {
@@ -625,6 +629,7 @@ constexpr Column kGerman = {
"Auf dem Bildschirm nach",
"Verbindung verloren: neu verbinden...",
"Wieder verbunden",
+ "Lichtleiste in der Farbe des Spiels",
};
constexpr Column kItalian = {
@@ -744,6 +749,7 @@ constexpr Column kItalian = {
"Sullo schermo dopo",
"Connessione persa: riconnessione...",
"Riconnesso",
+ "Barra luminosa con il colore del gioco",
};
constexpr std::array<const Column*, kLangs> kTable = {&kEnglish, &kPortugueseBR, &kSpanish,
diff --git a/src/ui/strings.h b/src/ui/strings.h
index 7433a57..a68f6c2 100644
--- a/src/ui/strings.h
+++ b/src/ui/strings.h
@@ -126,6 +126,7 @@ enum class Str {
StatOnScreen, // network arrival to on the TV
Reconnecting, // the connection dropped mid-game
Reconnected,
+ LightBar, // settings: the light bar takes the game's colour
Count
};
diff --git a/tests/test_main.cpp b/tests/test_main.cpp
index 617d5dd..5cf0212 100644
--- a/tests/test_main.cpp
+++ b/tests/test_main.cpp
@@ -6,6 +6,7 @@
#include "stream/input_packet.h"
#include "stream/stream_session.h"
#include "ui/app_ui.h"
+#include "ui/accent_color.h"
#include "ui/stream_menu.h"
#include "ui/strings.h"
#include "util/json.h"
@@ -182,6 +183,22 @@ static void testPrices() {
CHECK(formatPrice(4, "XYZ") == "XYZ 4.00");
}
+static void testAccentColor() {
+ using namespace xc::ui;
+ Image img;
+ img.w = img.h = 64;
+ img.px.assign(64 * 64, rgba(60, 60, 60)); // grey background
+ for (int i = 0; i < 64 * 24; ++i) img.px[i] = rgba(200, 40, 30); // a red third
+ for (int i = 64 * 60; i < 64 * 64; ++i) img.px[i] = rgba(30, 60, 200); // a little blue
+ Color c = 0;
+ CHECK(dominantColor(img, c));
+ CHECK((c & 0xFF) == 255 && ((c >> 8) & 0xFF) < 90 && ((c >> 16) & 0xFF) < 90); // red, at full
+ Image grey;
+ grey.w = grey.h = 16;
+ grey.px.assign(16 * 16, rgba(128, 128, 128));
+ CHECK(!dominantColor(grey, c));
+}
+
static void testVersions() {
using xc::app::isNewerVersion;
CHECK(isNewerVersion("v0.4.0", "0.3.0"));
@@ -228,6 +245,7 @@ static void testStreamMenu() {
}
int main() {
+ testAccentColor();
testVersions();
testStreamMenu();
testStrings();