Medius - BindingsTypes & errors

Types & errors

Every C struct, enum, and status code, by table

The Medius* types and MEDIUS_* enumerators from medius.h. The calls that produce and consume them are on API index; streams on Streams. What each value means lives with the canonical type docs in the Rust Library and Native API sections.

How C models the enums. Each enum has a fixed-width backing: MediusStatus is int32_t; every other enum is uint8_t. On C23 and C++ the tag carries that underlying type directly (enum MediusButton : uint8_t); on C99 the tag is typedef'd to the integer and you pass the prefixed enumerators (MEDIUS_BUTTON_LEFT). Structs are plain PODs: pass by value, read fields directly. Nothing is heap-allocated, so there's nothing to free per value; only the opaque handles have a *_free.

Sizing constants

Fixed-cap arrays sized to the wire limits

The event, lock, and log PODs embed fixed-cap arrays sized to the protocol's own limits, with a count field saying how many slots are live. char arrays are NUL-terminated.

MacroValueCaps
MEDIUS_MAX_USAGES256MediusUsageEvent.usages, MediusClipStatus.held
MEDIUS_MAX_LOCKS256MediusLocks.entries
MEDIUS_MAX_PATH512MediusPortInfo.path
MEDIUS_MAX_LOG_TEXT512MediusLogLine.text
MEDIUS_MAX_PRODUCT128MediusDeviceInfo.product
MEDIUS_MAX_SERIAL128MediusPortInfo.serial
MEDIUS_MAX_NAME33MediusVersion.name
MEDIUS_CLIP_TRIG_MAX8MediusClipSettings.triggers

Enums

uint8_t-backed selectors (MediusStatus is int32_t)

Each value is a wire byte; the canonical meaning lives on Enums. The *Kind enums (and MediusClass) tag which arm of a built value (MediusUsage, MediusMotion, MediusCatchEvent) is populated.

MediusDeviceKind

The cloned device's primary kind
enum MediusDeviceKind : uint8_t

The kind field of a MediusDeviceInfo, from the cloned device's Boot-interface protocol. Also what medius_device_find_mouse_box / _find_keyboard_box select on. See DeviceKind.

EnumeratorValueMeaning
MEDIUS_DEVICE_KIND_UNKNOWN0Neither a Boot keyboard nor mouse.
MEDIUS_DEVICE_KIND_KEYBOARD1The device is a keyboard.
MEDIUS_DEVICE_KIND_MOUSE2The device is a mouse.

MediusButton

A mouse button id
enum MediusButton : uint8_t   /* values match the firmware button id */

The button an inject call drives. Ids on Usage IDs.

EnumeratorValueMeaning
MEDIUS_BUTTON_LEFT0Left button.
MEDIUS_BUTTON_RIGHT1Right button.
MEDIUS_BUTTON_MIDDLE2Middle button.
MEDIUS_BUTTON_SIDE13First thumb button.
MEDIUS_BUTTON_SIDE24Second thumb button.

MediusAction

The press / release tri-state
enum MediusAction : uint8_t

The override action shared by inject calls, whether a button, key, or media usage. See the injection model.

EnumeratorValueMeaning
MEDIUS_ACTION_SOFT_RELEASE0Drop the box's override, press or force; a physical hold stays down.
MEDIUS_ACTION_PRESS1Force the input down.
MEDIUS_ACTION_FORCE_RELEASE2Force the input up, masking a physical hold.

MediusClass

Which arm of a MediusUsage is set
enum MediusClass : uint8_t

The kind tag of a MediusUsage you build with medius_usage_button/_key/_media.

EnumeratorValueMeaning
MEDIUS_CLASS_BUTTON0id is a mouse button id.
MEDIUS_CLASS_KEY1id is a HID keyboard usage.
MEDIUS_CLASS_MEDIA2id is a 16-bit Consumer usage.

MediusMotionKind

Which arm of a MediusMotion is set
enum MediusMotionKind : uint8_t

Tags the MediusMotion you build with medius_motion_cursor/_wheel. See Move.

EnumeratorValueMeaning
MEDIUS_MOTION_KIND_CURSOR0dx/dy apply.
MEDIUS_MOTION_KIND_WHEEL1wheel applies.

MediusLockTargetKind

Which input a MediusLockTarget addresses
enum MediusLockTargetKind : uint8_t

