Crate xwiimote

Crate xwiimote 

Source
Expand description

This library provides a safe Rust interface to the xwiimote user-space library.

§Examples

Connect to the first Wii Remote found and print its battery level.

use xwiimote::{Device, Monitor};
use futures_util::TryStreamExt;

// A monitor enumerates the addresses of all connected Wii Remotes.
let mut monitor = Monitor::enumerate()?;
match monitor.try_next().await {
    Ok(Some(address)) => {
        // Connect to the Wii Remote specified by `address`.
        let device = Device::connect(&address)?;
        let level = device.battery()?;
        println!("the battery level is {}%", level);
    }
    Ok(None) => println!("found no connected device"),
    Err(e) => eprintln!("could not enumerate devices: {e}"),
};

Print device addresses as new Wii Remotes are discovered.

use xwiimote::{Device, Monitor};
use futures_util::TryStreamExt;

let mut monitor = Monitor::discover()?;
while let Ok(Some(address)) = monitor.try_next().await {
    println!("found device at {address:?}");
}

Modules§

events

Structs§

Address
A Wii Remote device address.
Channels
Represents the channels that can be opened on a Device.
Device
A connected Wii Remote.
Monitor
Enumerates the addresses of connected Wii Remotes and optionally streams device addresses as new devices are discovered. The same address may be produced multiple times.
MotionPlusNormalization
Motion Plus sensor normalization and calibration values.

Enums§

Led
The Wii Remote LED lights.

Type Aliases§

Result
The main result type used by this crate.