Medius - Rust LibraryEnums

Enums

Command and status enumerations

Command and status enums, each tied to a wire byte. Conversion helpers are listed with each.

DeviceKind

The cloned device's primary kind
enum DeviceKind { Unknown, Keyboard, Mouse }

The kind field of a DeviceInfo, read from the cloned device's USB Boot-interface bInterfaceProtocol. It also drives find_mouse_box and find_keyboard_box. Display prints the lowercase name.

VariantByteMeaning
Unknown0Neither a Boot keyboard nor a Boot mouse.
Keyboard1The device is a keyboard.
Mouse2The device is a mouse.

Button

The button a command acts on
enum Button { Left, Right, Middle, Side1, Side2 }

The button an INJECT command acts on. A Button converts Into<Usage> as class button, so you pass one straight to inject. Convert with as_id() -> u8 and from_id(u8) -> Option<Button>.

VariantidMeaning
Left0Left button.
Right1Right button.
Middle2Middle button.
Side13First thumb button.
Side24Second thumb button.

Action

The shared press / release tri-state
enum Action { SoftRelease, Press, ForceRelease }

The shared override action for an inject call, on any Usage class (button, key, or media). The discriminant is the wire byte. Convert with as_u8() and from_u8(u8) -> Option<Action>.

VariantByteMeaning
SoftRelease0Drop the box's override, press or force; a physical hold stays down.
Press1Force the input down.
ForceRelease2Force the input up, masking a physical hold.
RESULT THE PC SEES

The two releases differ only when the user physically holds the same input:

VariantUser holds nothingUser is holding it
Pressdowndown
SoftReleaseupdown (physical wins)
ForceReleaseupup (masks physical)

Class

The class of a momentary usage
enum Class { Button, Key, Media }

The class byte of a Usage, shared by INJECT, LOCK, and CATCH. Convert with as_u8() and from_u8(u8) -> Option<Class>.

VariantByteMeaning
Button0A mouse button; id is a Button id (0=Left .. 4=Side2).
Key1A keyboard key; id is a HID keycode (0xE0 .. 0xE7 is a modifier).
Media2A media usage; id is a 16-bit Consumer usage.

Usage

A momentary input: (class, id)
struct Usage { class: Class, id: u16 }

What inject drives and LockTarget locks: a mouse button, a keyboard key, or a media usage in one shape. A Button, Key, and MediaKey each impl Into<Usage>, so you pass one straight to any verb; build one by hand with Usage::new(class, id).

FieldTypeMeaning
classClassThe input class (button, key, or media).
idu16The class-specific id: a button id, a HID keycode, or a Consumer usage.
EXAMPLE
use medius::{Button, Class, Key, Usage};

let from_button: Usage = Button::Left.into();      // Class::Button, id 0
let from_key: Usage = Key::A.into();               // Class::Key, id 0x04
let by_hand = Usage::new(Class::Media, 0x00E9);    // volume up
device.press(from_button)?;                         // press takes any impl Into<Usage>

Motion

A relative axis for move_axis
enum Motion { Cursor { dx: i16, dy: i16 }, Wheel(i16) }

What move_axis drives: the cursor (carrying dx and dy) or the wheel (a single delta). Both span the full i16 range. A lock names a single Axis instead.

VariantPayloadMeaning
Cursor{ dx: i16, dy: i16 }Relative pointer movement.
Wheeli16Relative scroll.

Axis

A single relative axis
enum Axis { X, Y, Wheel }

One relative axis, the input kind that is genuinely mouse-hardware-specific. A lock_axis or a LockTarget::Axis names one, with the sign given by a LockDirection. Convert with as_u16().

VariantidMeaning
X0The X cursor axis.
Y1The Y cursor axis.
Wheel2The wheel.

RebootTarget

Which chip to restart, and how
enum RebootTarget { DeviceDownload, HostDownload, DeviceRun, HostRun }

Which chip a REBOOT restarts, and into what mode. Convert with as_u8() and from_u8(u8) -> Option<RebootTarget>.

VariantByteMeaning
DeviceDownload0Device chip into ROM download mode, ready to flash over the serial link.
HostDownload1Host chip into ROM download mode, ready to flash over its own USB.
DeviceRun2Restart the device chip and run its firmware.
HostRun3Restart the host chip and run its firmware.

EmitPace

What paces injected motion
enum EmitPace { Learned, Interval, Fixed(u16) }

What sets the emit-rate ceiling for injected motion, passed to set_emit_pace and returned in EmitPaceStatus. It raises the ceiling only, so idle stays idle.

VariantMeaning
LearnedPace to the mouse's learnt native report rate (the default).
IntervalPace to the cloned mouse's declared poll rate (its bInterval).
Fixed(u16)Pace to a fixed rate in Hz; snaps to 1000/n and caps at 1 kHz.

LedTarget

