Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ClientKit/BuildConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ internal class BuildConstants
public const string FrameworkDescription = ".NET 2.0";
#elif NET45
public const string FrameworkDescription = ".NET 4.5";
#elif WINDOWS_UWP
public const string FrameworkDescription = ".Net 4.6";
#else
#error "Building for some unrecognized .NET version!"
#endif
Expand Down
54 changes: 44 additions & 10 deletions ClientKit/ClientKit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
/// See the License for the specific language governing permissions and
/// limitations under the License.
/// </copyright>

using System;
using System;
using System.Runtime.InteropServices;
using System.Text;
using Microsoft.Win32.SafeHandles;
#if !WINDOWS_UWP
using System.Runtime.ConstrainedExecution;
#endif

#if !MANAGED_OSVR_INTERNAL_PINVOKE

Expand All @@ -36,11 +38,17 @@ public sealed class SafeClientContextHandle : SafeHandleZeroOrMinusOneIsInvalid
{
public SafeClientContextHandle() : base(true) { }

#if !WINDOWS_UWP
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#endif
protected override bool ReleaseHandle()
{
#if !WINDOWS_UWP
System.Diagnostics.Debug.WriteLine("[OSVR] ClientContext shutdown");
return ClientContext.osvrClientShutdown(handle) == OSVR.ClientKit.ClientContext.OSVR_RETURN_SUCCESS;
#else
return true;
#endif
}
}

Expand All @@ -61,11 +69,16 @@ public class ServerAutoStarter : IDisposable
private const string OSVRCoreDll = "osvrClientKit";
#endif

