Expand description
one API for the most popular passthrough boxes. you connect, and anybox figures out which box it is, the firmware, and what it can do, then you call the same methods without having to worry about which box is plugged in
use anybox::{Button, Event, Key};
fn main() -> anybox::Result<()> {
let device = anybox::connect()?;
device.move_by(100, 0)?;
device.click(Button::Left)?;
device.tap_key(Key::A)?;
for event in device.events() {
if let Event::Button { button, pressed: true, .. } = event {
println!("{button:?} down");
}
}
Ok(())
}if a box can’t do something, the call fails with Error::Unsupported and says why, nothing is faked or
changed behind your back. Device::snapshot tells you up front what the box in front of you can do right
now, which also depends on what’s plugged into it. things only one box has stay reachable through that box’s
own API, like device.medius() on a Medius
the README has the full picture, which box does what, the differences between them, and how to add your own fallback for something a box can’t do: https://github.com/etherealrl/anybox
Re-exports§
pub use medius;
Structs§
- BoxTime
- Capabilities
- what this box, on this firmware, with this mouse behind it, can do
- Capability
- Click
- Closed
- Connect
- Device
- one connected box. every call checks what the box can do first, so nothing is faked and nothing is silently dropped. dropping it lets go of every button and key you were holding and closes the port
- Event
Kinds - which input a receiver wants, combined with
|. a receiver only gets what it asked for, the box streams what any receiver wants, and connection events and drops reach every receiver - Events
- a receiver of events from one device. it ends once the device is gone and you’ve read everything queued
- Found
- one box
findsaw - Info
- Key
- a keyboard key by its HID usage (page 0x07). the consts cover the usual keys, and
Key(n)gets you any other one from 0x04 to 0xE7 - Media
Key - a media key by its HID consumer usage (page 0x0C)
- Mock
Poller - the poller of a device made with
Device::mock_medius_manual, ticked by hand so a test doesn’t wait on its timing - Snapshot
- who the box is and what it can do, both always read from the same connection
- Stamp
Enums§
- Action
- every action a box gets asked whether it can do, and the one an error is about
- Axis
- a physical axis you can lock or scale
- Button
- Click
Timing - what
click()and the key and media taps do on a box that can’t time them itself - Clock
- each box clock is its own counter, so only compare stamps that come from the same one
- Direction
- which way along an axis. positive is the way the box moves for a positive value, so right for X, down for Y, up for the wheel and right for pan
- Drop
Source - Error
- Event
- Execution
- how a box does an action
- Family
- the box families anybox knows how to talk to
- Firmware
- Quirk
- a way this box behaves differently that anybox can’t hide, so it tells you instead of smoothing it over
- Recv
Timeout Error - Stable
Id - Timing
- TryRecv
Error
Functions§
- connect
- connects to the first box found, in port order
- find
- every box on this machine in port order. each one gets opened, described and closed again