mirror of
https://github.com/mii443/rust-openvr.git
synced 2025-08-24 00:59:25 +00:00
use #[repr(C)]
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
#![crate_name = "ovr"]
|
#![crate_name = "ovr"]
|
||||||
#![crate_type = "lib"]
|
#![crate_type = "lib"]
|
||||||
#![feature(link_args)]
|
#![feature(link_args)]
|
||||||
|
#![allow(non_uppercase_statics)]
|
||||||
|
|
||||||
extern crate cgmath;
|
extern crate cgmath;
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
@ -39,18 +40,21 @@ pub mod ll {
|
|||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
|
|
||||||
#[deriving(Clone, Default)]
|
#[deriving(Clone, Default)]
|
||||||
|
#[repr(C)]
|
||||||
pub struct Vector2i {
|
pub struct Vector2i {
|
||||||
pub x: c_int,
|
pub x: c_int,
|
||||||
pub y: c_int
|
pub y: c_int
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Clone, Default)]
|
#[deriving(Clone, Default)]
|
||||||
|
#[repr(C)]
|
||||||
pub struct Sizei {
|
pub struct Sizei {
|
||||||
pub x: c_int,
|
pub x: c_int,
|
||||||
pub y: c_int
|
pub y: c_int
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Clone, Default)]
|
#[deriving(Clone, Default)]
|
||||||
|
#[repr(C)]
|
||||||
pub struct Recti {
|
pub struct Recti {
|
||||||
pub pos: Vector2i,
|
pub pos: Vector2i,
|
||||||
pub size: Sizei
|
pub size: Sizei
|
||||||
@ -58,23 +62,28 @@ pub mod ll {
|
|||||||
|
|
||||||
|
|
||||||
#[deriving(Clone, Default)]
|
#[deriving(Clone, Default)]
|
||||||
|
#[repr(C)]
|
||||||
pub struct FovPort {
|
pub struct FovPort {
|
||||||
pub upTan: c_float,
|
pub up_tan: c_float,
|
||||||
pub downTan: c_float,
|
pub down_tan: c_float,
|
||||||
pub leftTan: c_float,
|
pub left_tan: c_float,
|
||||||
pub rightTan: c_float
|
pub right_tan: c_float
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Clone, Default)]
|
#[deriving(Clone, Default)]
|
||||||
|
#[repr(C)]
|
||||||
pub struct Vector2f {pub x: c_float, pub y: c_float}
|
pub struct Vector2f {pub x: c_float, pub y: c_float}
|
||||||
|
|
||||||
#[deriving(Clone, Default)]
|
#[deriving(Clone, Default)]
|
||||||
|
#[repr(C)]
|
||||||
pub struct Vector3f {pub x: c_float, pub y: c_float, pub z: c_float}
|
pub struct Vector3f {pub x: c_float, pub y: c_float, pub z: c_float}
|
||||||
|
|
||||||
#[deriving(Clone, Default)]
|
#[deriving(Clone, Default)]
|
||||||
|
#[repr(C)]
|
||||||
pub struct Quaternionf {pub x: c_float, pub y: c_float, pub z: c_float, pub w: c_float}
|
pub struct Quaternionf {pub x: c_float, pub y: c_float, pub z: c_float, pub w: c_float}
|
||||||
|
|
||||||
#[deriving(Clone, Default)]
|
#[deriving(Clone, Default)]
|
||||||
|
#[repr(C)]
|
||||||
pub struct Matrix4f {pub m11: c_float, pub m12: c_float, pub m13: c_float, pub m14: c_float,
|
pub struct Matrix4f {pub m11: c_float, pub m12: c_float, pub m13: c_float, pub m14: c_float,
|
||||||
pub m21: c_float, pub m22: c_float, pub m23: c_float, pub m24: c_float,
|
pub m21: c_float, pub m22: c_float, pub m23: c_float, pub m24: c_float,
|
||||||
pub m31: c_float, pub m32: c_float, pub m33: c_float, pub m34: c_float,
|
pub m31: c_float, pub m32: c_float, pub m33: c_float, pub m34: c_float,
|
||||||
@ -82,12 +91,14 @@ pub mod ll {
|
|||||||
|
|
||||||
|
|
||||||
#[deriving(Clone, Default)]
|
#[deriving(Clone, Default)]
|
||||||
|
#[repr(C)]
|
||||||
pub struct Posef {
|
pub struct Posef {
|
||||||
pub orientation: Quaternionf,
|
pub orientation: Quaternionf,
|
||||||
pub position: Vector3f
|
pub position: Vector3f
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Clone, Default)]
|
#[deriving(Clone, Default)]
|
||||||
|
#[repr(C)]
|
||||||
pub struct PoseState {
|
pub struct PoseState {
|
||||||
pub pose: Posef,
|
pub pose: Posef,
|
||||||
pub angular_velocity: Vector3f,
|
pub angular_velocity: Vector3f,
|
||||||
@ -98,6 +109,7 @@ pub mod ll {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Clone, Default)]
|
#[deriving(Clone, Default)]
|
||||||
|
#[repr(C)]
|
||||||
pub struct SensorState {
|
pub struct SensorState {
|
||||||
pub predicted: PoseState,
|
pub predicted: PoseState,
|
||||||
pub recorded: PoseState,
|
pub recorded: PoseState,
|
||||||
@ -107,6 +119,7 @@ pub mod ll {
|
|||||||
|
|
||||||
pub enum Hmd {}
|
pub enum Hmd {}
|
||||||
|
|
||||||
|
#[repr(C)]
|
||||||
pub struct HmdDesc {
|
pub struct HmdDesc {
|
||||||
pub handle: *const Hmd,
|
pub handle: *const Hmd,
|
||||||
pub hmd_type: c_int,
|
pub hmd_type: c_int,
|
||||||
@ -145,6 +158,7 @@ pub mod ll {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[repr(C)]
|
||||||
pub struct SensorDesc {
|
pub struct SensorDesc {
|
||||||
pub vendor_id: c_short,
|
pub vendor_id: c_short,
|
||||||
pub product_id: c_short,
|
pub product_id: c_short,
|
||||||
@ -152,6 +166,7 @@ pub mod ll {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Clone, Default)]
|
#[deriving(Clone, Default)]
|
||||||
|
#[repr(C)]
|
||||||
pub struct EyeRenderDesc {
|
pub struct EyeRenderDesc {
|
||||||
pub eye: c_uint,
|
pub eye: c_uint,
|
||||||
pub fov: FovPort,
|
pub fov: FovPort,
|
||||||
@ -160,12 +175,14 @@ pub mod ll {
|
|||||||
pub view_adjust: Vector3f
|
pub view_adjust: Vector3f
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[repr(C)]
|
||||||
pub struct RenderApiConfigHeader {
|
pub struct RenderApiConfigHeader {
|
||||||
pub render_api_type: c_uint,
|
pub render_api_type: c_uint,
|
||||||
pub rt_size: Sizei,
|
pub rt_size: Sizei,
|
||||||
pub multisample: c_int,
|
pub multisample: c_int,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[repr(C)]
|
||||||
pub struct RenderApiConfig {
|
pub struct RenderApiConfig {
|
||||||
pub header: RenderApiConfigHeader,
|
pub header: RenderApiConfigHeader,
|
||||||
pub display: *const c_void,
|
pub display: *const c_void,
|
||||||
@ -173,6 +190,7 @@ pub mod ll {
|
|||||||
pub padd: [*const c_void, ..6]
|
pub padd: [*const c_void, ..6]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[repr(C)]
|
||||||
pub struct FrameTiming {
|
pub struct FrameTiming {
|
||||||
pub delta_seconds: f32,
|
pub delta_seconds: f32,
|
||||||
pub this_frame_seconds: f64,
|
pub this_frame_seconds: f64,
|
||||||
@ -182,12 +200,14 @@ pub mod ll {
|
|||||||
pub eye_scanout_seconds: [f64, ..2]
|
pub eye_scanout_seconds: [f64, ..2]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[repr(C)]
|
||||||
pub struct TextureHeader {
|
pub struct TextureHeader {
|
||||||
pub render_api_type: c_uint,
|
pub render_api_type: c_uint,
|
||||||
pub size: Sizei,
|
pub size: Sizei,
|
||||||
pub viewport: Recti
|
pub viewport: Recti
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[repr(C)]
|
||||||
pub struct Texture {
|
pub struct Texture {
|
||||||
pub header: TextureHeader,
|
pub header: TextureHeader,
|
||||||
pub texture_id: u32,
|
pub texture_id: u32,
|
||||||
@ -250,7 +270,7 @@ pub mod ll {
|
|||||||
pub fn ovrHmd_StopSensor(hmd: *mut Hmd);
|
pub fn ovrHmd_StopSensor(hmd: *mut Hmd);
|
||||||
pub fn ovrHmd_ResetSensor(hmd: *mut Hmd);
|
pub fn ovrHmd_ResetSensor(hmd: *mut Hmd);
|
||||||
pub fn ovrHmd_GetSensorState(hmd: *mut Hmd,
|
pub fn ovrHmd_GetSensorState(hmd: *mut Hmd,
|
||||||
absTime: c_double) -> SensorState;
|
abs_time: c_double) -> SensorState;
|
||||||
pub fn ovrHmd_GetSensorDesc(hmd: *mut Hmd,
|
pub fn ovrHmd_GetSensorDesc(hmd: *mut Hmd,
|
||||||
sensor_desc: *mut SensorDesc) -> bool;
|
sensor_desc: *mut SensorDesc) -> bool;
|
||||||
pub fn ovrHmd_GetDesc(hmd: *mut Hmd,
|
pub fn ovrHmd_GetDesc(hmd: *mut Hmd,
|
||||||
@ -275,7 +295,7 @@ pub mod ll {
|
|||||||
zfar: c_float,
|
zfar: c_float,
|
||||||
right_handed: bool) -> Matrix4f;
|
right_handed: bool) -> Matrix4f;
|
||||||
|
|
||||||
pub fn ovr_WaitTillTime(absTime: c_double) -> c_double;
|
pub fn ovr_WaitTillTime(abs_time: c_double) -> c_double;
|
||||||
pub fn ovr_GetTimeInSeconds() -> c_double;
|
pub fn ovr_GetTimeInSeconds() -> c_double;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -434,9 +454,9 @@ impl Hmd {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_sensor_state(&self, absTime: f64) -> SensorState {
|
pub fn get_sensor_state(&self, abs_time: f64) -> SensorState {
|
||||||
unsafe {
|
unsafe {
|
||||||
SensorState::from_ll(ll::ovrHmd_GetSensorState(self.ptr, absTime))
|
SensorState::from_ll(ll::ovrHmd_GetSensorState(self.ptr, abs_time))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1110,19 +1130,19 @@ pub struct FovPort {
|
|||||||
impl FovPort {
|
impl FovPort {
|
||||||
fn from_ll(ll: ll::FovPort) -> FovPort {
|
fn from_ll(ll: ll::FovPort) -> FovPort {
|
||||||
FovPort {
|
FovPort {
|
||||||
up: ll.upTan as f32,
|
up: ll.up_tan as f32,
|
||||||
down: ll.downTan as f32,
|
down: ll.down_tan as f32,
|
||||||
left: ll.leftTan as f32,
|
left: ll.left_tan as f32,
|
||||||
right: ll.rightTan as f32
|
right: ll.right_tan as f32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_ll(&self) -> ll::FovPort {
|
fn to_ll(&self) -> ll::FovPort {
|
||||||
ll::FovPort {
|
ll::FovPort {
|
||||||
upTan: self.up as c_float,
|
up_tan: self.up as c_float,
|
||||||
downTan: self.down as c_float,
|
down_tan: self.down as c_float,
|
||||||
leftTan: self.left as c_float,
|
left_tan: self.left as c_float,
|
||||||
rightTan: self.right as c_float
|
right_tan: self.right as c_float
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user