Expose well known component names

This commit is contained in:
Benjamin Saunders
2017-07-29 16:51:06 -07:00
parent eda7efc728
commit eb1f18a4ea
3 changed files with 19 additions and 0 deletions

View File

@ -17,6 +17,7 @@ description = "A safe binding for openvr."
[dependencies]
openvr_sys = { git = "https://github.com/Ralith/rust-openvr-sys.git", branch = "enum-rename" }
lazy_static = "0.2.8"
[dev_dependencies]
glium = "0.14.0"

View File

@ -1,4 +1,6 @@
extern crate openvr_sys;
#[macro_use]
extern crate lazy_static;
use std::sync::atomic::{Ordering, AtomicBool, ATOMIC_BOOL_INIT};
use std::{fmt, error, ptr, mem};

View File

@ -259,3 +259,19 @@ pub mod component_properties {
pub const IS_PRESSED: ComponentProperties = sys::EVRComponentProperty_VRComponentProperty_IsPressed;
pub const IS_SCROLLED: ComponentProperties = sys::EVRComponentProperty_VRComponentProperty_IsScrolled;
}
pub mod component {
pub mod controller {
use std::ffi::CStr;
use openvr_sys as sys;
// TODO: Real constants
lazy_static! {
pub static ref GDC2015: &'static CStr = unsafe { CStr::from_bytes_with_nul_unchecked(sys::k_pch_Controller_Component_GDC2015) };
pub static ref BASE: &'static CStr = unsafe { CStr::from_bytes_with_nul_unchecked(sys::k_pch_Controller_Component_Base) };
pub static ref TIP: &'static CStr = unsafe { CStr::from_bytes_with_nul_unchecked(sys::k_pch_Controller_Component_Tip) };
pub static ref HAND_GRIP: &'static CStr = unsafe { CStr::from_bytes_with_nul_unchecked(sys::k_pch_Controller_Component_HandGrip) };
pub static ref STATUS: &'static CStr = unsafe { CStr::from_bytes_with_nul_unchecked(sys::k_pch_Controller_Component_Status) };
}
}
}