Move
move_axis drives every relative axis. The rest wrap it. Each call queues one fire-and-forget MOVE frame.
The right-hand calls emit the whole delta on the box's next mouse report, whatever movement riding, spreading and rendering are set to. flush_motion and discard_motion act on motion still held from earlier moves.
move_axis Field-generic motion verb
fn move_axis(&self, motion: Motion, timing: MoveTiming, pending: PendingMotion) -> Result<()>
Fire-and-forget
| Parameter | Type | Description |
|---|---|---|
motion | Motion | Axis and delta: Cursor { dx, dy }, Wheel(dz), or Pan(dz). |
timing | MoveTiming | Ride native motion, or emit on the next report. |
pending | PendingMotion | Keep, flush or discard motion already held for a ride. |
Backs MOVE, whose flags byte holds the last two parameters. With movement riding off, Now still skips spreading and rendering. Flush and Discard then act on what spreading and rendering hold of earlier moves.
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 motion
fn move_rel(&self, dx: i16, dy: i16) -> Result<()>
Fire-and-forget
move_axis with Motion::Cursor.
| Parameter | Type | Description |
|---|---|---|
dx | i16 | Horizontal offset in mouse counts. Positive right, negative left. |
dy | i16 | Vertical offset in mouse counts. Positive down, negative up. |
dx and dy span the full i16 range (-32768 to 32767). The OS pointer speed and acceleration curve scale counts to pixels.
device.move_rel(20, 20)?; // right and down
device.move_rel(-40, 0)?; // left
device.move_rel(0, -10)?; // upwheelWheel scroll
fn wheel(&self, delta: i16) -> Result<()>
Fire-and-forget
A wrapper over move_axis with Motion::Wheel.
| Parameter | Type | Description |
|---|---|---|
delta | i16 | Scroll steps. Positive up, negative down. |
delta spans the full i16 range (-32768 to 32767). It feeds the same accumulator as cursor motion, which paces large values across reports.
device.wheel(3)?; // up three notches
device.wheel(-1)?; // down one notchpanAC Pan (horizontal scroll)
fn pan(&self, delta: i16) -> Result<()>
Fire-and-forget
move_axis with Motion::Pan, a full peer of wheel.
| Parameter | Type | Description |
|---|---|---|
delta | i16 | Pan steps (horizontal scroll). Positive right, negative left. |
delta spans the full i16 range (-32768 to 32767). It feeds the same accumulator as the wheel, which paces large values across reports. It works only on a real device whose descriptor declares AC Pan (check caps).
device.pan(3)?; // pan right
device.pan(-1)?; // pan leftmove_rel_now Cursor motion that bypasses riding
fn move_rel_now(&self, dx: i16, dy: i16) -> Result<()>
Fire-and-forget
| Parameter | Type | Description |
|---|---|---|
dx | i16 | Horizontal offset in mouse counts. Positive right, negative left. |
dy | i16 | Vertical offset in mouse counts. Positive down, negative up. |
move_rel with MoveTiming::Now: the delta is emitted on the box's next mouse report instead of riding native motion, and held motion stays held.
The box emits a report for the delta on the first poll that no native report can be ready for. If a native report reaches the box first, that report carries the delta. But if it already carries injected motion and the real device leaves polls free, the delta takes a separate poll.
device.set_movement_riding(Some(Duration::from_millis(20)))?;
device.move_rel(100, 0)?; // rides native motion, dropped without it
device.move_rel_now(100, 0)?; // emits either waywheel_now Scroll that bypasses riding
fn 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 next reportpan_now Pan that bypasses riding
fn pan_now(&self, delta: i16) -> Result<()>
Fire-and-forget
| Parameter | Type | Description |
|---|---|---|
delta | i16 | Pan steps (horizontal scroll). Positive pans right, negative pans left. |
pan with MoveTiming::Now.
device.pan_now(-1)?; // one step left, on the next reportflush_motion Emit what riding holds
fn flush_motion(&self) -> Result<()>
Fire-and-forget
| Accumulator | After flush |
|---|---|
| Riding | Emptied into the immediate accumulator, regardless of the ride window. Emits no motion itself. |
| Immediate | Gains that amount, emitted on the box's next mouse report. |
for _ in 0..10 {
device.move_rel(4, 0)?; // accumulates, waiting for native motion
}
device.flush_motion()?; // 40 counts, nowdiscard_motion Drop what riding holds
fn discard_motion(&self) -> Result<()>
Fire-and-forget
| State | After discard |
|---|---|
| Riding accumulator | Zeroed; never reaches the game PC. |
| Immediate accumulator | Untouched, so a move sent with MoveTiming::Now is still emitted. |
| Bearing | Cleared, 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
device.discard_motion()?; // it never reaches the game PCOn AsyncDevice Motion stays synchronous
AsyncDevice keeps every motion verb synchronous: no .await, same signatures. block_on is only for async queries.
let dev = Device::find()?.into_async();
dev.move_rel(40, 0)?; // no .await
dev.wheel(1)?;