gearvr-controller 0.1.0

Read the Samsung Gear VR Controller (ET-YO324) over Bluetooth LE: packet decoding, orientation tracking and a btleplug transport
Documentation
//! Read the Samsung Gear VR Controller (ET-YO324) over Bluetooth LE.
//!
//! The crate has three layers:
//!
//! - [`protocol`] decodes the controller's 60-byte data packets. It has no dependencies.
//! - [`orientation`] turns the gyroscope and accelerometer samples into an orientation.
//! - [`ble`] (feature `ble`, on by default) finds the controller, connects, and delivers
//!   packets, using [btleplug](https://docs.rs/btleplug) and tokio.
//!
//! [`sim`] produces synthetic packets so applications can be developed without the hardware.
//!
//! # Example
//!
//! Decoding and tracking need no Bluetooth, so this runs anywhere:
//!
//! ```
//! use gearvr_controller::{sim::Simulator, Orientation, Packet};
//!
//! let mut controller = Simulator::new();
//! let mut orientation = Orientation::new();
//! for _ in 0..100 {
//!     let bytes = controller.next_bytes(); // with real hardware: a Bluetooth notification
//!     let packet = Packet::parse(&bytes).unwrap();
//!     orientation.update(&packet);
//! }
//! let e = orientation.euler();
//! println!("yaw {:.0}°  pitch {:.0}°  roll {:.0}°", e.yaw.to_degrees(), e.pitch.to_degrees(), e.roll.to_degrees());
//! ```
//!
//! See [`ble`] for the same loop driven by a real controller.
//!
//! # Axes
//!
//! Sensor values are in the controller's own frame: **x** points right, **y** points forward
//! out of the tip, and **z** points up out of the touchpad face. The accelerometer reads
//! about +9.8 m/s² on whichever axis points up.

#[cfg(feature = "ble")]
pub mod ble;
mod event;
pub mod orientation;
pub mod protocol;
pub mod sim;

pub use event::Event;
pub use orientation::{Euler, Orientation, Quat};
pub use protocol::{Buttons, Command, ImuSample, Packet, ParseError, Touch};