The Þog of 2024-01-01 — WebAssembly Applet Spec

WIP

Exports

AppletStart

Function Signature
export fn AppletStart() -> void

Called by the host to initialize the module.

AppletQuit

Function Signature
export fn AppletQuit() -> void

Called by the host to notify it's shutting down. (Currently not really that useful)

AppletRender

Function Signature
export fn AppletRender() -> void

Called by the host to tell the module to refresh its framebuffer.

AppletEvent

Function Signature
export fn AppletEvent(
    kind: i32,
    arg_1: i32,
    arg_2: i32,
    arg_3: i32
) -> i32

Called by the host in response to mouse or key events.

Key scancodes and modifiers are TBD.

AppletDisplayWidth

Function Signature
export fn AppletDisplayWidth() -> i32

Returns the module's display width. The host should only call this once at startup.

AppletDisplayHeight

Function Signature
export fn AppletDisplayHeight() -> i32

Returns the module's display height. The host should only call this once at startup.

AppletDisplayPtr

Function Signature
export fn AppletDisplayPtr -> *u32

Returns a pointer to an array of width*height RGBA bytes. The host should only call this once at startup.

Imports

Applet.Write

Function Signature
import fn Applet.Write(ptr: *u8, len: u32) -> void

A debugging aid. Writes UTF-8 text to an optional text buffer, without a newline.

Applet.SetCursorLock

Function Signature
import fn Applet.SetCursorLock(enable: i32) -> void

Requests the host to lock the cursor. Locked cursor movement gives mouse delta events instead of absolute position events.

Applets should account for the host not locking the cursor. Ideally, the host should try to lock the cursor when able.

Applet.Quit

Function Signature
import fn Applet.Quit(code: i32) -> noreturn

Requests the host to quit. The host should call AppletQuit, like in any other quit condition.