commit 7d4f238b9b50c9ea9b22d34e65ddaeb7f1c773f5 Author: Colin Sherratt Date: Mon Jan 27 03:12:35 2014 -0500 inital diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ee53b76 --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ + +LIBOVR_INCLUDE_PATH=../OculusSDK/LibOVR/Include/ +LIBOVR_LIB_PATH=../OculusSDK/LibOVR/Lib/Linux/Release/x86_64/libovr.a + + +all: test + +libovr_wrapper.a: wrapper.o + ar rcs libovr_wrapper.a wrapper.o + +wrapper.o: wrapper.cpp + c++ -I $(LIBOVR_INCLUDE_PATH) -c -o wrapper.o wrapper.cpp + +libovr-rs-44316370-0.1.so: libovr_wrapper.a + rustc lib.rs + +test: test.rs libovr-rs-44316370-0.1.so + rustc test.rs -L . --link-args="-lovr -ludev -lstdc++ -lc -lX11 -lm -lpthread -lXinerama" diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..dbe3774 --- /dev/null +++ b/Readme.md @@ -0,0 +1,6 @@ +This projects goal is to provide Rift bindings for Rust. + +Right now it is none functional, only grabbing a few pointers from the framework. + +libovr.a is not supplied with this library for legal reasons. You may obtain a copy from +https://developer.oculusvr.com/ . \ No newline at end of file diff --git a/lib.rs b/lib.rs new file mode 100644 index 0000000..c840aaa --- /dev/null +++ b/lib.rs @@ -0,0 +1,26 @@ +#[crate_id = "ovr-rs#0.1"]; +#[crate_type = "lib"]; +#[feature(link_args)]; + +pub enum DeviceManager {} +pub enum HMDInfo {} +pub enum HMDDevice {} +pub enum SensorDevice {} +pub enum SensorFusion {} + + +#[link(name="ovr_wrapper")] +extern {} + +#[link(name="ovr")] +extern {} + +extern "C" { + pub fn OVR_system_init(); + pub fn OVR_DeviceManager_Create() -> *DeviceManager; + pub fn OVR_DeviceManager_EnumerateDevices(dm :*DeviceManager) -> *HMDDevice; + pub fn OVR_HDMDevice_GetDeviceInfo(hmd: *HMDDevice) -> *HMDInfo; + pub fn OVR_HDMDevice_GetSensor(hmd: *HMDDevice) -> *SensorDevice; + pub fn OVR_SensorFusion() -> *SensorFusion; + pub fn OVR_SensorFusion_AttachToSensor(sf: *SensorFusion, sd: *SensorDevice) -> bool; +} \ No newline at end of file diff --git a/test.rs b/test.rs new file mode 100644 index 0000000..8c0ba98 --- /dev/null +++ b/test.rs @@ -0,0 +1,17 @@ + + +extern mod ovr = "ovr-rs"; + +fn main() +{ + unsafe { + ovr::OVR_system_init(); + + let dm = ovr::OVR_DeviceManager_Create(); + println!("dm {:?}", dm); + + let em = ovr::OVR_DeviceManager_EnumerateDevices(dm); + println!("dm {:?}", em); + + } +} \ No newline at end of file diff --git a/wrapper.cpp b/wrapper.cpp new file mode 100644 index 0000000..16d7735 --- /dev/null +++ b/wrapper.cpp @@ -0,0 +1,43 @@ +#include "OVR.h" + +extern "C" +{ + void OVR_system_init(void) + { + OVR::System::Init(OVR::Log::ConfigureDefaultLog(OVR::LogMask_All)); + } + + OVR::DeviceManager* OVR_DeviceManager_Create(void) + { + return OVR::DeviceManager::Create(); + } + + OVR::HMDDevice* OVR_DeviceManager_EnumerateDevices(OVR::DeviceManager* pManager) + { + return pManager->EnumerateDevices().CreateDevice(); + } + + // not pointer on purpose! + OVR::HMDInfo* OVR_HDMDevice_GetDeviceInfo(OVR::HMDDevice* pHMD) + { + OVR::HMDInfo *hdm = new OVR::HMDInfo; + pHMD->GetDeviceInfo(hdm); + return hdm; + } + + OVR::SensorDevice* OVR_HDMDevice_GetSensor(OVR::HMDDevice* pHMD) + { + return pHMD->GetSensor(); + } + + OVR::SensorFusion* OVR_SensorFusion(OVR::HMDDevice* pHMD) + { + OVR::SensorFusion* SFusion = new OVR::SensorFusion; + return SFusion; + } + + bool OVR_SensorFusion_AttachToSensor(OVR::SensorFusion* SFusion, OVR::SensorDevice *pSensor) + { + return (*SFusion).AttachToSensor(pSensor); + } +} \ No newline at end of file