forked from AndersMalmgren/FreePIE
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d43a68
commit 256b157
Showing
6 changed files
with
131 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters