Expand description
Lock-free mouse -> console command hand-off.
The mouse task must never hold VGA_WRITER: it publishes the input work
here and the console-render task (which already owns the writer) applies it.
Single-producer/single-consumer ring: the mouse task pushes, the console
task pops. No allocation, no locks.
Press/release ordering is preserved: the mouse taskβs local button state
machine emits Press before Release for a turn that observes both, and
each turn is published as one unit (a single tail store) so the renderer
never observes a half-written turn.
Re-exportsΒ§
use core::cell::UnsafeCell;πuse core::sync::atomic::AtomicBool;πuse core::sync::atomic::AtomicUsize;πuse core::sync::atomic::Ordering;π
StructsΒ§
- Input
State - Renderer-owned state carried across ticks; identical to the state the mouse task used to keep locally.
- Ring π
EnumsΒ§
- Input
Command - A deferred input action, applied by the console-render task.
ConstantsΒ§
- INPUT_
RING_ CAPACITY - Ring slot count. One slot is reserved to distinguish full from empty, so
the usable capacity is
INPUT_RING_CAPACITY - 1(63) commands. - LINES_
PER_ πNOTCH - Text lines moved per mouse-wheel notch. The wheel is eased: the console tick applies one line per frame, so a notch settles over three frames.
- MAX_
TURN_ COMMANDS - Maximum commands the mouse task can emit for one turn, including the
trailing
InputCommand::EndTurnmarker. - MOUSE_
RENDER_ πMIN_ TICKS - Minimum ticks between mouse visual renders (was in
mouse.rs). - RING_
MASK π - SCROLLBAR_
DRAG_ πMIN_ TICKS - Minimum ticks between scrollbar-drag applies (was in
mouse.rs).
StaticsΒ§
- INPUT_
PENDING π - RING π
FunctionsΒ§
- apply_
input - Drain complete turns and apply each to
writerwith the exact call sequence/order of the old in-lock mouse loop. Returns whether anything was applied (commands consumed or a pending visual rendered). - apply_
turn π - Apply the commands of one mouse turn, preserving the original batching.
- discard
- Drop every queued command (used when the console is unavailable).
- has_
pending_ πvisual - has_
space - Whether a full turn can be enqueued without dropping any command.
- push_
turn - Publish one turn (the slice must end with
InputCommand::EndTurn). Returnsfalsewhen the ring cannot hold the whole turn. - render_
pending π - Apply the pending visual updates under the original tick gates.
- take_
pending - Take and clear the pending flag.
- wake
- Publish that input work is ready; consumed by
take_pending.