Gamerig Library: gamerig's game library as a Chandra desktop module
CI / test (push) Successful in 2m25s

- New desktop module gamerig-library (components/gamerig-library, logic in lib/gamelib): the
  layout of gamerig's web library (desktop/ui) in draw ops. Top bar with the Gamerig mark, app
  count and search; sidebar with categories and counts, running apps (switch to, stop) and rig
  status (GPU, display, audio); card grid with featured games two columns wide, icon tiles,
  category and status badges, description, install hint, Launch / Big Picture / Switch to / Stop.
  Typing filters, arrows + Enter launch, the wheel scrolls. Colours: follow desktop, dark, light.
- New game-library capability: tables 26-28 (status, games, launch modes), request 45, in the
  wasmer/wasmtime stub, the MoonBit wasmhost and the Rust host-wasm.
- compositor/shell/gamelib.mbt polls GET $GAMERIG_DESKTOP_API/api/state (default
  http://127.0.0.1:8091) every 2 s with curl on a socket and POSTs launch/stop/focus; a file://
  base reads a state file (tests).
- --desktop NAME picks what fills the desktop at start. scripts/gamerig-kiosk.sh now runs a
  hybrid kiosk with the library as the desktop (CHANDRA_KIOSK_MODE=strict for the old one).
- Tests: lib/gamelib, compositor/host/gamelib_test.mbt, a host-wasm test; docs/gamerig-library.md
  with a screenshot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hgvjzw8hHirxRsXSsE
This commit is contained in:
Claude committed 2026-11-26 02:57:07 +00:00
1 parent fa932f9ac0
commit f556df2f4b
57 files changed
+3551 -29

No files matched your search

+34 -2
View File
@@ -67,7 +67,8 @@ enum {
K_SC_LIST, K_SC_CAPTURE, K_SC_CANCEL, K_SC_RESET, K_SC_RESET_ALL,
K_DA_CATS, K_DA_APPS, K_DA_SET, K_DA_REFRESH,
K_DESKTOPS, K_DESKTOP_CUR, K_SET_DESKTOP,
K_FU_STATUS, K_FU_FACES, K_FU_ENROLL, K_FU_REMOVE, K_FU_SET_IN_USE, K_FU_REFRESH
K_FU_STATUS, K_FU_FACES, K_FU_ENROLL, K_FU_REMOVE, K_FU_SET_IN_USE, K_FU_REFRESH,
K_GL_STATUS, K_GL_GAMES, K_GL_MODES, K_GL_LAUNCH, K_GL_STOP, K_GL_FOCUS, K_GL_REFRESH
};
typedef struct Env { Inst *inst; int kind; } Env;
@@ -76,7 +77,8 @@ typedef struct Env { Inst *inst; int kind; } Env;
enum { T_APPS, T_WINDOWS, T_LAYOUTS, T_MODULES, T_INSTANCES, T_WALLPAPERS, T_SESSION_SETTINGS, T_ICONS,
T_NET_STATUS, T_NET_NETWORKS, T_SHORTCUTS, T_APP_CATS, T_APP_CHOICES,
/* fixed numbers from here (wit/host/plasmoids.wit publish-table) */
T_DESKTOPS = 20, T_FACE_STATUS = 24, T_FACES = 25, T_N = 32 };
T_DESKTOPS = 20, T_FACE_STATUS = 24, T_FACES = 25,
T_GL_STATUS = 26, T_GL_GAMES = 27, T_GL_MODES = 28, T_N = 32 };
typedef struct { uint8_t *data; size_t len; } Blob;
static Blob tables[T_N];
static int32_t host_ints[24] = {[7] = -1}; /* 0 layout mode, 1 inspector on, 2 current wallpaper, 3 session settings on (bit i: row i),
@@ -397,6 +399,29 @@ static wasm_trap_t *host_import(void *env, const wasm_val_vec_t *args, wasm_val_
case K_FU_REMOVE: if (a0 >= 0 && a0 < 1000) push_req(44, a0, NULL); break;
case K_FU_SET_IN_USE: push_req(44, a0 ? -4 : -3, NULL); break;
case K_FU_REFRESH: push_req(44, -1, NULL); break;
/* Game library: status from table 26 (error gpu resolution display audio hostname connected
* audio-ok), games from 27 (id name category description icon install-hint featured installed
* running), launch modes from 28 (game id label); request 45 is 0 launch / 1 stop / 2 focus /
* 3 refresh, with "game\x1fmode". */
case K_GL_STATUS: build_record(in, T_GL_STATUS, "ssssssbb", a0); break;
case K_GL_GAMES: build_list(in, T_GL_GAMES, "ssssssbbb", a0); break;
case K_GL_MODES: build_list(in, T_GL_MODES, "sss", a0); break;
case K_GL_REFRESH: push_req(45, 3, NULL); break;
case K_GL_LAUNCH:
case K_GL_STOP:
case K_GL_FOCUS: {
int32_t a3 = args->size >= 4 ? args->data[3].of.i32 : 0;
char *game = guest_str(in, a0, a1);
char *mode = e->kind == K_GL_LAUNCH ? guest_str(in, a2, a3) : strdup("");
size_t lg = strlen(game), lm = strlen(mode);
char *both = (char *)malloc(lg + lm + 2);
memcpy(both, game, lg);
both[lg] = 0x1f;
memcpy(both + lg + 1, mode, lm + 1);
push_req(45, e->kind == K_GL_LAUNCH ? 0 : e->kind == K_GL_STOP ? 1 : 2, both);
free(game); free(mode); free(both);
break;
}
case K_SESSION_SET: push_req(a1 ? 11 : 10, a0, NULL); break; /* 10 off, 11 on */
/* Request 12 carries the screenshot code: 0-3 take, 10-12 record, 20 stop, 30/31 pointer. */
case K_SHOT_TAKE: if (a0 >= 0 && a0 <= 3) push_req(12, a0, NULL); break;
@@ -620,6 +645,13 @@ static int classify_import(const wasm_name_t *m, const wasm_name_t *f) {
if (!strcmp(iface, "face-unlock") && !strcmp(fn, "remove")) return K_FU_REMOVE;
if (!strcmp(iface, "face-unlock") && !strcmp(fn, "set-in-use")) return K_FU_SET_IN_USE;
if (!strcmp(iface, "face-unlock") && !strcmp(fn, "refresh")) return K_FU_REFRESH;
if (!strcmp(iface, "game-library") && !strcmp(fn, "status")) return K_GL_STATUS;
if (!strcmp(iface, "game-library") && !strcmp(fn, "games")) return K_GL_GAMES;
if (!strcmp(iface, "game-library") && !strcmp(fn, "launch-modes")) return K_GL_MODES;
if (!strcmp(iface, "game-library") && !strcmp(fn, "launch")) return K_GL_LAUNCH;
if (!strcmp(iface, "game-library") && !strcmp(fn, "stop")) return K_GL_STOP;
if (!strcmp(iface, "game-library") && !strcmp(fn, "focus")) return K_GL_FOCUS;
if (!strcmp(iface, "game-library") && !strcmp(fn, "refresh")) return K_GL_REFRESH;
if (!strcmp(iface, "session-settings") && !strcmp(fn, "settings")) return K_SESSION_SETTINGS;
if (!strcmp(iface, "session-settings") && !strcmp(fn, "is-on")) return K_SESSION_IS_ON;
if (!strcmp(iface, "session-settings") && !strcmp(fn, "set-setting")) return K_SESSION_SET;