Skip to content

Commit

Permalink
Added Oculus VR Plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
AndersMalmgren committed Jul 2, 2013
1 parent 8d43a68 commit 256b157
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 1 deletion.
3 changes: 2 additions & 1 deletion BuildTools/build_output.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@
$(Lib)\FreeTrack\*.dll;
$(Lib)\Zeiss\*.dll;
$(Lib)\YEI3-Space\*.dll;
$(Lib)\IO\Binaries\Release-DllMultiThreadRuntime\*.dll">
$(Lib)\IO\Binaries\Release-DllMultiThreadRuntime\*.dll;
$(Lib)\OculusVR\Binaries\*.dll">
</DependecieFiles>
</ItemGroup>
<Copy SourceFiles="@(DependecieFiles)" DestinationFiles="@(DependecieFiles -> '$(BuildDir)\%(Filename)%(Extension)')"/>
Expand Down
3 changes: 3 additions & 0 deletions FreePIE.Core.Plugins/FreePIE.Core.Plugins.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
<Compile Include="MemoryMapping\WorkerProcess.cs" />
<Compile Include="MouseKeyIO.cs" />
<Compile Include="MousePlugin.cs" />
<Compile Include="OculusPlugin.cs" />
<Compile Include="OculusVR\Api.cs" />
<Compile Include="OculusVR\OVR3DOF.cs" />
<Compile Include="Plugin.cs" />
<Compile Include="PPJoyPlugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
67 changes: 67 additions & 0 deletions FreePIE.Core.Plugins/OculusPlugin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FreePIE.Core.Contracts;
using FreePIE.Core.Plugins.OculusVR;

namespace FreePIE.Core.Plugins
{
[GlobalType(Type = typeof(OculusGlobal))]
public class OculusPlugin : Plugin
{
public override object CreateGlobal()
{
return new OculusGlobal(this);
}

public override string FriendlyName
{
get { return "Oculus VR"; }
}

public override Action Start()
{
if (!Api.Init())
throw new Exception("Oculus VR SDK failed to init");

return null;
}

public override void Stop()
{
Api.Dispose();
}

public override void DoBeforeNextExecute()
{
Data = Api.Read();
OnUpdate();
}

public void ReCenter()
{
Api.ReCenter();
}

public OculusVr3Dof Data
{
get; private set;
}
}

[Global(Name = "oculusVR")]
public class OculusGlobal : UpdateblePluginGlobal<OculusPlugin>
{
public OculusGlobal(OculusPlugin plugin) : base(plugin){}

public float yaw { get { return plugin.Data.Yaw; } }
public float pitch { get { return plugin.Data.Pitch; } }
public float roll { get { return plugin.Data.Roll; } }

public void ReCenter()
{
plugin.ReCenter();
}
}
}
42 changes: 42 additions & 0 deletions FreePIE.Core.Plugins/OculusVR/Api.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace FreePIE.Core.Plugins.OculusVR
{
public static class Api
{
[DllImport("OVRFreePIE.dll")]
private extern static int ovr_freepie_init();
[DllImport("OVRFreePIE.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int ovr_freepie_read(out OculusVr3Dof output);
[DllImport("OVRFreePIE.dll")]
private extern static int ovr_freepie_destroy();
[DllImport("OVRFreePIE.dll")]
private extern static int ovr_freepie_reset_orientation();

public static bool Init()
{
return ovr_freepie_init() == 0;
}

public static OculusVr3Dof Read()
{
OculusVr3Dof output;
ovr_freepie_read(out output);
return output;
}

public static bool Dispose()
{
return ovr_freepie_destroy() == 0;
}

public static bool ReCenter()
{
return ovr_freepie_reset_orientation() == 0;
}
}
}
16 changes: 16 additions & 0 deletions FreePIE.Core.Plugins/OculusVR/OVR3DOF.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace FreePIE.Core.Plugins.OculusVR
{
[StructLayout(LayoutKind.Sequential)]
public struct OculusVr3Dof
{
public float Yaw;
public float Pitch;
public float Roll;
}
}
1 change: 1 addition & 0 deletions FreePIE.GUI/FreePIE.GUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ copy "$(SolutionDir)\Lib\FreeTrack\*.dll" "$(TargetDir)"
copy "$(SolutionDir)\Lib\Zeiss\*.dll" "$(TargetDir)"
copy "$(SolutionDir)\Lib\YEI3-Space\*.dll" "$(TargetDir)"
copy "$(SolutionDir)\Lib\IO\Binaries\Release-DllMultiThreadRuntime\*.dll" "$(TargetDir)"
copy "$(SolutionDir)\Lib\OculusVR\Binaries\*.dll" "$(TargetDir)"
</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down

0 comments on commit 256b157

Please sign in to comment.