Trying to get the rift to work with C# for FreePIE

Post Reply
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Trying to get the rift to work with C# for FreePIE

Post by CyberVillain »

Found this lib https://github.com/Entroper/VRapper

It uses the Hid device directly, I cant manage to get anything when I read.. I tried

Code: Select all

var trackerHid =
    HidDevices.Enumerate()
                .FirstOrDefault(
                    h => h.Attributes.VendorId == (int)SensorID.VendorID && h.Attributes.ProductId == (int)SensorID.ProductID);

var data = trackerHid.Read();
but it read blocks the thread and never returns.

Btw, are there any static C port of the lib? Could use that from c#
User avatar
brantlew
Petrif-Eyed
Posts: 2221
Joined: Sat Sep 17, 2011 9:23 pm
Location: Menlo Park, CA

Re: Trying to get the rift to work with C# for FreePIE

Post by brantlew »

I've been thinking about doing this, but never got around to it. If you download the Oculus-enabled Unity SDK you can pull an Oculus interface DLL out of there and it should also contain C# import glue code as well which will make this task pretty simple.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Trying to get the rift to work with C# for FreePIE

Post by CyberVillain »

brantlew wrote:I've been thinking about doing this, but never got around to it. If you download the Oculus-enabled Unity SDK you can pull an Oculus interface DLL out of there and it should also contain C# import glue code as well which will make this task pretty simple.
There is a OculusPlugin.dll in there but it cant be loaded?
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Trying to get the rift to work with C# for FreePIE

Post by CyberVillain »

Found it, but it got dependencies to Unity, not something we want in FreePIE
User avatar
brantlew
Petrif-Eyed
Posts: 2221
Joined: Sat Sep 17, 2011 9:23 pm
Location: Menlo Park, CA

Re: Trying to get the rift to work with C# for FreePIE

Post by brantlew »

Bummer. You should check the Oculus forums. I know there are some guys working on Java and C# linkages that might be helpful.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Trying to get the rift to work with C# for FreePIE

Post by CyberVillain »

Will do thanks
StephaneLX
One Eyed Hopeful
Posts: 39
Joined: Mon Sep 03, 2012 10:38 am
Location: Montreal

Re: Trying to get the rift to work with C# for FreePIE

Post by StephaneLX »

CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Trying to get the rift to work with C# for FreePIE

Post by CyberVillain »

StephaneLX wrote:You can take a look at: https://github.com/SiS-Shadowman/RiftDotNet
Checked it, but it had a lot of strange dependencies, will have a crack at the cpp code when I get the time. Compile a static C wrapper for it
Daloots
One Eyed Hopeful
Posts: 21
Joined: Sat Sep 22, 2012 5:38 am

Re: Trying to get the rift to work with C# for FreePIE

Post by Daloots »

The RiftDotNet code looks amazing and very complete, but I also didn't want the dependency toward SharpDx.
So I did a very barebone DLL and C# wrapper, just to extract the HMD orientation.

You can get the code (or contribute) at:
https://github.com/davyloots/riftsharp

I didn't include the actual LibOVR code project from the Oculus SDK because I'm not sure about the licensing, so you'll need to import that lib project before compiling.

If you just want to use it, here's a compiled version:
http://rcdeskpilot.com/system/files/RiftSharp.zip

The RiftSharpDll.dll is the C++ dll, RiftSharp.dll is the wrapper assembly. Just add a reference to that last one and copy the C++ dll to your binary folder.
Code use is as folows:

Code: Select all

using RiftSharp;

//.....
YawPitchRoll ypr = Hmd.Instance.YawPitchRoll;
float yaw=ypr.Yaw;
This is just a quick implementation, not even error handling is present. I'm not a very competent coder, so use at your own risk ;) .
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Trying to get the rift to work with C# for FreePIE

Post by CyberVillain »

I missed this post so I created my own wrapper :D Nice work btw!

Brantlew, maybe this could be integrated into the SDK becasue it will make it work with most languanges under win32

header:
https://github.com/AndersMalmgren/FreeP ... _freepie.h

source:
https://github.com/AndersMalmgren/FreeP ... reepie.cpp

C#:
https://github.com/AndersMalmgren/FreeP ... sVR/Api.cs
Post Reply

Return to “Oculus VR”