Skip to content

Commit 8acee89

Browse files
committed
initial commit
0 parents  commit 8acee89

10 files changed

Lines changed: 9254 additions & 0 deletions

File tree

.gitignore

Lines changed: 405 additions & 0 deletions
Large diffs are not rendered by default.

OVRSharp.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.808.1
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OVRSharp", "OVRSharp\OVRSharp.csproj", "{DA0D98B4-9F23-414E-9B9F-CD8F113992BE}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{DA0D98B4-9F23-414E-9B9F-CD8F113992BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{DA0D98B4-9F23-414E-9B9F-CD8F113992BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{DA0D98B4-9F23-414E-9B9F-CD8F113992BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{DA0D98B4-9F23-414E-9B9F-CD8F113992BE}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {93984CAB-8CA9-430A-8166-5E2B339CA8A8}
24+
EndGlobalSection
25+
EndGlobal

OVRSharp/Application.cs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
using OVRSharp.Exceptions;
2+
using Valve.VR;
3+
4+
namespace OVRSharp
5+
{
6+
public class Application
7+
{
8+
public enum ApplicationType
9+
{
10+
/// <summary>
11+
/// A 3D application that will be drawing an environment.
12+
/// </summary>
13+
Scene = EVRApplicationType.VRApplication_Scene,
14+
15+
/// <summary>
16+
/// An application that only interacts with overlays or the dashboard.
17+
/// </summary>
18+
Overlay = EVRApplicationType.VRApplication_Overlay,
19+
20+
/// <summary>
21+
/// The application will not start SteamVR. If it is not already running
22+
/// the call with VR_Init will fail with VRInitError_Init_NoServerForBackgroundApp.
23+
/// </summary>
24+
Background = EVRApplicationType.VRApplication_Background,
25+
26+
/// <summary>
27+
/// The application will start up even if no hardware is present. Only the IVRSettings
28+
/// and IVRApplications interfaces are guaranteed to work. This application type is
29+
/// appropriate for things like installers.
30+
/// </summary>
31+
Utility = EVRApplicationType.VRApplication_Utility,
32+
33+
Other = EVRApplicationType.VRApplication_Other
34+
}
35+
36+
public readonly ApplicationType Type;
37+
public readonly CVRSystem OVRSystem;
38+
39+
/// <summary>
40+
/// Instantiate and initialize a new <see cref="Application"/>.
41+
/// Internally, this will initialize the OpenVR API with the specified
42+
/// <paramref name="type"/> and <paramref name="startupInfo"/>.
43+
/// </summary>
44+
///
45+
/// <param name="type"></param>
46+
/// <param name="startupInfo"></param>
47+
public Application(ApplicationType type, string startupInfo = "")
48+
{
49+
// Attempt to initialize a new OpenVR context
50+
EVRInitError err = EVRInitError.None;
51+
OVRSystem = OpenVR.Init(ref err, (EVRApplicationType)type, startupInfo);
52+
53+
if (err != EVRInitError.None)
54+
throw new OpenVRSystemException<EVRInitError>("An error occurred while initializing the OpenVR runtime.", err);
55+
}
56+
57+
public void Shutdown()
58+
{
59+
OpenVR.Shutdown();
60+
}
61+
}
62+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace OVRSharp.Exceptions
6+
{
7+
class OpenVRSystemException<ErrorType> : Exception
8+
{
9+
public readonly ErrorType Error;
10+
11+
public OpenVRSystemException() : base() { }
12+
public OpenVRSystemException(string message) : base(message) { }
13+
public OpenVRSystemException(string message, Exception inner) : base(message, inner) { }
14+
15+
public OpenVRSystemException(string message, ErrorType error) : this(message)
16+
{
17+
Error = error;
18+
}
19+
}
20+
}

OVRSharp/Math/Transforms.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System;
2+
3+
namespace OVRSharp.Math
4+
{
5+
public class Transforms
6+
{
7+
public Transforms()
8+
{
9+
}
10+
}
11+
}

OVRSharp/OVRSharp.csproj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<None Update="openvr_api.dll">
9+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
10+
</None>
11+
</ItemGroup>
12+
<ItemGroup>
13+
<Folder Include="Math\" />
14+
</ItemGroup>
15+
</Project>

0 commit comments

Comments
 (0)