Move
Cursor motion and scrollOne field-generic verb, move_axis, drives the relative axes; the rest are thin wrappers over it. Each call queues one fire-and-forget MOVE frame.
| Drive a... | Rides a real move | Goes on the box's clock |
|---|---|---|
| cursor | move_rel | move_rel_now |
| wheel | wheel | wheel_now |
The right-hand column only differs while movement riding is on. flush_motion and discard_motion act on motion it is already holding.
move_axis
Field-generic motion verbfn move_axis(&self, motion: Motion, timing: MoveTiming, pending: PendingMotion) -> Result<()>
Fire-and-forget
| Parameter | Type | Description |
|---|---|---|
motion | Motion | The axis to drive: Cursor { dx, dy } or Wheel(dz). |
timing | MoveTiming | Whether this delta waits for a real move or emits on the box's own clock. |
pending | PendingMotion | What happens to motion the box is already holding for a real move. |
Backs the MOVE command; the last two are its flags byte. With movement riding off, Now and Flush change nothing, while Discard still drops whatever has accumulated since the last emit.
use medius::{Motion, MoveTiming, PendingMotion};
device.move_axis(Motion::Cursor { dx: 20, dy: 20 }, MoveTiming::Ride, PendingMotion::Keep)?;
device.move_axis(Motion::Wheel(1), MoveTiming::Ride, PendingMotion::Keep)?;
// Send this one now, and the held motion with it.
device.move_axis(Motion::Cursor { dx: 5, dy: 0 }, MoveTiming::Now, PendingMotion::Flush)?;move_rel
Relative cursor movementfn move_rel(&self, dx: i16, dy: i16) -> Result<()>
Fire-and-forget
A wrapper over move_axis with Motion::Cursor.
| Parameter | Type | Description |
|---|---|---|
dx | i16 | Horizontal offset in mouse counts. Positive moves right, negative moves left. |
dy | i16 | Vertical offset in mouse counts. Positive moves down, negative moves up (screen-style, not math-style). |
Counts are not pixels: the OS pointer-speed and acceleration curve scale them. Both span the full i16 range (-32768 to 32767).
device.move_rel(20, 20)?; // right and down
device.move_rel(-40, 0)?; // left
device.move_rel(0, -10)?; // upwheel
Wheel scrollfn wheel(&self, delta: i16) -> Result<()>
Fire-and-forget
A wrapper over move_axis with Motion::Wheel.
| Parameter | Type | Description |
|---|---|---|
delta | i16 | Scroll steps. Positive scrolls up, negative scrolls down. |
delta spans the full i16 range (-32768 to 32767) and feeds the same accumulator as cursor motion, pacing large values across reports.
device.wheel(3)?; // up three notches
device.wheel(-1)?; // down one notchmove_rel_now
Cursor movement that bypasses ridingfn move_rel_now(&self, dx: i16, dy: i16) -> Result<()>
Fire-and-forget
| Parameter | Type | Description |
|---|---|---|
dx | i16 | Horizontal offset in mouse counts. Positive moves right, negative moves left. |
dy | i16 | Vertical offset in mouse counts. Positive moves down, negative moves up. |
move_rel with MoveTiming::Now: the delta emits on the box's own clock rather than waiting for a real move to carry it, and leaves held motion held.
device.set_movement_riding(Some(Duration::from_millis(20)))?;
device.move_rel(100, 0)?; // waits for the user to move, dropped if they don't
device.move_rel_now(100, 0)?; // emits whether they move or notwheel_now
Scroll that bypasses ridingfn wheel_now(&self, delta: i16) -> Result<()>
Fire-and-forget
| Parameter | Type | Description |
|---|---|---|
delta | i16 | Scroll steps. Positive scrolls up, negative scrolls down. |
wheel with MoveTiming::Now.
device.wheel_now(-1)?; // one notch down, on the box's clockflush_motion
Send what riding is holdingfn flush_motion(&self) -> Result<()>
Fire-and-forget
| Accumulator | What flush does |
|---|---|
| Riding | Emptied onto the box's own clock, whatever the ride window says. Sends no motion of its own. |
| Immediate | Gains that amount, so it goes out on the next frame the box emits. |
for _ in 0..10 {
device.move_rel(4, 0)?; // accumulates, waiting for a real move
}
device.flush_motion()?; // 40 counts, nowdiscard_motion
Drop what riding is holdingfn discard_motion(&self) -> Result<()>
Fire-and-forget
| State | What discard does |
|---|---|
| Riding accumulator | Zeroed. That motion never reaches the game PC. |
| Immediate accumulator | Untouched, so a move sent with MoveTiming::Now still lands. |
| Bearing | Cleared with it: a discarded delta is never emitted, so every With / Against scale stops applying until the box injects again. |
Unlike reset, no held usage or lock is released.
device.move_rel(400, 0)?; // queued, then superseded
device.discard_motion()?; // it never reaches the game PCOn AsyncDevice
Movement stays synchronousAsyncDevice keeps every movement verb synchronous: no .await, same signatures. The block_on pattern is only for async queries.
let dev = Device::find()?.into_async();
dev.move_rel(40, 0)?; // no .await
dev.wheel(1)?;