mirror of
https://github.com/mii443/rust-openvr.git
synced 2025-08-23 00:35:31 +00:00
inital
This commit is contained in:
18
Makefile
Normal file
18
Makefile
Normal file
@ -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"
|
6
Readme.md
Normal file
6
Readme.md
Normal file
@ -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/ .
|
26
lib.rs
Normal file
26
lib.rs
Normal file
@ -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;
|
||||
}
|
17
test.rs
Normal file
17
test.rs
Normal file
@ -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);
|
||||
|
||||
}
|
||||
}
|
43
wrapper.cpp
Normal file
43
wrapper.cpp
Normal file
@ -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<OVR::HMDDevice>().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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user