Which chip's status LED to drive
enum LedTarget { Device, Host, Both }

Which chip's LED a LED command drives. The discriminant is the wire target byte. Convert with as_u8() and from_u8(u8) -> Option<LedTarget>.

VariantByteMeaning
Device0The device chip's own LED.
Host1The host chip's LED, relayed over the inter-chip link.
Both2Both LEDs at once.

LedMode

What to drive the LED to
enum LedMode { Auto, Off, Solid, Blink }

What a LED command drives the LED to; Auto hands it back to the box's status display. The discriminant is the wire mode byte. Convert with as_u8() and from_u8(u8) -> Option<LedMode>.

VariantByteMeaning
Auto0Restore the chip's own status display.
Off1LED dark.
Solid2Lit steadily at the command's level.
Blink3Blinks at the command's level.

LockTarget

What a lock acts on
enum LockTarget { Axis(Axis), Usage(Usage) }

What a LOCK command blocks: a relative Axis or a momentary Usage (a button, key, or media usage). An Axis and any impl Into<Usage> each convert Into<LockTarget>, so you pass one straight to lock. A button locks exactly like a key.

VariantPayloadLocked by
AxisAxisThe sign, a LockDirection of positive, negative, or both.
UsageUsageThe press or release edge, a LockDirection.

LockScope

What a reported lock covers
enum LockScope { Target(LockTarget), Blanket(Class) }

What a LockEntry in a query_locks reply covers: one specific LockTarget, or a whole-class blanket that locks every usage of a Class at once.

VariantPayloadCovers
TargetLockTargetA specific axis or usage.
BlanketClassEvery button, key, or media usage of the class.

LockDirection

Which way or which edge to block
enum LockDirection { Both, Positive, Negative }

Which side of an input a LOCK blocks. For an axis or the wheel it's a sign; for a usage (button, key, or media) it's an edge. The discriminant is the wire direction byte. Convert with as_u8() and from_u8(u8) -> Option<LockDirection>.

VariantByteMeaning
Both0Both signs, or press and release.
Positive1Axis positive (+), or usage press.
Negative2Axis negative (-), or usage release.

Blanket

A whole-group lock selector
enum Blanket { Aim, Wheel, Buttons, Keys, Media }

A whole input group: which one lock_all / unlock_all block in one call, and the members of a clip's ClipSettings auto-lock.

VariantMeaning
AimThe X and Y cursor axes.
WheelThe wheel.
ButtonsEvery mouse button.
KeysEvery keyboard key and modifier.
MediaEvery media (Consumer) usage.

LogLevel

Severity tag on a log line
enum LogLevel { Error, Warn, Info, Debug, Verbose }

The severity tag on a LogLine. from_u8(u8) is infallible: an unknown byte falls back to Info.

VariantByteMeaning
Error0A failure the box could not recover from.
Warn1Something off that the box handled.
Info2Normal operational notices.
Debug3Detail for diagnosing a problem.
Verbose4The finest-grained trace output.

CatchEvent

One physical-input event off the stream
enum CatchEvent { Motion(MotionEvent), Usages(UsageSnapshot) }

What an EventStream yields, captured before lock suppression or injection. A relative axis is Motion; a held-usage snapshot (buttons, keys, or media, all one shape) is Usages. Match on the variant.

VariantPayloadRaised by
MotionMotionEventA cursor or wheel change (the MOTION / WHEEL classes).
UsagesUsageSnapshotA button, key, or media change (the BUTTONS / KEYS / MEDIA classes).

ClipState

The buffered-clip lifecycle state
enum ClipState { Idle, Playing, Paused, Faulted }

The device-side clip state on ClipStatus::state, from ClipHandle::query_status().

VariantByteMeaning
Idle0No clip playing (empty, or a loaded clip parked at its start).
Playing1Draining the ring, one entry per native frame.
Paused2Held mid-clip, keeping the cursor and any held input; resumes from the same spot.
Faulted3An append was dropped or the ring overflowed; recover with clear.

Edge

Which edge fires a clip trigger
enum Edge { Both, Press, Release }

Which edge of a bound usage fires a ClipTrigger: its press, its release, or either. It shares wire values with LockDirection.

VariantByteMeaning
Both0Fire on either edge.
Press1Fire on the press edge.
Release2Fire on the release edge.

ClipAction

What a fired clip trigger does
enum ClipAction { Start, Stop, Pause, Resume, Restart, Toggle }

What a bound ClipTrigger does to the clip when its edge fires. The discriminant doubles as the CLIP_CTRL op byte for the same action.

VariantByteMeaning
Start0Start playback from the ring's head.
Stop1Stop playback and rewind to the head.
Pause2Hold playback mid-clip.
Resume3Continue a paused clip from where it stopped.
Restart4Rewind to the head and play from the start.
Toggle5Start if idle, stop if playing.