Difference between revisions of "SDK 6.3/Rust/cubios-sys"

From WowWiki
Jump to navigation Jump to search
(Full Rust API reference: cubios-sys + cubios, every pub fn with docs (WowBot))
 
(Fix array-type signatures (WowBot))
 
Line 32: Line 32:
 
: Called every frame. `cur_time` is current time in ms, `delta_time` is ms since last tick.
 
: Called every frame. `cur_time` is current time in ms, `delta_time` is ms since last tick.
  
; <code>Application::fn on_render(&mut self, screens: &mut [Screen</code>
+
; <code>Application::fn on_render(&mut self, screens: &mut [Screen; 3]) -&gt; Result&lt;(), AppErr&gt;</code>
 
: Called to render the current frame. `screens` contains the 3 screens for this module.
 
: Called to render the current frame. `screens` contains the 3 screens for this module.
  
; <code>Application::fn on_phys_tick(&mut self, screens: &[Screen</code>
+
; <code>Application::fn on_phys_tick(&mut self, screens: &[Screen; 3]) -&gt; Result&lt;(), AppErr&gt;</code>
 
: Called on physics tick. `screens` contains the 3 screens for this module.
 
: Called on physics tick. `screens` contains the 3 screens for this module.
  
Line 93: Line 93:
 
; <code>Mappable::fn get_place( &self, module: u32, screen: u32, orientation: TopologyOrientation, ) -&gt; Result&lt;(u32, u32), AppErr&gt;</code>
 
; <code>Mappable::fn get_place( &self, module: u32, screen: u32, orientation: TopologyOrientation, ) -&gt; Result&lt;(u32, u32), AppErr&gt;</code>
  
; <code>Packable::fn to_pkt(&self, module: u8, screen: u8) -&gt; [u8</code>
+
; <code>Packable::fn to_pkt(&self, module: u8, screen: u8) -&gt; [u8; 4]</code>
  
; <code>Packable::fn from_pkt(pkt: [u8</code>
+
; <code>Packable::fn from_pkt(pkt: [u8; 4]) -&gt; (Self, u8, u8)</code>
  
 
; <code>fn new(val: T) -&gt; Self</code>
 
; <code>fn new(val: T) -&gt; Self</code>
Line 103: Line 103:
 
; <code>Broadcastable::fn broadcast(&mut self, delay: usize) -&gt; Result&lt;(), AppErr&gt;</code>
 
; <code>Broadcastable::fn broadcast(&mut self, delay: usize) -&gt; Result&lt;(), AppErr&gt;</code>
  
; <code>Broadcastable::fn recv(&mut self, pkt: [u8</code>
+
; <code>Broadcastable::fn recv(&mut self, pkt: [u8; 4]) -&gt; Result&lt;(), AppErr&gt;</code>
  
 
; <code>Shuffable::fn rotate(&mut self, dir: &RotationDir) -&gt; Result&lt;(), AppErr&gt;</code>
 
; <code>Shuffable::fn rotate(&mut self, dir: &RotationDir) -&gt; Result&lt;(), AppErr&gt;</code>

Latest revision as of 10:45, 26 July 2026

Official WOWCube SDK documentation. SDK 6.3, Rust API — EXPERIMENTAL (supported; APIs may change). Generated from the CubiOS_Rust_SDK sources — the repository is authoritative; do not edit by hand.

SDK 6.3 · PAWN API: Core · Graphics · Topology · Sound · Motion Sensor · Leaderboard · Splash Screen · Physics · Network · Save · Scramble · Logging
C++: Native API · Application · GFX Engine  ·  Rust: Rust API (experimental)  ·  Changelog


SDK 6.3 · Rust / cubios-sys (raw layer)

Complete reference of the raw layer crate cubios-sys: FFI bindings to the CubiOS engine ABI, thin safe wrappers and the application event loop. Signatures and descriptions are extracted from the crate sources. Engine-function semantics match the C++ native API one-to-one.

ffi::application

The Application trait (11 callbacks), ApplicationContext, TimerController, the event loop (application_init / application_run), Anim<T>, AppErr.

Types: enum AppErr · enum AppPkt · enum RotationDir · struct Anim · struct Timer · trait Application · trait Assetable · trait Mappable · trait Packable · struct MapBase · struct SceneSwitch · trait Broadcastable · trait Shuffable · struct TimerController · struct ApplicationContext

49 public functions:

Application::fn app_context_mut(&mut self) -> &mut ApplicationContext
Application::fn set_timer(&mut self, id: u8, delay: u32, suspended: bool) -> bool
Application::fn start_timer(&mut self, id: u8) -> bool
Application::fn stop_timer(&mut self, id: u8) -> bool
Application::fn kill_timer(&mut self, id: u8)
Application::fn on_init(&mut self) -> Result<(), AppErr>
Called once when the application initializes.
Application::fn on_tick(&mut self, cur_time: u32, delta_time: u32) -> Result<(), AppErr>
Called every frame. `cur_time` is current time in ms, `delta_time` is ms since last tick.
Application::fn on_render(&mut self, screens: &mut [Screen; 3]) -> Result<(), AppErr>
Called to render the current frame. `screens` contains the 3 screens for this module.
Application::fn on_phys_tick(&mut self, screens: &[Screen; 3]) -> Result<(), AppErr>
Called on physics tick. `screens` contains the 3 screens for this module.
Application::fn on_twist(&mut self, twist: &TopologyTwistInfo) -> Result<(), AppErr>
Called when a twist event occurs.
Application::fn on_tap(&mut self, count: u32) -> Result<(), AppErr>
Called when a tap event occurs. `count` is the number of taps.
Application::fn on_pat(&mut self, count: u32) -> Result<(), AppErr>
Called when a pat event occurs. `count` is the number of pats.
Application::fn on_message(&mut self, msg_type: u32, data: &[u8]) -> Result<(), AppErr>
Called when a network message is received from another module.
Application::fn on_external_message(&mut self, data: &[u8]) -> Result<(), AppErr>
Called when an external message is received via BLE.
Application::fn on_timer(&mut self, timer_id: u8) -> Result<(), AppErr>
Called when a timer fires.
Application::fn on_close(&mut self) -> Result<(), AppErr>
Called when the application is closing.
Application::fn get_time(&self) -> u32
Returns current time in milliseconds.
Application::fn get_time_seconds(&self) -> u32
Returns current time in seconds.
Application::fn is_master_module(&self) -> bool
Returns true if this module is the master (module 0).
Application::fn send_network_message(&self, msg_type: u32, data: &[u8])
Sends a network message to other modules.
Application::fn save_state(&self, data: &[u8])
Saves game state to persistent storage.
Application::fn load_state(&self, id: &mut u32, data: &mut [u8]) -> i32
Loads game state from persistent storage. Returns the number of bytes read, or negative on error.
Application::fn send_external_message(&self, msg_type: u32, data: &mut [u8])
Sends an external message via BLE.
Application::fn show_fps_counter(&self, show: bool)
Shows or hides the FPS counter overlay.
Application::fn get_image_assets_count(&self) -> i32
Returns the number of image assets available.
Application::fn get_sound_assets_count(&self) -> i32
Returns the number of sound assets available.
Assetable::fn get_asset_id(asset: &'static str) -> Result<u32, AppErr>
Mappable::fn get_place( &self, module: u32, screen: u32, orientation: TopologyOrientation, ) -> Result<(u32, u32), AppErr>
Packable::fn to_pkt(&self, module: u8, screen: u8) -> [u8; 4]
Packable::fn from_pkt(pkt: [u8; 4]) -> (Self, u8, u8)
fn new(val: T) -> Self
Broadcastable::fn broadcast_part(&mut self, _module: u8, _screen: u8, _delay: usize) -> Result<(), AppErr>
Broadcastable::fn broadcast(&mut self, delay: usize) -> Result<(), AppErr>
Broadcastable::fn recv(&mut self, pkt: [u8; 4]) -> Result<(), AppErr>
Shuffable::fn rotate(&mut self, dir: &RotationDir) -> Result<(), AppErr>
Shuffable::fn shuffle(&mut self, algo: &[RotationDir]) -> Result<(), AppErr>
fn new(scenes: &'static [usize], start_time: usize) -> Self
fn next_scene(&mut self)
fn set_scene(&mut self, id: u8) -> Result<(), AppErr>
fn animate(&mut self)
fn new() -> Self
Create a new TimerController with no active timers.
fn set_timer(&mut self, id: u8, delay: u32, suspended: bool) -> bool
fn start_timer(&mut self, id: u8) -> bool
fn stop_timer(&mut self, id: u8) -> bool
fn kill_timer(&mut self, id: u8)
fn delta_time(&self) -> u32
fn new() -> Self
Create a new ApplicationContext.
fn application_init<T: Application>(app: &mut T, cid: u32)
fn application_run<T: Application>(app: &mut T)

ffi::comm

Inter-module packets and UART lines, BLE external data, time, user name, state save/load, RNG, logging (log_alog_v), tap.

22 public functions:

fn send_message(line: u32, pkt: *const u8, size: u32) -> i32
fn send_message_to(line: u32, dest: u32, pkt: *const u8, size: u32) -> i32
fn recv_message( line: u32, size: u32, pkt_info: *mut u32, pkt: *mut u8, rx_size: *mut u32, ) -> i32
fn send_packet(packet_type: u32, pkt: &[u8]) -> i32
Send a packet (new API in SDK 6.3)
fn recv_packet(size: u32, packet_type: *mut u32, pkt: *mut u8) -> i32
Receive a packet (new API in SDK 6.3) Returns the number of bytes received, or negative on error. The packet type is written to `packet_type`.
fn get_time() -> i32
fn get_user_name(buffer: &mut [u8]) -> i32
fn toggle_debug_info() -> i32
fn save_state(data: &[u8]) -> i32
fn load_state(id: &mut u32, data: &mut [u8]) -> i32
Load saved state Returns the number of bytes loaded, or negative on error. The save ID is written to `id`.
fn load_state_legacy(data: &mut [u8]) -> i32
Load saved state (legacy API without ID) Note: This ignores the save ID. Use `load_state` for full functionality.
fn random_range(min: u32, max: u32) -> i32
fn get_app_version() -> AppVersion
Get the application version
fn log_a(text: &str) -> i32
fn log_e(text: &str) -> i32
fn log_w(text: &str) -> i32
fn log_i(text: &str) -> i32
fn log_d(text: &str) -> i32
fn log_v(text: &str) -> i32
fn get_tap() -> i32
fn send_ble_data(data_type: u32, pkt: &mut [u8]) -> i32
Send BLE data
fn recv_ble_data(pkt: &mut [u8]) -> i32
Receive BLE data

ffi::gfx

Immediate-mode drawing: clear, primitives, text, images, baked images, sub-images, shaders, QR, render target, cache.

26 public functions:

fn get_asset_id(sprite_name: &str) -> i32
fn clear(color: u32) -> i32
fn draw_text( x: i32, y: i32, scale: u32, angle: u32, align: TextAlign, color: u32, text: &str, ) -> i32
fn draw_point(x: i32, y: i32, color: u32) -> i32
fn draw_circle(x: u32, y: u32, radius: u32, width: u32, color: u32) -> i32
fn draw_solid_circle(x: u32, y: u32, radius: u32, color: u32) -> i32
Deprecated: use `set_fill_shader` + `draw_circle` instead
fn draw_arc( x: i32, y: i32, radius: u32, width: u32, angle0: u32, angle1: u32, color: u32, ) -> i32
fn draw_sector(x: i32, y: i32, radius: u32, angle0: u32, angle1: u32, color: u32) -> i32
fn draw_line(x0: i32, y0: i32, x1: i32, y1: i32, thickness: u32, color: u32) -> i32
fn draw_rectangle(x: i32, y: i32, w: i32, h: i32, color: u32) -> i32
fn bake_image( id: SpriteId, width: u32, height: u32, format: GfxPixelFormat, overwrite: bool, ) -> i32
Bake an image to an offscreen buffer # Arguments * `id` - Sprite ID to bake * `width` - Width of the baked image * `height` - Height of the baked image * `format` - Pixel format for the baked image * `overwrite` - Whether to overwrite existing baked image
fn remove_baked_image(id: SpriteId) -> i32
Remove a previously baked image
fn set_render_target(display: u8) -> i32
fn draw_image( id: SpriteId, x: i32, y: i32, opacity: u32, color_key: u32, scale_x: u32, scale_y: u32, angle: u32, mirror: GfxMirror, ) -> i32
fn draw_baked_image( x: i32, y: i32, opacity: u32, color_key: u32, scale_x: u32, scale_y: u32, angle: u32, mirror: GfxMirror, id: SpriteId, ) -> i32
fn draw_sub_image( id: SpriteId, x: i32, y: i32, rect_x: u32, rect_y: u32, rect_w: u32, rect_h: u32, opacity: u32, color_key: u32, scale_x: u32, scale_y: u32, angle: u32, mirror: GfxMirror, ) -> i32
Draw a sub-region of a sprite (for sprite atlases)
fn draw_qr_code( x: i32, y: i32, size: u32, color0: u32, color1: u32, angle: u32, id: u32, text: &str, ) -> i32
Draw a QR code
fn render() -> i32
fn clear_cache() -> i32
fn cache_images(sprite_ids: &[SpriteId]) -> i32
fn get_assets_count() -> i32
Get the total number of image assets
fn set_fps_window(size: u32) -> i32
Set the FPS counter window size
fn set_fill_shader(color: u32) -> i32
Set a solid fill shader When active, drawing operations will use this color to fill shapes.
fn set_linear_gradient_shader( x0: u32, y0: u32, x1: u32, y1: u32, color0: u32, color1: u32, ) -> i32
Set a linear gradient shader # Arguments * `x0`, `y0` - Start point of the gradient * `x1`, `y1` - End point of the gradient * `color0` - Start color * `color1` - End color
fn set_radial_gradient_shader(x0: u32, y0: u32, radius: u32, color0: u32, color1: u32) -> i32
Set a radial gradient shader # Arguments * `x0`, `y0` - Center point of the gradient * `radius` - Radius of the gradient * `color0` - Center color * `color1` - Edge color
fn remove_shader() -> i32
Remove the active shader

ffi::topology

Facelets, faces, places, orientation, twists, assembly check.

15 public functions:

fn get_cuben() -> u32
fn get_adjacent_facelet( module: u32, screen: u32, direction: TopologyNeighbour, result: *mut TopologyFaceletInfo, ) -> i32
fn get_reversed_face(face: u32) -> Option<u32>
fn get_facelet( face: u32, position: u32, mode: TopologyOrientation, result: *mut TopologyFaceletInfo, ) -> i32
fn get_place( module: u32, screen: u32, mode: TopologyOrientation, result: *mut TopologyPlace, ) -> i32
fn get_opposite_facelet(module: u32, screen: u32, result: *mut TopologyFaceletInfo) -> i32
fn get_angle(module: u32, screen: u32, mode: TopologyOrientation) -> i32
fn get_facelet_orientation(module: u32, screen: u32) -> i32
fn get_place_orientation(face: u32, position: u32) -> i32
fn get_face(orientation: u32) -> i32
fn is_assembled() -> bool
fn get_twist(twist: *mut TopologyTwistInfo) -> i32
fn debug_get_face(module: u32, screen: u32) -> i32
fn debug_get_position(module: u32, screen: u32) -> i32
fn debug_get_horizontal() -> i32

ffi::sound

Sound asset id, play, cache, stop, status.

6 public functions:

fn get_asset_id(sound_name: &str) -> i32
fn play(sound_id: SoundId, volume: u32) -> i32
fn cache_sounds(sound_ids: &[SoundId]) -> i32
fn is_playing() -> bool
Check if a sound is currently playing
fn stop() -> i32
Stop the currently playing sound
fn get_assets_count() -> i32
Get the total number of sound assets

ffi::motion

Per-display accelerometer and gyroscope.

8 public functions:

fn get_face_accel_x(display: u32) -> i32
Get raw accelerometer value along the screen-local X-axis (horizontal right). At rest, this reads the X-component of gravity in the screen's coordinate frame. During motion, reads gravity + linear acceleration. # Parameters - `display`: Screen index (0–23). All 3 screens on a module return the same physical measurement, transformed to screen-local coordinates.
fn get_face_accel_y(display: u32) -> i32
Get raw accelerometer value along the screen-local Y-axis (vertical up). See [`get_face_accel_x`] for details on data format and coordinate frame.
fn get_face_accel_z(display: u32) -> i32
Get raw accelerometer value along the screen-local Z-axis (toward cube center). When this screen faces up, Z reads approximately -1g (gravity pulls toward center). When this screen faces down, Z reads approximately +1g. See [`get_face_accel_x`] for details on data format and coordinate frame.
fn get_face_gyro_x(display: u32) -> i32
Get raw gyroscope value for rotation around the screen-local X-axis. Measures angular velocity of the screen pitching up/down. At rest, reads approximately zero. Sign convention: positive = clockwise when looking along the positive X-axis direction (per SDK docs, unverified). # Parameters - `display`: Screen index (0–23). Same sensor sharing as accelerometer.
fn get_face_gyro_y(display: u32) -> i32
Get raw gyroscope value for rotation around the screen-local Y-axis. Measures angular velocity of the screen yawing left/right. See [`get_face_gyro_x`] for details.
fn get_face_gyro_z(display: u32) -> i32
Get raw gyroscope value for rotation around the screen-local Z-axis. Measures angular velocity of the screen spinning in-plane (like a wheel). See [`get_face_gyro_x`] for details.
fn get_face_accel(display: u32) -> (i32, i32, i32)
Get all 3 accelerometer axes for a screen in one call. Returns `(x, y, z)` in screen-local coordinates. Equivalent to calling [`get_face_accel_x`], [`get_face_accel_y`], and [`get_face_accel_z`] separately. # Parameters - `display`: Screen index (0–23).
fn get_face_gyro(display: u32) -> (i32, i32, i32)
Get all 3 gyroscope axes for a screen in one call. Returns `(x, y, z)` angular velocities in screen-local coordinates. Equivalent to calling [`get_face_gyro_x`], [`get_face_gyro_y`], and [`get_face_gyro_z`] separately. # Parameters - `display`: Screen index (0–23).

ffi::leaderboard

Leaderboard info and score table.

3 public functions:

fn get_info(info: *mut LbInfo) -> i32
fn get_info_safe() -> LbInfo
Get leaderboard info with safe interface
fn get_score(lead_table_bin: &mut [u8]) -> i32

ffi::event

Pending-event mask (Event, get_list).

Types: enum Event — Event flags returned by `get_list()`

2 public functions:

fn get_list() -> i32
fn has_event(event_list: i32, event: Event) -> bool
Check if a specific event is set in the event list

ffi::network_message

Bit-packed serializer for inter-module messages.

Types: struct NetworkMessage — Bit-packed network message for inter-module communication. Allows packing multiple values into a compact byte buffer using variable bit widths for efficient network transmission.

17 public functions:

fn new() -> Self
Create a new empty network message.
fn from_data(data: &[u8]) -> Self
Create a network message from existing data.
fn reset(&mut self, zero: bool)
Reset the message position. If `zero` is true, also clear the buffer.
fn get_data(&self) -> &[u8]
Get the underlying data buffer and used length.
fn can_read(&self, bits: usize) -> bool
Returns true if at least `bits` more bits can be read from the current position.
fn write_int(&mut self, value: u32, bits: u8)
Write an unsigned integer with specified bit width (1-32 bits). This writes raw bits without sign handling. For signed values that need sign extension when read back, use [`write_signed_int`](Self::write_signed_int). # Arguments * `value` - The unsigned value to write (only the lower `bits` bits are used) * `bits` - Number of bits to write (1-32, clamped if larger) # Note on C++ SDK difference The C++ `WriteInt` uses `int` (signed), but performs unsigned bit operations. This Rust version uses `u32` to make the unsigned semantics explicit.
fn write_byte(&mut self, value: u8)
Write a single byte (8 bits).
fn write_signed_int(&mut self, value: i32, bits: u8)
Write a signed integer with specified bit width.
fn write_bool(&mut self, value: bool)
Write a boolean (1 bit).
fn write_float(&mut self, value: f32)
Write a 32-bit float.
fn read_int(&mut self, bits: u8) -> u32
Read an unsigned integer with specified bit width. This reads raw bits without sign extension. For signed values that were written with [`write_signed_int`](Self::write_signed_int), use [`read_signed_int`](Self::read_signed_int) to properly sign-extend. # Arguments * `bits` - Number of bits to read (1-32, clamped if larger) # Returns The unsigned value read from the message buffer. # Note on C++ SDK difference The C++ `ReadInt` returns `int` (signed), but performs unsigned bit operations. This Rust version returns `u32` to make the unsigned semantics explicit.
fn read_byte(&mut self) -> u8
Read a single byte.
fn read_signed_int(&mut self, bits: u8) -> i32
Read a signed integer with specified bit width.
fn read_bool(&mut self) -> bool
Read a boolean.
fn read_float(&mut self) -> f32
Read a 32-bit float.
fn position(&self) -> usize
Get current bit position.
fn can_write(&self, bits: usize) -> bool
Check if there's enough space to write `bits` more bits.

ffi::save_message

Bit-packed serializer for the persistent save buffer.

Types: struct SaveMessage — Bit-packed save message for game state persistence. Allows packing multiple values into a compact byte buffer using variable bit widths for efficient save data storage.

18 public functions:

fn new() -> Self
Create a new empty save message.
fn from_data(data: &[u8]) -> Self
Create a save message from existing data.
fn reset(&mut self, zero: bool)
Reset the message position. If `zero` is true, also clear the buffer.
fn get_data(&self) -> &[u8]
Get the underlying data buffer (only the used portion).
fn get_buffer_mut(&mut self) -> &mut [u8]
Get the full buffer for loading saved data.
fn write_int(&mut self, value: u32, bits: u8)
Write an unsigned integer with specified bit width (1-32 bits). This writes raw bits without sign handling. For signed values that need sign extension when read back, use [`write_signed_int`](Self::write_signed_int). # Arguments * `value` - The unsigned value to write (only the lower `bits` bits are used) * `bits` - Number of bits to write (1-32, clamped if larger) # Note on C++ SDK difference The C++ `WriteInt` uses `int` (signed), but performs unsigned bit operations. This Rust version uses `u32` to make the unsigned semantics explicit.
fn write_byte(&mut self, value: u8)
Write a single byte (8 bits).
fn write_signed_int(&mut self, value: i32, bits: u8)
Write a signed integer with specified bit width.
fn write_bool(&mut self, value: bool)
Write a boolean (1 bit).
fn write_float(&mut self, value: f32)
Write a 32-bit float.
fn read_int(&mut self, bits: u8) -> u32
Read an unsigned integer with specified bit width. This reads raw bits without sign extension. For signed values that were written with [`write_signed_int`](Self::write_signed_int), use [`read_signed_int`](Self::read_signed_int) to properly sign-extend. # Arguments * `bits` - Number of bits to read (1-32, clamped if larger) # Returns The unsigned value read from the save buffer. # Note on C++ SDK difference The C++ `ReadInt` returns `int` (signed), but performs unsigned bit operations. This Rust version returns `u32` to make the unsigned semantics explicit.
fn read_byte(&mut self) -> u8
Read a single byte.
fn read_signed_int(&mut self, bits: u8) -> i32
Read a signed integer with specified bit width.
fn read_bool(&mut self) -> bool
Read a boolean.
fn read_float(&mut self) -> f32
Read a 32-bit float.
fn position(&self) -> usize
Get current bit position.
fn can_write(&self, bits: usize) -> bool
Check if there's enough space to write `bits` more bits.
fn set_used_bits(&mut self, bits: usize)
Set the number of used bits (for after loading data).

ffi::screen

Low-level screen descriptor (id, angle, face, position) + create_screens().

Types: struct Screen — Represents a screen on a WOWCube module. Each module has 3 screens. This struct provides access to screen properties like position, orientation, and display ID for rendering purposes.

7 public functions:

fn new(display_id: u8) -> Self
Creates a new Screen for the given display ID on this module.
fn id(&self) -> u8
Returns the display ID (0-2).
fn angle(&self) -> u32
Returns the current rotation angle.
fn position(&self) -> u32
Returns the position in the topology.
fn face(&self) -> i32
Returns the face this screen is on.
fn update_from_topology(&mut self, module: u32, orientation: TopologyOrientation)
Updates screen topology information from the system.
fn create_screens() -> [Screen; 3]
Creates an array of 3 screens for a module, initialized with display IDs 0, 1, 2.

ffi::math

Vec2/Vec2i, Color, Transform, Rect2, trigonometry and fixed-point helpers (no_std, libm).

Types: struct Vec2 — 2D vector with floating-point components. · struct Vec2i — 2D vector with integer components. · struct Color — ARGB color with 8-bit components. Stored as a packed u32 in ARGB format: 0xAARRGGBB · struct Transform — Transform with position, rotation, scale, and mirroring. · struct Rect2 — 2D rectangle defined by top-left and dimensions.

57 public functions:

fn log2(f: f32) -> f32
Log base 2.
fn iclamp(val: i32, min_val: i32, max_val: i32) -> i32
Clamp an integer value between min and max.
fn acos(x: f32) -> f32
Arc cosine with value clamping to [-1, 1].
fn asin(x: f32) -> f32
Arc sine with value clamping to [-1, 1].
fn sqrt(x: f32) -> f32
Safe square root (negative values return 0).
fn fequal(f0: f32, f1: f32, tol: f32) -> bool
Fuzzy floating point equality check.
fn fless(f0: f32, f1: f32, tol: f32) -> bool
Fuzzy floating point less-than check.
fn fgreater(f0: f32, f1: f32, tol: f32) -> bool
Fuzzy floating point greater-than check.
fn ftol(val: f32) -> i32
Fast float to int conversion (truncates). Note: This is a portable implementation that matches the C++ SDK behavior.
fn smooth(new_val: f32, cur_val: f32, max_change: f32) -> f32
Smooth a value towards a target using max change per step.
fn clamp(val: f32, lower: f32, upper: f32) -> f32
Clamp a float value between lower and upper bounds.
fn saturate(val: f32) -> f32
Saturate a value (clamp between 0.0 and 1.0).
fn deg2rad(d: f32) -> f32
Convert degrees to radians.
fn rad2deg(r: f32) -> f32
Convert radians to degrees.
fn n_abs(a: f32) -> f32
Get the absolute value.
fn n_sgn(a: f32) -> i32
Get the sign of a value (-1 or 1).
fn n_max<T: PartialOrd>(a: T, b: T) -> T
Return the maximum of two values.
fn n_min<T: PartialOrd>(a: T, b: T) -> T
Return the minimum of two values.
fn lerp(x: f32, y: f32, l: f32) -> f32
Linearly interpolate between two values. Returns `x + l * (y - x)`.
fn rand_get_seed() -> u32
Get the current random seed.
fn rand_set_seed(s: u32)
Set the random seed.
fn rand() -> u32
Generate a random u32 using LCG algorithm.
fn rand2() -> f32
Return a pseudo random number between 0.0 and 1.0.
fn rand_int(n: i32) -> i32
Return a random integer in range [0, n].
fn rand_real() -> f32
Return a random float in [0.0, 1.0].
fn new(x: f32, y: f32) -> Self
Create a new vector.
fn zero() -> Self
Zero vector.
fn set(&mut self, x: f32, y: f32)
Set components.
fn len(&self) -> f32
Calculate length.
fn normalize(&mut self)
Normalize in place.
fn normalized(&self) -> Self
Return normalized copy.
fn dot(&self, other: &Self) -> f32
Dot product.
fn new(x: i16, y: i16) -> Self
Create a new vector.
fn zero() -> Self
Zero vector.
fn rgb(r: u8, g: u8, b: u8) -> Self
Create from RGB (alpha = 255).
fn rgba(r: u8, g: u8, b: u8, a: u8) -> Self
Create from RGBA.
fn from_u32(value: u32) -> Self
Create from packed u32 value (0xAARRGGBB format).
fn value(&self) -> u32
Get the packed u32 value.
fn r(&self) -> u8
Get red component.
fn g(&self) -> u8
Get green component.
fn b(&self) -> u8
Get blue component.
fn a(&self) -> u8
Get alpha component.
fn a_f32(&self) -> f32
Get alpha as float (0.0 - 1.0).
fn set_r(&mut self, r: u8)
Set red component.
fn set_g(&mut self, g: u8)
Set green component.
fn set_b(&mut self, b: u8)
Set blue component.
fn set_a(&mut self, a: u8)
Set alpha component.
fn set_a_f32(&mut self, a: f32)
Set alpha from float (0.0 - 1.0).
fn new(x: f32, y: f32) -> Self
Create a new transform at position.
fn with_rotation(x: f32, y: f32, rotation: i32) -> Self
Create with position and rotation.
fn with_scale(x: f32, y: f32, rotation: i32, scale: u32) -> Self
Create with position, rotation, and uniform scale.
fn safe_rotation(&self) -> i32
Get rotation normalized to 0-359.
fn set_scale(&mut self, scale: u32)
Set uniform scale.
fn new(x: i16, y: i16, w: i16, h: i16) -> Self
Create a new rectangle.
fn contains(&self, px: i16, py: i16) -> bool
Check if a point is inside the rectangle.
fn contains_point(&self, p: Vec2i) -> bool
Check if point (as Vec2i) is inside.
fn center(&self) -> Vec2i
Get the center point.

ffi::types

ABI enums and structs (TopologyFaceletInfo, TopologyTwistInfo, TextAlign, GfxMirror, …).

Types: enum UartId — UART line identifiers · enum GfxPixelFormat — Pixel format for baked images · enum GfxMirror — Mirror mode for sprites · enum TopologyNeighbour — Topology neighbor direction · enum TopologyOrientation — Topology orientation mode · enum TopologyTwist — Twist direction for cube rotations · enum TextAlign — Text alignment options · enum TopologyLocation — Topology face location · enum LogLevel — Log level for debug output · struct TopologyFaceletInfo — Information about a facelet in the topology · struct TopologyPlace — Place information (face and position) · struct TopologyTwistInfo — Twist event information · struct LbInfo — Leaderboard information · struct GfxParticle — Particle effect parameters · struct AppVersion — Application version (packed bitfield in C++)

4 public functions:

fn from_u32(value: u32) -> Self
Converts a u32 value to a GfxMirror variant. Returns `GfxMirror::None` for invalid values.
fn patch(&self) -> u16
Extract patch version (bits 0-15)
fn minor(&self) -> u8
Extract minor version (bits 16-19)
fn major(&self) -> u8
Extract major version (bits 20-23)

ffi::constants

Platform constants (screen size, module counts, buffer limits, CUBE_N).