1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
use std::sync::Arc; use std::cell::RefCell; use VRPose; pub type VRGamepadPtr = Arc<RefCell<VRGamepad>>; pub trait VRGamepad { fn id(&self) -> u64; fn name(&self) -> String; fn state(&self) -> VRGamepadState; } #[derive(Debug, Clone)] #[cfg_attr(feature = "serde-serialization", derive(Deserialize, Serialize))] pub struct VRGamepadState { pub connected: bool, pub timestamp: f64, pub axes: Vec<f64>, pub buttons: Vec<VRGamepadButton>, pub pose: VRPose } impl Default for VRGamepadState { fn default() -> VRGamepadState { VRGamepadState { connected: false, timestamp: 0.0, axes: Vec::new(), buttons: Vec::new(), pose: VRPose::default() } } } #[derive(Debug, Clone)] #[cfg_attr(feature = "serde-serialization", derive(Deserialize, Serialize))] pub struct VRGamepadButton { pub pressed: bool, pub touched: bool }