The kind of a MediusLockTarget. See Lock.

EnumeratorValueMeaning
MEDIUS_LOCK_TARGET_KIND_X0Horizontal movement.
MEDIUS_LOCK_TARGET_KIND_Y1Vertical movement.
MEDIUS_LOCK_TARGET_KIND_WHEEL2Scroll wheel.
MEDIUS_LOCK_TARGET_KIND_USAGE3A momentary usage (the struct's usage field selects which).

MediusLockDirection

Which edge a lock applies to
enum MediusLockDirection : uint8_t

For an axis or wheel it's a sign; for a usage it's an edge. See LOCK.

EnumeratorValueMeaning
MEDIUS_LOCK_DIRECTION_BOTH0Both signs, or press and release.
MEDIUS_LOCK_DIRECTION_POSITIVE1Axis positive (+), or a usage press.
MEDIUS_LOCK_DIRECTION_NEGATIVE2Axis negative (-), or a usage release.

MediusEdge

Which edge of a trigger usage fires a clip binding
enum MediusEdge : uint8_t

The edge of a MediusClipTrigger's on usage that runs its action. Same wire values as MediusLockDirection. See Clip.

EnumeratorValueMeaning
MEDIUS_EDGE_BOTH0Both press and release.
MEDIUS_EDGE_PRESS1The press edge only.
MEDIUS_EDGE_RELEASE2The release edge only.

MediusClipAction

The engine action a clip trigger drives
enum MediusClipAction : uint8_t

What a bound MediusClipTrigger does to the clip on its edge; the same verbs as the medius_clip_start/_stop/... calls. See Clip.

EnumeratorValueMeaning
MEDIUS_CLIP_ACTION_START0Rewind and play (resume from a pause).
MEDIUS_CLIP_ACTION_STOP1Stop and release held input and the auto-lock.
MEDIUS_CLIP_ACTION_PAUSE2Halt mid-clip, retaining the cursor and held input.
MEDIUS_CLIP_ACTION_RESUME3Continue from the paused cursor.
MEDIUS_CLIP_ACTION_RESTART4Force a rewind and play, even mid-playback.
MEDIUS_CLIP_ACTION_TOGGLE5Play if idle/paused, stop if playing.

MediusBlanket

A whole-group lock selector
enum MediusBlanket : uint8_t

A whole input group: which one medius_device_lock_all/_unlock_all block in one call, and the scope medius_clip_set_autolock auto-locks while a clip plays. See Lock.

The values are ABI-local ordinals (matching the crate's Blanket order), not the CLIP_LOCK_* wire bits.

EnumeratorValueMeaning
MEDIUS_BLANKET_AIM0The X and Y cursor axes.
MEDIUS_BLANKET_WHEEL1The wheel.
MEDIUS_BLANKET_BUTTONS2Every mouse button.
MEDIUS_BLANKET_KEYS3Every keyboard key and modifier.
MEDIUS_BLANKET_MEDIA4Every media (Consumer) usage.

MediusLedTarget

Which chip's status LED to drive
enum MediusLedTarget : uint8_t

See LED.

EnumeratorValueMeaning
MEDIUS_LED_TARGET_DEVICE0The device chip's own LED.
MEDIUS_LED_TARGET_HOST1The host chip's LED, relayed over the inter-chip link.
MEDIUS_LED_TARGET_BOTH2Both LEDs at once.

MediusLedMode

What to drive the LED to
enum MediusLedMode : uint8_t

See LED. Solid / Blink use the command's level.

EnumeratorValueMeaning
MEDIUS_LED_MODE_AUTO0Restore the chip's own status display.
MEDIUS_LED_MODE_OFF1LED dark.
MEDIUS_LED_MODE_SOLID2Lit steadily at level.
MEDIUS_LED_MODE_BLINK3Blinks at level.

MediusRebootTarget

Which chip to restart, and how
enum MediusRebootTarget : uint8_t

See Admin.

EnumeratorValueMeaning
MEDIUS_REBOOT_TARGET_DEVICE_DOWNLOAD0Device chip into ROM download mode (flash over the serial link).
MEDIUS_REBOOT_TARGET_HOST_DOWNLOAD1Host chip into ROM download mode (flash over its own USB).
MEDIUS_REBOOT_TARGET_DEVICE_RUN2Restart the device chip and run its firmware.
MEDIUS_REBOOT_TARGET_HOST_RUN3Restart the host chip and run its firmware.

MediusEmitMode

What paces injected motion
enum MediusEmitMode : uint8_t

See Options.

EnumeratorValueMeaning
MEDIUS_EMIT_MODE_LEARNED0Pace to the mouse's learnt native report rate (the default).
MEDIUS_EMIT_MODE_INTERVAL1Pace to the cloned mouse's declared poll rate (its bInterval).
MEDIUS_EMIT_MODE_FIXED2Pace to a fixed rate in Hz (snapped to 1000/n, capped 1 kHz).

MediusCatchEventKind

Which arm of a MediusCatchEvent is set
enum MediusCatchEventKind : uint8_t

Tells you which member of the MediusCatchEvent union to read. See Catch.

EnumeratorValueRead
MEDIUS_CATCH_EVENT_KIND_MOTION0data.motion
MEDIUS_CATCH_EVENT_KIND_USAGES1data.usages

MediusLogLevel

Severity tag on a log line
enum MediusLogLevel : uint8_t

The severity of a MediusLogLine. See Logs & counters.

EnumeratorValueMeaning
MEDIUS_LOG_LEVEL_ERROR0A failure the box couldn't recover from.
MEDIUS_LOG_LEVEL_WARN1Something off that the box handled.
MEDIUS_LOG_LEVEL_INFO2Normal operational notices.
MEDIUS_LOG_LEVEL_DEBUG3Detail for diagnosing a problem.
MEDIUS_LOG_LEVEL_VERBOSE4The finest-grained trace output.

MediusCatchMask

Which physical reports raise an event
typedef uint8_t MediusCatchMask;   /* OR the MEDIUS_CATCH_MASK_* bits */

The subscription you hand to medius_device_catch_events. See Catch.

MacroBitTriggers on
MEDIUS_CATCH_MASK_MOTION0x01The mouse moved (dx/dy).
MEDIUS_CATCH_MASK_WHEEL0x02The wheel turned.
MEDIUS_CATCH_MASK_BUTTONS0x04A button changed.
MEDIUS_CATCH_MASK_KEYS0x08A keyboard key changed.
MEDIUS_CATCH_MASK_MEDIA0x10A media key changed.
MEDIUS_CATCH_MASK_ALL0x1FEvery class.

MediusKey

A HID keyboard/keypad usage
typedef uint8_t MediusKey;   /* modifiers are 0xE0 to 0xE7 */

A raw HID keyboard usage passed to the key calls. Pass any usage byte, or one of the MEDIUS_KEY_* macros. The full set of usages is on Usage IDs.

Macro groupExampleUsage
LettersMEDIUS_KEY_A .. MEDIUS_KEY_Z4 to 29
DigitsMEDIUS_KEY_1 .. MEDIUS_KEY_030 to 39
FunctionMEDIUS_KEY_F1 .. MEDIUS_KEY_F1258 to 69
Editing / navMEDIUS_KEY_ENTER, _ESCAPE, _TAB, _SPACE, _INSERT, _HOME, _DELETE, arrowsvarious
ModifiersMEDIUS_KEY_LEFT_CTRL .. MEDIUS_KEY_RIGHT_GUI224 to 231 (0xE0 to 0xE7)

MediusMediaKey

A 16-bit HID Consumer usage
typedef uint16_t MediusMediaKey;

A raw Consumer usage passed to the media calls. Pass any 16-bit usage, or a MEDIUS_MEDIA_* macro. The full set is on Usage IDs.

MacroUsageMacroUsage
MEDIUS_MEDIA_PLAY_PAUSE205MEDIUS_MEDIA_MUTE226
MEDIUS_MEDIA_NEXT_TRACK181MEDIUS_MEDIA_VOLUME_UP233
MEDIUS_MEDIA_PREV_TRACK182MEDIUS_MEDIA_VOLUME_DOWN234
MEDIUS_MEDIA_STOP183MEDIUS_MEDIA_PLAY176
MEDIUS_MEDIA_PAUSE177

MediusFrameType

A wire frame TYPE byte (mock only)
enum MediusFrameType : uint8_t   /* always defined; read only by the mock recorder */

The TYPE byte of a wire frame, used with the mock recorder (medius_mock_saw / medius_mock_recorded_frame). See the mock feature.

EnumeratorValueEnumeratorValue
MEDIUS_FRAME_TYPE_MOVE1MEDIUS_FRAME_TYPE_LOCK10
MEDIUS_FRAME_TYPE_INJECT3MEDIUS_FRAME_TYPE_CATCH11
MEDIUS_FRAME_TYPE_RESET4MEDIUS_FRAME_TYPE_MOTION_EVENT12
MEDIUS_FRAME_TYPE_QUERY5MEDIUS_FRAME_TYPE_USAGE_EVENT15
MEDIUS_FRAME_TYPE_RESP6MEDIUS_FRAME_TYPE_OPTION17
MEDIUS_FRAME_TYPE_REBOOT_DL7MEDIUS_FRAME_TYPE_CLIP_APPEND18
MEDIUS_FRAME_TYPE_LOG8MEDIUS_FRAME_TYPE_CLIP_CTRL19
MEDIUS_FRAME_TYPE_LED9MEDIUS_FRAME_TYPE_CLIP_SET20
MEDIUS_FRAME_TYPE_CLIP_TRIGGER21

Argument structs

Tagged values you build, then pass in

Three small PODs you build with a helper and hand to a call. The medius_*_* constructors set the kind tag and the right field for you.

MediusUsage

A momentary usage for inject

What medius_device_inject drives. Build with medius_usage_button(...), _key(...), or _media(...); id holds the button id or usage per kind. See Inject.

FieldC typeMeaning
kindMediusClassWhich class id names.
iduint16_tButton id, key usage, or media usage.

MediusMotion

A relative axis for move_axis

What medius_device_move_axis drives. Build with medius_motion_cursor(dx, dy) or medius_motion_wheel(delta). See Move.

FieldC typeMeaning
kindMediusMotionKindCursor vs wheel.
dxint16_tX movement (Cursor only).
dyint16_tY movement (Cursor only).
wheelint16_tScroll delta (Wheel only).

MediusLockTarget

What a lock acts on

Passed to medius_device_lock / _unlock. Build it with medius_lock_target_axis or medius_lock_target_usage; usage is read only when kind is USAGE. See Lock.

FieldC typeMeaning
kindMediusLockTargetKindX, Y, Wheel, or Usage.
usageMediusUsageThe button, key, or media usage, when kind == USAGE.

Query values

PODs written through a query's out-param

Each medius_device_query_* / _caps / _counters call fills one of these by value. Canonical field docs are on Structs; query semantics on Requests.

MediusVersion

Decoded firmware version and box name

From medius_device_query_version. Set the box's name with medius_device_set_name.

FieldC typeMeaning
proto_veruint8_tWire-protocol version the firmware speaks.
fw_majoruint8_tFirmware major version.
fw_minoruint8_tFirmware minor version.
fw_patchuint8_tFirmware patch version.
macuint8_t[6]The device chip's base MAC, a stable per-box id.
namechar[MEDIUS_MAX_NAME]The box's human-readable name (NUL-terminated; a synthesized default when unset).

MediusHealth

Box readiness flags (each 0 or 1)

From medius_device_query_health.

FieldC typeTrue (1) when
link_upuint8_tThe link to the host chip is up.
mouse_attacheduint8_tA real mouse is plugged in.
clone_configureduint8_tThe PC has set up the cloned mouse.
injection_activeuint8_tAt least one injected button or move is held.
rate_confidentuint8_tThe native-rate estimator window is full.
lock_onuint8_tAt least one input lock is active.
catch_onuint8_tA catch subscription is streaming.
kbd_attacheduint8_tA keyboard is attached, cloned, and injectable.

MediusDeviceInfo

The cloned device's USB identity, kind, and product

From medius_device_device_info; all-zero/empty when nothing is cloned. product is a NUL-terminated UTF-8 string.

FieldC typeMeaning
viduint16_tUSB vendor id (idVendor).
piduint16_tUSB product id (idProduct).
bcd_deviceuint16_tDevice release (bcdDevice).
bcd_usbuint16_tUSB version (bcdUSB), e.g. 0x0200.
has_serialuint8_tThe clone serves a serial string.
has_bosuint8_tThe clone serves a BOS descriptor.
kindMediusDeviceKindThe device's primary kind (Boot-interface protocol).
productchar[MEDIUS_MAX_PRODUCT]The product string (NUL-terminated; empty when none).

MediusCaps

The whole cloned device's capabilities

From medius_device_caps: a mouse half and a keyboard half plus the per-class change-driven flags. Test it with medius_caps_has_mouse, medius_caps_has_keyboard, medius_caps_is_composite.

FieldC typeMeaning
mouseMediusMouseCapsThe mouse half (all-zero when no mouse is bound).
keyboardMediusKbdCapsThe keyboard half (all-zero when no keyboard is bound).
mouse_change_drivenuint8_tAlways 0: mouse motion is continuous, so it has a learned cadence.
kbd_change_drivenuint8_t1 when a keyboard is bound: it reports only on a key change.

MediusMouseCaps

What the cloned mouse can do

The mouse half of MediusCaps; all-zero when no mouse interface is bound.

FieldC typeMeaning
n_buttonsuint8_tButtons the mouse report carries.
has_xuint8_tThe report carries an X axis.
has_yuint8_tThe report carries a Y axis.
has_wheeluint8_tThe report carries a wheel.
has_report_iduint8_tThe mouse report sits behind a HID report ID.
n_hiduint8_tCloned HID interfaces; >1 = composite.

MediusKbdCaps

What the cloned keyboard can do

The keyboard half of MediusCaps; all-zero when no keyboard is bound. n_keys == 0xFF signals an NKRO bitmap.

FieldC typeMeaning
n_keysuint8_tKeycode-array slots, or 0xFF for an NKRO bitmap.
nkrouint8_tThe keyboard reports an NKRO bitmap.
has_consumeruint8_tA Consumer collection is present (media injectable).
has_systemuint8_tA system-control collection is present (passthrough-only).
has_report_iduint8_tThe keyboard report sits behind a HID report ID.

MediusRate

The native report rate and clone poll period

From medius_device_query_rate. Convert to Hz with medius_rate_native_hz(rate, &hz) (returns false when there's no continuous cadence).

FieldC typeMeaning
native_period_usuint16_tRealised native period in µs; 0 = not learned, or change-driven.
poll_period_usuint16_tCloned inject-endpoint poll period in µs.
confidentuint8_tThe estimator window is full and the value is trustworthy.
change_drivenuint8_tThe active input is event-driven (keyboard/media), so no continuous cadence.

MediusStats

Box-side delivery / telemetry counters

From medius_device_query_stats. A nonzero tx_drops or tx_wedges means delivery degraded under load.

FieldC typeMeaning
inject_emitsuint32_tPure-injection reports emitted.
tx_dropsuint16_tReports dropped on TX-queue overflow (should stay 0).
tx_mergesuint16_tBacked-up reports merged instead of queued.
tx_maxdepthuint8_tDeepest the TX queue has reached.
tx_wedgesuint8_tWedged-endpoint recoveries.
wakeupsuint16_tRemote-wakeups issued.
reset_countuint16_tUSB bus resets seen.
config_countuint16_tSET_CONFIGURATION events (re-enumerations).

MediusLocks & MediusLockEntry

The active locks, as an entry list

From medius_device_query_locks: entries[0..n], one per locked target. Test a target/direction with medius_locks_is_locked(&locks, target, dir), which reports a match from a specific entry or a covering whole-class is_blanket lock. Wire layout on the native LOCKS reply.

FieldC typeMeaning
nuint16_tLive entries in entries.
entriesMediusLockEntry[MEDIUS_MAX_LOCKS]One per locked axis or usage.
MEDIUSLOCKENTRY
FieldC typeMeaning
targetMediusLockTargetThe locked axis or usage.
is_blanketboolThe lock covers a whole class; target.usage.kind names it and target.usage.id is unused.
positiveboolThe positive edge (axis +, or press) is locked.
negativeboolThe negative edge (axis -, or release) is locked.

MediusCatchState

The active catch subscription

From medius_device_query_catch. A nonzero dropped means the box shed events under back-pressure.

FieldC typeMeaning
maskuint8_tSubscribed classes (the MEDIUS_CATCH_MASK_* bits); 0 = none.
droppeduint32_tBox-side events dropped under back-pressure.

MediusImperfectStatus

The imperfect-clone state (each 0 or 1)

From medius_device_query_imperfect. See Options.

FieldC typeTrue (1) when
alloweduint8_tThe opt-in toggle; cloning an over-capacity device is allowed.
over_capacityuint8_tThe device needs an interrupt-IN endpoint the box can't service.
clone_imperfectuint8_tThe live clone is over-capacity and was cloned anyway, so one interface is dead.

MediusEmitPaceStatus

The emit-rate pacing state

From medius_device_query_emit_pace. See Options.

FieldC typeMeaning
modeMediusEmitModeThe selected mode.
fixed_hzuint16_tThe rate requested for FIXED (0 otherwise).
resolved_hzuint16_tThe ceiling in effect; 0 = learnt/adaptive, or no device yet in INTERVAL.

MediusCountersSnapshot

Host-side always-on link counters

From medius_device_counters. See Logs & counters.

FieldC typeMeaning
frames_txuint64_tFrames sent to the box.
frames_rxuint64_tFrames received from the box.
crc_dropsuint64_tInbound frames dropped on a bad checksum.
reconnectsuint64_tTimes the library reopened the port.

MediusPortInfo

A discovered medius serial port

Filled by medius_find_ports; path and serial are NUL-terminated. Canonical docs on PortInfo.

FieldC typeMeaning
pathchar[MEDIUS_MAX_PATH]Serial port path (NUL-terminated).
viduint16_tUSB vendor id (0x1A86).
piduint16_tUSB product id (0x55D3).
serialchar[MEDIUS_MAX_SERIAL]The CH343 adapter's serial (NUL-terminated); empty when has_serial == 0.
has_serialuint8_tWhether the adapter serves a serial string.

MediusBoxInfo

One discovered box: port, version, and cloned device

Filled by medius_list: one entry per connected box, each opened and handshaked in turn. See BoxInfo.

FieldC typeMeaning
portMediusPortInfoThe box's control port (path + CH343 serial).
versionMediusVersionIts firmware version, with the box MAC and name.
deviceMediusDeviceInfoThe device it clones.

Event & log types

Fixed-size PODs off the streams

The values you read off the catch and log streams. Catch semantics on Catch; canonical docs on Structs.

MediusMotionEvent

One physical relative-axis snapshot

The user's real motion at the merge point, before any lock suppression or injection. Surfaces as the Motion arm of a MediusCatchEvent.

FieldC typeMeaning
dxint16_tRelative X this report (right positive).
dyint16_tRelative Y this report (down positive).
dzint16_tWheel delta this report (up positive).

MediusUsageEvent

One held-usage snapshot for a class

The held usages of one class (button, key, or media; modifiers are key usages 0xE0 to 0xE7) in usages[0..n], buttons and keys the same shape. Test one with medius_usage_event_is_held(&event, usage), or diff successive snapshots for edges.

FieldC typeMeaning
nuint16_tLive usages in usages.
usagesMediusUsage[MEDIUS_MAX_USAGES]The held MediusUsage usages (button, key, or media).

MediusCatchEvent

One catch-stream event (a tagged union)
struct MediusCatchEvent {
    MediusCatchEventKind kind;
    union MediusCatchEventData { MediusMotionEvent motion; MediusUsageEvent usages; } data;
}

Written by medius_event_stream_recv and friends. Read the union member named by kind.

FieldC typeMeaning
kindMediusCatchEventKindWhich union member is live.
data.motionMediusMotionEventRead when kind == MOTION.
data.usagesMediusUsageEventRead when kind == USAGES.

MediusLogLine

One device log line

Written by medius_log_stream_recv; text is NUL-terminated.

FieldC typeMeaning
levelMediusLogLevelSeverity tag.
textchar[MEDIUS_MAX_LOG_TEXT]The decoded message (NUL-terminated).

MediusClipTrigger

One physical-input binding that drives the clip

A managed binding you add with medius_clip_bind: when on hits edge, the box runs action on the clip. Build the on usage with the medius_usage_* helpers. Concept on Clip.

FieldC typeMeaning
onMediusUsageThe physical button, key, or media usage that fires the binding.
edgeMediusEdgeWhich edge of on fires it.
actionMediusClipActionWhat it does to the clip.
consumeuint8_t1 to swallow the input so the game never sees it; 0 to let it pass through.

MediusClipSettings

The clip configuration read back from the box

From medius_clip_query_config: the auto-lock scope, the loop/retain/finalize scalars, and the live trigger set. Concept on Clip.

FieldC typeMeaning
autolock_bitsuint8_tThe auto-lock scope as CLIP_LOCK_* wire bits (set with medius_clip_set_autolock).
loop_uint8_tPlayback loops at the clip end (retained mode only).
retainuint8_tThe loaded clip is retained so it can rewind and replay (0 = streaming).
finalizeduint8_tA retained clip's end is fixed, so it can replay and loop.
triggersMediusClipTrigger[MEDIUS_CLIP_TRIG_MAX]The bound triggers, triggers[0..n].
nuint8_tLive entries in triggers.

MediusClipStatus & MediusClipState

Buffered-clip ring and playback state

From medius_clip_query_status; state is a MediusClipState. Concept on Clip.

MEDIUSCLIPSTATE
EnumeratorValueMeaning
MEDIUS_CLIP_STATE_IDLE0No clip playing (empty, or a loaded clip parked at its start).
MEDIUS_CLIP_STATE_PLAYING1Draining the ring, one entry per native frame.
MEDIUS_CLIP_STATE_PAUSED2Halted mid-clip; the cursor and any held usages are retained.
MEDIUS_CLIP_STATE_FAULTED3An append was dropped or the ring overflowed; recover with medius_clip_clear.
MEDIUSCLIPSTATUS
FieldC typeMeaning
stateMediusClipStateThe lifecycle state.
freeuint32_tRing bytes free; pace top-ups off this.
totaluint32_tThe retained clip size in bytes; streaming, the buffered-but-undrained bytes.
playeduint32_tBytes played from the clip start (retained progress; ~0 while streaming).
ticksuint32_tContent frames drained since the last start (gap runs are not counted).
underrunsuint16_tEmpty-ring episodes.
overrunsuint16_tAppends dropped because the ring was full.
seq_gapsuint16_tDropped append frames detected.
held_nuint16_tHeld usages in held.
heldMediusUsage[MEDIUS_MAX_USAGES]The buttons, keys, and media the clip is holding down; test one with medius_clip_status_is_held.

Errors

MediusStatus plus a thread-local message
enum MediusStatus : int32_t   /* MEDIUS_STATUS_OK == 0; everything else is a failure */

Every fallible call returns a MediusStatus and writes its result through an out-param. On failure the detail lives in thread-local state. Read it before the next call on that thread overwrites it. Canonical mapping on Errors.

EnumeratorValueMeaning
MEDIUS_STATUS_OK0Success.
MEDIUS_STATUS_ERR_IO1An underlying serial or OS error.
MEDIUS_STATUS_ERR_NOT_FOUND2No device matched the expected VID/PID.
MEDIUS_STATUS_ERR_NO_REPLY3The box never answered the version query during the handshake.
MEDIUS_STATUS_ERR_BAD_PROTO_VER4The box answered with an unexpected proto_ver (see medius_last_error_proto_ver).
MEDIUS_STATUS_ERR_QUERY_TIMEOUT5A query waited past its timeout with no reply.
MEDIUS_STATUS_ERR_DISCONNECTED6The link dropped (also returned by a stream when it closes).
MEDIUS_STATUS_ERR_FRAME_TOO_LONG7An outbound frame exceeded the wire limit.
MEDIUS_STATUS_ERR_FLASH_TOOL8The flash subprocess (esptool) failed.
MEDIUS_STATUS_ERR_INVALID_ARG9A bad argument (e.g. a null required pointer).
MEDIUS_STATUS_ERR_PANIC10A Rust panic was caught at the boundary.
MEDIUS_STATUS_ERR_UNKNOWN11An unclassified failure.
FunctionReturnsMeaning
medius_last_error_message(char *buf, uintptr_t cap)uintptr_tCopies the last error's text (NUL-terminated, truncated to cap); returns the full length, so you can size a buffer and retry.
medius_last_error_proto_ver(void)uint8_tThe version byte from a BAD_PROTO_VER error, or 0.
EXAMPLE
MediusDevice *dev = NULL;
if (medius_device_find(&dev) != MEDIUS_STATUS_OK) {
    char buf[256];
    medius_last_error_message(buf, sizeof buf);
    fprintf(stderr, "open failed: %s\n", buf);
    return 1;
}