Gamerig Library: gamerig's game library as a Chandra desktop module
CI / test (push) Successful in 2m25s
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:
57 files changed
+3551
-29
No files matched your search
@@ -0,0 +1,5 @@
|
||||
A game library (docs/gamerig-library.md): the games and apps a game-streaming rig offers, what
|
||||
runs, and the rig's GPU, display and audio. The host gets all of it from gamerig's library
|
||||
daemon (`GET /api/state` on 127.0.0.1:8091, or GAMERIG_DESKTOP_API), polled every couple of
|
||||
seconds; the module never talks to the network itself. Launch, stop and focus go back to the
|
||||
daemon, which starts games on the rig's X server.
|
||||
@@ -0,0 +1,54 @@
|
||||
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
|
||||
|
||||
///|
|
||||
fn wasmImportStatus(p0 : Int) = "chandra:desktop/game-library@0.1.0" "status"
|
||||
|
||||
///|
|
||||
fn wasmImportGames(p0 : Int) = "chandra:desktop/game-library@0.1.0" "games"
|
||||
|
||||
///|
|
||||
fn wasmImportLaunchModes(p0 : Int) = "chandra:desktop/game-library@0.1.0" "launch-modes"
|
||||
|
||||
///|
|
||||
fn wasmImportLaunch(p0 : Int, p1 : Int, p2 : Int, p3 : Int) = "chandra:desktop/game-library@0.1.0" "launch"
|
||||
|
||||
///|
|
||||
fn wasmImportStop(p0 : Int, p1 : Int) = "chandra:desktop/game-library@0.1.0" "stop"
|
||||
|
||||
///|
|
||||
fn wasmImportFocus(p0 : Int, p1 : Int) = "chandra:desktop/game-library@0.1.0" "focus"
|
||||
|
||||
///|
|
||||
fn wasmImportRefresh() = "chandra:desktop/game-library@0.1.0" "refresh"
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load)
|
||||
|
||||
///|
|
||||
#owned(str)
|
||||
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load8_u(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load8_u)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_free(position : Int) =
|
||||
#|(func (param i32) local.get 0 call $moonbit.decref)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String =
|
||||
#|(func (param i32) (param i32) (result i32)
|
||||
#| local.get 0
|
||||
#| local.get 1 call $moonbit.init_array16
|
||||
#| local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
|
||||
#|(func (param i32) (result i32) (local i32)
|
||||
#| local.get 0 i32.const 4 i32.add call $moonbit.gc.malloc
|
||||
#| local.tee 1 i32.const 0 call $moonbit.init_array8
|
||||
#| local.get 1)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
warnings = "-44"
|
||||
@@ -0,0 +1,129 @@
|
||||
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
|
||||
///|
|
||||
pub(all) struct RigStatus {
|
||||
error : String; gpu : String; resolution : String; display : String; audio : String; hostname : String; connected : Bool; audio_ok : Bool
|
||||
}
|
||||
///|
|
||||
pub(all) struct Game {
|
||||
id : String; name : String; category : String; description : String; icon : String; install_hint : String; featured : Bool; installed : Bool; running : Bool
|
||||
}
|
||||
///|
|
||||
/// A way to start a game other than plain Launch (Steam's Big Picture).
|
||||
pub(all) struct LaunchMode {
|
||||
game : String; id : String; label : String
|
||||
}
|
||||
///|
|
||||
pub fn status() -> RigStatus {
|
||||
|
||||
let return_area = mbt_ffi_malloc(52)
|
||||
wasmImportStatus(return_area);
|
||||
|
||||
let result = mbt_ffi_ptr2str(mbt_ffi_load32((return_area) + 0), mbt_ffi_load32((return_area) + 4))
|
||||
|
||||
let result0 = mbt_ffi_ptr2str(mbt_ffi_load32((return_area) + 8), mbt_ffi_load32((return_area) + 12))
|
||||
|
||||
let result1 = mbt_ffi_ptr2str(mbt_ffi_load32((return_area) + 16), mbt_ffi_load32((return_area) + 20))
|
||||
|
||||
let result2 = mbt_ffi_ptr2str(mbt_ffi_load32((return_area) + 24), mbt_ffi_load32((return_area) + 28))
|
||||
|
||||
let result3 = mbt_ffi_ptr2str(mbt_ffi_load32((return_area) + 32), mbt_ffi_load32((return_area) + 36))
|
||||
|
||||
let result4 = mbt_ffi_ptr2str(mbt_ffi_load32((return_area) + 40), mbt_ffi_load32((return_area) + 44))
|
||||
let ret = RigStatus::{error : result, gpu : result0, resolution : result1, display : result2, audio : result3, hostname : result4, connected : (mbt_ffi_load8_u((return_area) + 48) != 0), audio_ok : (mbt_ffi_load8_u((return_area) + 49) != 0)}
|
||||
mbt_ffi_free(return_area)
|
||||
return ret
|
||||
|
||||
}
|
||||
///|
|
||||
/// In catalog order.
|
||||
pub fn games() -> Array[Game] {
|
||||
|
||||
let return_area = mbt_ffi_malloc(8)
|
||||
wasmImportGames(return_area);
|
||||
|
||||
let array : Array[Game] = [];
|
||||
for index = 0; index < (mbt_ffi_load32((return_area) + 4)); index = index + 1 {
|
||||
let iter_base = (mbt_ffi_load32((return_area) + 0)) + (index * 52)
|
||||
|
||||
let result = mbt_ffi_ptr2str(mbt_ffi_load32((iter_base) + 0), mbt_ffi_load32((iter_base) + 4))
|
||||
|
||||
let result0 = mbt_ffi_ptr2str(mbt_ffi_load32((iter_base) + 8), mbt_ffi_load32((iter_base) + 12))
|
||||
|
||||
let result1 = mbt_ffi_ptr2str(mbt_ffi_load32((iter_base) + 16), mbt_ffi_load32((iter_base) + 20))
|
||||
|
||||
let result2 = mbt_ffi_ptr2str(mbt_ffi_load32((iter_base) + 24), mbt_ffi_load32((iter_base) + 28))
|
||||
|
||||
let result3 = mbt_ffi_ptr2str(mbt_ffi_load32((iter_base) + 32), mbt_ffi_load32((iter_base) + 36))
|
||||
|
||||
let result4 = mbt_ffi_ptr2str(mbt_ffi_load32((iter_base) + 40), mbt_ffi_load32((iter_base) + 44))
|
||||
|
||||
array.push(Game::{id : result, name : result0, category : result1, description : result2, icon : result3, install_hint : result4, featured : (mbt_ffi_load8_u((iter_base) + 48) != 0), installed : (mbt_ffi_load8_u((iter_base) + 49) != 0), running : (mbt_ffi_load8_u((iter_base) + 50) != 0)})
|
||||
}
|
||||
mbt_ffi_free(mbt_ffi_load32((return_area) + 0))
|
||||
let ret = array
|
||||
mbt_ffi_free(return_area)
|
||||
return ret
|
||||
|
||||
}
|
||||
///|
|
||||
pub fn launch_modes() -> Array[LaunchMode] {
|
||||
|
||||
let return_area = mbt_ffi_malloc(8)
|
||||
wasmImportLaunchModes(return_area);
|
||||
|
||||
let array : Array[LaunchMode] = [];
|
||||
for index = 0; index < (mbt_ffi_load32((return_area) + 4)); index = index + 1 {
|
||||
let iter_base = (mbt_ffi_load32((return_area) + 0)) + (index * 24)
|
||||
|
||||
let result = mbt_ffi_ptr2str(mbt_ffi_load32((iter_base) + 0), mbt_ffi_load32((iter_base) + 4))
|
||||
|
||||
let result0 = mbt_ffi_ptr2str(mbt_ffi_load32((iter_base) + 8), mbt_ffi_load32((iter_base) + 12))
|
||||
|
||||
let result1 = mbt_ffi_ptr2str(mbt_ffi_load32((iter_base) + 16), mbt_ffi_load32((iter_base) + 20))
|
||||
|
||||
array.push(LaunchMode::{game : result, id : result0, label : result1})
|
||||
}
|
||||
mbt_ffi_free(mbt_ffi_load32((return_area) + 0))
|
||||
let ret = array
|
||||
mbt_ffi_free(return_area)
|
||||
return ret
|
||||
|
||||
}
|
||||
///|
|
||||
/// Start `game` (`mode` "default", or one of its launch modes).
|
||||
pub fn launch(game : String, mode : String) -> Unit {
|
||||
|
||||
let ptr = mbt_ffi_str2ptr(game)
|
||||
|
||||
let ptr0 = mbt_ffi_str2ptr(mode)
|
||||
wasmImportLaunch(ptr, game.length(), ptr0, mode.length());
|
||||
mbt_ffi_free(ptr)
|
||||
mbt_ffi_free(ptr0)
|
||||
|
||||
}
|
||||
///|
|
||||
/// Stop it (SIGTERM, then SIGKILL).
|
||||
pub fn stop(game : String) -> Unit {
|
||||
|
||||
let ptr = mbt_ffi_str2ptr(game)
|
||||
wasmImportStop(ptr, game.length());
|
||||
mbt_ffi_free(ptr)
|
||||
|
||||
}
|
||||
///|
|
||||
/// Raise its window over the desktop.
|
||||
pub fn focus(game : String) -> Unit {
|
||||
|
||||
let ptr = mbt_ffi_str2ptr(game)
|
||||
wasmImportFocus(ptr, game.length());
|
||||
mbt_ffi_free(ptr)
|
||||
|
||||
}
|
||||
///|
|
||||
/// Poll the daemon again now.
|
||||
pub fn refresh() -> Unit {
|
||||
|
||||
wasmImportRefresh();
|
||||
|
||||
}
|
||||
|
||||
@@ -69,6 +69,12 @@ pub(all) struct ConfigItem {
|
||||
value : String
|
||||
}
|
||||
|
||||
pub(all) struct GameRequest {
|
||||
action : Int32
|
||||
game : String
|
||||
mode : String
|
||||
}
|
||||
|
||||
pub(all) struct InstanceMove {
|
||||
slot : String
|
||||
delta : Int32
|
||||
@@ -123,6 +129,7 @@ pub(all) enum Request {
|
||||
DefaultApp(Int32)
|
||||
SetDesktop(Int32)
|
||||
FaceUnlock(Int32)
|
||||
GameLibrary(GameRequest)
|
||||
}
|
||||
|
||||
pub(all) struct SettingChange {
|
||||
|
||||
@@ -30,6 +30,11 @@ pub(all) struct NetworkRequest {
|
||||
action : Int; ssid : String; password : String
|
||||
}
|
||||
///|
|
||||
/// A game library action: 0 launch (game, mode), 1 stop, 2 focus (game), 3 poll again.
|
||||
pub(all) struct GameRequest {
|
||||
action : Int; game : String; mode : String
|
||||
}
|
||||
///|
|
||||
/// A module moving a panel instance `delta` places (negative: towards the start).
|
||||
pub(all) struct InstanceMove {
|
||||
slot : String; delta : Int
|
||||
@@ -63,6 +68,7 @@ pub(all) enum Request {
|
||||
DefaultApp(Int)
|
||||
SetDesktop(Int)
|
||||
FaceUnlock(Int)
|
||||
GameLibrary(GameRequest)
|
||||
}
|
||||
///|
|
||||
/// A native file-chooser dialog (zenity on the host session) for "Add widget".
|
||||
@@ -428,7 +434,11 @@ pub fn desktop_tick(handle : UInt, now_ms : UInt) -> UInt {
|
||||
/// can-manage has-wifi), 9 Wi-Fi networks (siiii: ssid signal secured active saved), 10 keyboard
|
||||
/// shortcuts (ssssi: name binding default-binding conflict capturing), 11 default-app
|
||||
/// categories (sss: name current missing), 12 default-app choices (issii: category id name icon current),
|
||||
/// 20 desktops (s: name) served by `wallpaper.desktops`.
|
||||
/// 20 desktops (s: name) served by `wallpaper.desktops`, 24 face unlock status (sssiii: problem howdy
|
||||
/// message installed in-use busy; one row), 25 enrolled faces (ss: label added), 26 game library status (one row,
|
||||
/// ssssssii: error gpu resolution display audio hostname connected audio-ok),
|
||||
/// 27 games (ssssssiii: id name category description icon install-hint featured installed running),
|
||||
/// 28 launch modes (sss: game id label).
|
||||
pub fn publish_table(which : UInt, rows : FixedArray[Byte]) -> Unit {
|
||||
|
||||
let ptr = mbt_ffi_bytes2ptr(rows)
|
||||
@@ -528,7 +538,7 @@ pub fn next_request() -> Request? {
|
||||
let return_area = mbt_ffi_malloc(28)
|
||||
wasmImportNextRequest(return_area);
|
||||
|
||||
let lifted5 : Request? = match mbt_ffi_load8_u((return_area) + 0) {
|
||||
let lifted7 : Request? = match mbt_ffi_load8_u((return_area) + 0) {
|
||||
0 => Option::None
|
||||
1 => {
|
||||
|
||||
@@ -629,6 +639,14 @@ pub fn next_request() -> Request? {
|
||||
|
||||
Request::FaceUnlock(mbt_ffi_load32((return_area) + 8))
|
||||
}
|
||||
21 => {
|
||||
|
||||
let result5 = mbt_ffi_ptr2str(mbt_ffi_load32((return_area) + 12), mbt_ffi_load32((return_area) + 16))
|
||||
|
||||
let result6 = mbt_ffi_ptr2str(mbt_ffi_load32((return_area) + 20), mbt_ffi_load32((return_area) + 24))
|
||||
|
||||
Request::GameLibrary(GameRequest::{action : mbt_ffi_load32((return_area) + 8), game : result5, mode : result6})
|
||||
}
|
||||
_ => panic()
|
||||
}
|
||||
|
||||
@@ -636,7 +654,7 @@ pub fn next_request() -> Request? {
|
||||
}
|
||||
_ => panic()
|
||||
}
|
||||
let ret = lifted5
|
||||
let ret = lifted7
|
||||
mbt_ffi_free(return_area)
|
||||
return ret
|
||||
|
||||
|
||||
Reference in new issue
Block a user