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

Structs

  • A Wii Remote device address.
  • Represents the channels that can be opened on a Device.
  • A connected Wii Remote.
  • 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.
  • Motion Plus sensor normalization and calibration values.

Enums

  • The Wii Remote LED lights.

Type Aliases

  • The main result type used by this crate.