commit 7cf3b4c1315f5c52804dc787d207f15c0ad7cdc0
Author: mrfox <jens.se@icloud.com>
AuthorDate: Wed Nov 25 16:27:41 2026 +0100
Commit: mrfox <jens.se@icloud.com>
CommitDate: Wed Nov 25 16:27:41 2026 +0100
xex video test: log every controller change, show pressed buttons
Every button (by name), trigger and stick change on all four ports goes to
the log, a row of 16 boxes and two trigger bars show the state on screen,
and the test runs 60 s so all inputs can be tried.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---
platform/xex/README.md | 2 +-
platform/xex/tests/video/main.cpp | 51 +++++++++++++++++++++++++++++++++++++--
2 files changed, 50 insertions(+), 3 deletions(-)
diff --git a/platform/xex/README.md b/platform/xex/README.md
index 3dbb274..98c1b92 100644
--- a/platform/xex/README.md
+++ b/platform/xex/README.md
@@ -67,4 +67,4 @@ read-only, so file writes only work on a console.
|---|---|
| `tests/hello` | static constructors, C++ exceptions, `std::regex`, notifications, exit to dashboard |
| `tests/fs` | time, `clock()`, directory listing, write/append/read/seek/stat/mkdir/remove on every device; writes `game:/fs-test-report.txt` |
-| `tests/video` | CPU-drawn frames at 60 fps through the title's own GPU ring, controller input (d-pad moves a square, A/B/X/Y colour it); logs to `game:/video-log.txt`, exits after 20 s or on Back+Start |
+| `tests/video` | CPU-drawn frames at 60 fps through the title's own GPU ring, controller input (d-pad moves a square, A/B/X/Y colour it); a row of 16 boxes lights up with the pressed buttons and every controller change is logged to `game:/video-log.txt`; exits after 60 s or on Back+Start |
diff --git a/platform/xex/tests/video/main.cpp b/platform/xex/tests/video/main.cpp
index f79691b..708f0cd 100644
--- a/platform/xex/tests/video/main.cpp
+++ b/platform/xex/tests/video/main.cpp
@@ -25,6 +25,40 @@ static void logLine(const char *fmt, ...) {
}
}
+static const char *const buttonNames[16] = {
+ "UP", "DOWN", "LEFT", "RIGHT", "START", "BACK", "LTHUMB", "RTHUMB",
+ "LB", "RB", "bit10", "bit11", "A", "B", "X", "Y"};
+
+// Logs every change of a controller: buttons by name, triggers past half,
+// sticks past half in each direction.
+static void logPadChanges(int port, int connected, const xex_pad &pad) {
+ static int lastConnected[4] = {-2, -2, -2, -2};
+ static xex_pad last[4];
+ if (connected != lastConnected[port]) {
+ logLine("pad %d: %s", port, connected == 0 ? "connected" : "not connected");
+ lastConnected[port] = connected;
+ }
+ if (connected != 0) return;
+ uint16_t changed = pad.buttons ^ last[port].buttons;
+ for (int b = 0; b < 16; b++) {
+ if (changed & (1 << b))
+ logLine("pad %d: %s %s", port, buttonNames[b], (pad.buttons & (1 << b)) ? "down" : "up");
+ }
+ auto zone = [](int v) { return v > 16000 ? 1 : v < -16000 ? -1 : 0; };
+ const int16_t now[4] = {pad.lx, pad.ly, pad.rx, pad.ry};
+ const int16_t before[4] = {last[port].lx, last[port].ly, last[port].rx, last[port].ry};
+ static const char *const axis[4] = {"left stick x", "left stick y", "right stick x", "right stick y"};
+ for (int a = 0; a < 4; a++) {
+ if (zone(now[a]) != zone(before[a])) logLine("pad %d: %s %d (%s)", port, axis[a], now[a],
+ zone(now[a]) > 0 ? "+" : zone(now[a]) < 0 ? "-" : "centre");
+ }
+ if ((pad.left_trigger > 128) != (last[port].left_trigger > 128))
+ logLine("pad %d: LT %u", port, pad.left_trigger);
+ if ((pad.right_trigger > 128) != (last[port].right_trigger > 128))
+ logLine("pad %d: RT %u", port, pad.right_trigger);
+ last[port] = pad;
+}
+
int main(int, char **) {
remove("game:/video-log.txt");
logLine("start");
@@ -51,9 +85,14 @@ int main(int, char **) {
for (;;) {
xex_pad pad;
int connected = xex_input_get(0, &pad);
+ logPadChanges(0, connected, pad);
+ for (int port = 1; port < 4; port++) {
+ xex_pad other;
+ logPadChanges(port, xex_input_get(port, &other), other);
+ }
// stop by itself after 20 s, so a black screen still tells whether the loop runs
- if (xex_timebase() - startTime > 20 * freq) {
- logLine("20 s elapsed, exiting");
+ if (xex_timebase() - startTime > 60 * freq) {
+ logLine("60 s elapsed, exiting");
break;
}
if ((pad.buttons & XEX_PAD_BACK) && (pad.buttons & XEX_PAD_START)) break;
@@ -80,6 +119,14 @@ int main(int, char **) {
uint32_t c;
if (x >= sx && x < sx + 128 && y >= sy && y < sy + 128) {
c = colour;
+ } else if (y >= f.window_height - 40 && y < f.window_height - 16 && x >= 16 &&
+ x < 16 + 16 * 36 && (x - 16) % 36 < 30) {
+ int b = (x - 16) / 36;
+ c = (pad.buttons & (1 << b)) ? xex_video_rgb(255, 255, 255) : xex_video_rgb(40, 40, 40);
+ } else if (y >= f.window_height - 64 && y < f.window_height - 52 &&
+ ((x >= 16 && x < 16 + pad.left_trigger) ||
+ (x >= 320 && x < 320 + pad.right_trigger))) {
+ c = xex_video_rgb(255, 163, 0);
} else if (y < 24 && x < fps * 8) {
c = xex_video_rgb(255, 255, 255);
} else {