Expand description
Read the Samsung Gear VR Controller (ET-YO324) over Bluetooth LE.
The crate has three layers:
protocoldecodes the controller’s 60-byte data packets. It has no dependencies.orientationturns the gyroscope and accelerometer samples into an orientation.ble(featureble, on by default) finds the controller, connects, and delivers packets, using 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.
Re-exports§
pub use orientation::Euler;pub use orientation::Orientation;pub use orientation::Quat;pub use protocol::Buttons;pub use protocol::Command;pub use protocol::ImuSample;pub use protocol::Packet;pub use protocol::ParseError;pub use protocol::Touch;
Modules§
- ble
- Bluetooth LE transport, built on btleplug and tokio.
- orientation
- Orientation tracking from the gyroscope and accelerometer.
- protocol
- The controller’s Bluetooth LE wire format.
- sim
- A simulated controller, for developing and testing without the hardware.
Enums§
- Event
- What a connection to a controller reports.