pub struct ClipFrame { /* private fields */ }Expand description
Clip frame: everything the box does on one tick (§3.11).
Any mix of cursor motion, wheel, pan, up to CLIP_EDGES_MAX edges, up to CLIP_RAW_MAX raw
reports and any number of control transfers, encoding to at most CLIP_ENTRY_MAX bytes;
append checks that.
Raw reports and transfers need the imperfect-clone opt-in when the frame plays, not when it is
appended. With it off the box discards them and counts each in ClipStatus::gated.
let device = Device::find()?;
let mut clip = ClipBuilder::new();
clip.frame(
ClipFrame::new()
.move_by(4, -2)
.press(Button::LEFT)
.raw(2, Direction::OUT, [0x10, 0xFF, 0x05])
.transfer(0, Setup::new(0x21, 0x09, 0x0300, 0, 2), [0x04, 0x01]),
);
device.clip().append(&clip)?;Implementations§
Source§impl ClipFrame
impl ClipFrame
Sourcepub fn edge(self, usage: impl Into<Usage>, action: Action) -> ClipFrame
pub fn edge(self, usage: impl Into<Usage>, action: Action) -> ClipFrame
Edge on a button, key or media usage.
Sourcepub fn release(self, usage: impl Into<Usage>) -> ClipFrame
pub fn release(self, usage: impl Into<Usage>) -> ClipFrame
Soft-release a usage: clear the injected press and leave a physical hold intact.
Sourcepub fn force_release(self, usage: impl Into<Usage>) -> ClipFrame
pub fn force_release(self, usage: impl Into<Usage>) -> ClipFrame
Force-release a usage: mask a physical hold too.
Sourcepub fn raw(
self,
ep: u8,
direction: Direction,
bytes: impl Into<Vec<u8>>,
) -> ClipFrame
pub fn raw( self, ep: u8, direction: Direction, bytes: impl Into<Vec<u8>>, ) -> ClipFrame
Raw report, as Device::raw sends one: bytes verbatim on endpoint
ep, Direction::IN to the game PC or Direction::OUT to the real device.
Sourcepub fn transfer(
self,
ep: u8,
setup: Setup,
out: impl Into<Vec<u8>>,
) -> ClipFrame
pub fn transfer( self, ep: u8, setup: Setup, out: impl Into<Vec<u8>>, ) -> ClipFrame
Control transfer to the real device, as Device::transfer runs
one. out is exactly setup.length bytes for an OUT request, empty for an IN one. The reply
arrives as a TrafficClass::ClipTransfer event.
Sourcepub fn byte_len(&self) -> usize
pub fn byte_len(&self) -> usize
Ring bytes this frame takes; at most CLIP_ENTRY_MAX for a frame
append accepts.