#if WINDOWS_UWP
internal static void osvrClientAttemptServerAutoStart() { }
internal static void osvrClientReleaseAutoStartedServer() { }
#else
[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
internal extern static void osvrClientAttemptServerAutoStart();

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
internal extern static void osvrClientReleaseAutoStartedServer();
#endif

public ServerAutoStarter()
{
Expand Down Expand Up @@ -103,7 +116,7 @@ protected virtual void Dispose(bool disposing)
/// @ingroup ClientKitCPP
public class ClientContext : IDisposable
{
#region ClientKit C functions
#region ClientKit C functions

// Should be defined if used with Unity and UNITY_IOS or UNITY_XBOX360 are defined
#if MANAGED_OSVR_INTERNAL_PINVOKE
Expand All @@ -118,6 +131,26 @@ public class ClientContext : IDisposable
public static Byte OSVR_RETURN_SUCCESS = 0x0;
public static Byte OSVR_RETURN_FAILURE = 0x1;

#if WINDOWS_UWP
public static SafeClientContextHandle osvrClientInit([MarshalAs(UnmanagedType.LPStr)] string applicationIdentifier, [MarshalAs(UnmanagedType.U4)] uint flags)
{
return null;
}

public static Byte osvrClientUpdate(SafeClientContextHandle ctx) { return 0; }
public static Byte osvrClientShutdown(IntPtr /*OSVR_ClientContext*/ ctx) { return 0; }

public static Byte osvrClientGetStringParameterLength(SafeClientContextHandle ctx, string path, out UIntPtr len)
{
len = UIntPtr.Zero;
return 0;
}

public static Byte osvrClientGetStringParameter(SafeClientContextHandle ctx, string path, StringBuilder buf, UIntPtr len) { return 0; }
internal static Byte osvrClientCheckStatus(SafeClientContextHandle ctx) { return 0; }
internal static Byte osvrClientSetRoomRotationUsingHead(SafeClientContextHandle ctx) { return 0; }
internal static Byte osvrClientClearRoomToWorldTransform(SafeClientContextHandle ctx) { return 0; }
#else
[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
public extern static SafeClientContextHandle osvrClientInit([MarshalAs(UnmanagedType.LPStr)] string applicationIdentifier, [MarshalAs(UnmanagedType.U4)] uint flags);

Expand All @@ -141,6 +174,7 @@ public class ClientContext : IDisposable

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
internal extern static Byte osvrClientClearRoomToWorldTransform(SafeClientContextHandle ctx);
#endif

#endregion ClientKit C functions

Expand All @@ -160,7 +194,7 @@ static public void PreloadNativeLibraries()
/// </summary>
static public void PreloadNativeLibraries(bool loadJointClientKitDlls)
{
#if !MANAGED_OSVR_INTERNAL_PINVOKE
#if !MANAGED_OSVR_INTERNAL_PINVOKE && !WINDOWS_UWP

// This line based on http://stackoverflow.com/a/864497/265522
var assembly = System.Uri.UnescapeDataString((new System.Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase)).AbsolutePath);
Expand Down Expand Up @@ -193,7 +227,7 @@ static public void PreloadNativeLibraries(bool loadJointClientKitDlls)
#endif
}

#if !MANAGED_OSVR_INTERNAL_PINVOKE
#if !MANAGED_OSVR_INTERNAL_PINVOKE && !WINDOWS_UWP

private class LibraryPathAttempter
{
Expand Down Expand Up @@ -401,7 +435,7 @@ private String[] NativeLibs

#endif

#endregion Support for locating native libraries
#endregion Support for locating native libraries

/// @brief Initialize the library.
/// @param applicationIdentifier A string identifying your application.
Expand Down Expand Up @@ -504,7 +538,7 @@ internal void AddChildDisposable(IDisposable childDisposable)
public DisplayConfig GetDisplayConfig()
{
SafeDisplayConfigHandle handle;
if(DisplayConfigNative.osvrClientGetDisplay(this.m_context, out handle) != OSVR_RETURN_SUCCESS)
if (DisplayConfigNative.osvrClientGetDisplay(this.m_context, out handle) != OSVR_RETURN_SUCCESS)
{
return null;
}
Expand Down Expand Up @@ -566,7 +600,7 @@ public string getStringParameter(string path)
return buf.ToString();
}


/// <summary>
/// Updates the internal "room to world" transformation (applied to all
/// tracker data for this client context instance) based on the user's head
Expand All @@ -579,7 +613,7 @@ public string getStringParameter(string path)
public void SetRoomRotationUsingHead()
{
Byte success = osvrClientSetRoomRotationUsingHead(m_context);
if(OSVR_RETURN_SUCCESS != success)
if (OSVR_RETURN_SUCCESS != success)
{
throw new ApplicationException("OSVR::SetRoomRotationUsingHead() - native osvrClientSetRoomRotationUsingHead call failed.");
}
Expand All @@ -594,7 +628,7 @@ public void SetRoomRotationUsingHead()
public void ClearRoomToWorldTransform()
{
Byte success = osvrClientClearRoomToWorldTransform(m_context);
if(OSVR_RETURN_SUCCESS != success)
if (OSVR_RETURN_SUCCESS != success)
{
throw new ApplicationException("OSVR::ClearRoomToWorldTransform() - native osvrClientClearRoomToWorldTransform call failed.");
}
Expand Down
158 changes: 158 additions & 0 deletions ClientKit/ClientKit.win10.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{438A507E-5DA4-499F-AD91-DED7B3ADF291}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OSVR</RootNamespace>
<AssemblyName>OSVR.ClientKit</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.15063.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.10586.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<PlatformTarget>ARM</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
<PlatformTarget>ARM</PlatformTarget>
<OutputPath>bin\ARM\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup>
<ItemGroup>
<Compile Include="AnalogInterface.cs" />
<Compile Include="BuildConstants.cs" />
<Compile Include="ButtonInterface.cs" />
<Compile Include="ClientKit.cs" />
<Compile Include="ClientReportTypes.cs" />
<Compile Include="DirectionInterface.cs" />
<Compile Include="Display.cs" />
<Compile Include="EyeTracker2DInterface.cs" />
<Compile Include="EyeTracker3DInterface.cs" />
<Compile Include="EyeTrackerBlinkInterface.cs" />
<Compile Include="ImagingInterface.cs" />
<Compile Include="Interface.cs" />
<Compile Include="InterfaceAdapter.cs" />
<Compile Include="InterfaceBase.cs" />
<Compile Include="JointClientKit.cs" />
<Compile Include="Location2DInterface.cs" />
<Compile Include="MatrixConventions.cs" />
<Compile Include="NaviPositionInterface.cs" />
<Compile Include="NaviVelocityInterface.cs" />
<Compile Include="OrientationInterface.cs" />
<Compile Include="Pose3.cs" />
<Compile Include="PoseInterface.cs" />
<Compile Include="PositionInterface.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Quaternion.cs" />
<Compile Include="TimeValue.cs" />
<Compile Include="Vec2.cs" />
<Compile Include="Vec3.cs" />
<Compile Include="Win10Wrapper.cs" />
<EmbeddedResource Include="Properties\OSVR.rd.xml">
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>5.2.3</Version>
</PackageReference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Loading