mirror of
https://github.com/mii443/rust-openvr.git
synced 2025-08-23 00:35:31 +00:00
Fixed functions calls and added VR_init
This commit is contained in:
32
src/lib.rs
32
src/lib.rs
@ -1,3 +1,33 @@
|
||||
|
||||
|
||||
extern crate openvr_sys;
|
||||
extern crate openvr_sys;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct IVRSystem(*const ());
|
||||
|
||||
impl IVRSystem {
|
||||
/// Initalize the IVR System
|
||||
pub fn init() -> Result<IVRSystem, openvr_sys::HmdError> {
|
||||
let mut err = openvr_sys::HmdError::None;
|
||||
let ptr = unsafe {
|
||||
openvr_sys::VR_Init(&mut err as *mut openvr_sys::HmdError)
|
||||
};
|
||||
if ptr.is_null() {
|
||||
Err(err)
|
||||
} else {
|
||||
Ok(IVRSystem(ptr))
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the window bounds
|
||||
pub fn bounds(&self) -> ((i32, i32), (u32, u32)) {
|
||||
unsafe {
|
||||
let ((mut x, mut y), (mut w, mut h)) = ((0, 0), (0, 0));
|
||||
openvr_sys::VR_IVRSystem_GetWindowBounds(
|
||||
self.0, &mut x, &mut y, &mut w, &mut h
|
||||
);
|
||||
((x, y), (w, h))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user