From d2f340158a9656c6bb03b86e2692944ee8679b31 Mon Sep 17 00:00:00 2001 From: Yannick Date: Sun, 14 May 2017 13:14:57 +0200 Subject: [PATCH 1/4] Added a new solution and csproj to build a working version of ClientKit on the Windows 10 Universal platform. --- ClientKit/BuildConstants.cs | 2 + ClientKit/ClientKit.cs | 24 +++-- ClientKit/ClientKit.win10.csproj | 156 +++++++++++++++++++++++++++ ClientKit/Display.cs | 14 ++- ClientKit/Interface.cs | 8 ++ ClientKit/JointClientKit.cs | 2 + ClientKit/Properties/AssemblyInfo.cs | 16 +-- ClientKit/Properties/OSVR.rd.xml | 33 ++++++ ClientKit/Win10Wrapper.cs | 24 +++++ Managed-OSVR.win10.sln | 40 +++++++ 10 files changed, 301 insertions(+), 18 deletions(-) create mode 100644 ClientKit/ClientKit.win10.csproj create mode 100644 ClientKit/Properties/OSVR.rd.xml create mode 100644 ClientKit/Win10Wrapper.cs create mode 100644 Managed-OSVR.win10.sln diff --git a/ClientKit/BuildConstants.cs b/ClientKit/BuildConstants.cs index 79979b4..003a64b 100644 --- a/ClientKit/BuildConstants.cs +++ b/ClientKit/BuildConstants.cs @@ -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 diff --git a/ClientKit/ClientKit.cs b/ClientKit/ClientKit.cs index 39402b9..0123494 100644 --- a/ClientKit/ClientKit.cs +++ b/ClientKit/ClientKit.cs @@ -15,12 +15,14 @@ /// See the License for the specific language governing permissions and /// limitations under the License. /// - -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 @@ -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 } } @@ -160,7 +168,7 @@ static public void PreloadNativeLibraries() /// 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); @@ -193,7 +201,7 @@ static public void PreloadNativeLibraries(bool loadJointClientKitDlls) #endif } -#if !MANAGED_OSVR_INTERNAL_PINVOKE +#if !MANAGED_OSVR_INTERNAL_PINVOKE && !WINDOWS_UWP private class LibraryPathAttempter { @@ -504,7 +512,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; } @@ -566,7 +574,7 @@ public string getStringParameter(string path) return buf.ToString(); } - + /// /// Updates the internal "room to world" transformation (applied to all /// tracker data for this client context instance) based on the user's head @@ -579,7 +587,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."); } @@ -594,7 +602,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."); } diff --git a/ClientKit/ClientKit.win10.csproj b/ClientKit/ClientKit.win10.csproj new file mode 100644 index 0000000..e4568bd --- /dev/null +++ b/ClientKit/ClientKit.win10.csproj @@ -0,0 +1,156 @@ + + + + + Debug + AnyCPU + {438A507E-5DA4-499F-AD91-DED7B3ADF291} + Library + Properties + OSVR + OSVR.ClientKit + en-EN + UAP + 10.0.15063.0 + 10.0.10586.0 + 14 + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + prompt + 4 + + + x86 + true + bin\x86\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + x86 + false + prompt + + + x86 + bin\x86\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + x86 + false + prompt + + + ARM + true + bin\ARM\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + ARM + false + prompt + + + ARM + bin\ARM\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + ARM + false + prompt + + + x64 + true + bin\x64\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + x64 + false + prompt + + + x64 + bin\x64\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + x64 + false + prompt + + + PackageReference + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5.2.3 + + + + 14.0 + + + + \ No newline at end of file diff --git a/ClientKit/Display.cs b/ClientKit/Display.cs index 966a556..62d0622 100644 --- a/ClientKit/Display.cs +++ b/ClientKit/Display.cs @@ -20,7 +20,9 @@ using System.Runtime.InteropServices; using System.Text; using Microsoft.Win32.SafeHandles; +#if !WINDOWS_UWP using System.Runtime.ConstrainedExecution; +#endif using ViewportDimension = System.Int32; using ViewerCount = System.UInt32; @@ -34,12 +36,18 @@ namespace OSVR.ClientKit { public sealed class SafeDisplayConfigHandle : SafeHandleZeroOrMinusOneIsInvalid { - public SafeDisplayConfigHandle() : base(true) { } - + public SafeDisplayConfigHandle() : base(true) { } + +#if !WINDOWS_UWP [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] +#endif protected override bool ReleaseHandle() - { + { +#if !WINDOWS_UWP return DisplayConfigNative.osvrClientFreeDisplay(handle) == OSVR.ClientKit.ClientContext.OSVR_RETURN_SUCCESS; +#else + return true; +#endif } } diff --git a/ClientKit/Interface.cs b/ClientKit/Interface.cs index 98c1bd4..a358650 100644 --- a/ClientKit/Interface.cs +++ b/ClientKit/Interface.cs @@ -17,7 +17,9 @@ /// using Microsoft.Win32.SafeHandles; using System; +#if !WINDOWS_UWP using System.Runtime.ConstrainedExecution; +#endif using System.Runtime.InteropServices; namespace OSVR @@ -29,11 +31,17 @@ public sealed class SafeClientInterfaceHandle : SafeHandleZeroOrMinusOneIsInvali { public SafeClientInterfaceHandle() : base(true) { } +#if !WINDOWS_UWP [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] +#endif override protected bool ReleaseHandle() { +#if !WINDOWS_UWP System.Diagnostics.Debug.WriteLine("[OSVR] Interface shutdown"); return Interface.osvrClientFreeInterface(handle) == OSVR.ClientKit.ClientContext.OSVR_RETURN_SUCCESS; +#else + return true; +#endif } } diff --git a/ClientKit/JointClientKit.cs b/ClientKit/JointClientKit.cs index f501689..98791f6 100644 --- a/ClientKit/JointClientKit.cs +++ b/ClientKit/JointClientKit.cs @@ -18,7 +18,9 @@ /// using System; using System.Collections.Generic; +#if !WINDOWS_UWP using System.Runtime.ConstrainedExecution; +#endif using System.Runtime.InteropServices; using System.Text; diff --git a/ClientKit/Properties/AssemblyInfo.cs b/ClientKit/Properties/AssemblyInfo.cs index 11ddf26..c16fed0 100644 --- a/ClientKit/Properties/AssemblyInfo.cs +++ b/ClientKit/Properties/AssemblyInfo.cs @@ -19,6 +19,9 @@ using OSVR.ClientKit; using System.Reflection; +#if WINDOWS_UWP +using System.Runtime.InteropServices; +#endif [assembly: AssemblyTitle("OSVR ClientKit (" + BuildConstants.FrameworkDescription + ")")] [assembly: AssemblyDescription(BuildConstants.FrameworkDescription + "/" + BuildConstants.Configuration + BuildConstants.InternalPInvokeString)] @@ -29,14 +32,13 @@ [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] +[assembly: AssemblyVersion("0.1.*")] + // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". // The form "{Major}.{Minor}.*" will automatically update the build and revision, // and "{Major}.{Minor}.{Build}.*" will update just the revision. -[assembly: AssemblyVersion("0.1.*")] - -// The following attributes are used to specify the signing key for the assembly, -// if desired. See the Mono documentation for more information about signing. - -//[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyFile("")] +#if WINDOWS_UWP +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: ComVisible(false)] +#endif \ No newline at end of file diff --git a/ClientKit/Properties/OSVR.rd.xml b/ClientKit/Properties/OSVR.rd.xml new file mode 100644 index 0000000..7c6bf27 --- /dev/null +++ b/ClientKit/Properties/OSVR.rd.xml @@ -0,0 +1,33 @@ + + + + + + + + + diff --git a/ClientKit/Win10Wrapper.cs b/ClientKit/Win10Wrapper.cs new file mode 100644 index 0000000..49e4936 --- /dev/null +++ b/ClientKit/Win10Wrapper.cs @@ -0,0 +1,24 @@ +#if WINDOWS_UWP +using System; + +namespace OSVR.ClientKit +{ + public class SafeHandleZeroOrMinusOneIsInvalid : IDisposable + { + public bool IsClosed; + public bool IsInvalid; + + public SafeHandleZeroOrMinusOneIsInvalid(bool value) { } + + public void Close() { } + public void Dispose() { } + protected virtual bool ReleaseHandle() { return true; } + } + + public class ApplicationException : Exception + { + public ApplicationException(string message) + : base(message) { } + } +} +#endif \ No newline at end of file diff --git a/Managed-OSVR.win10.sln b/Managed-OSVR.win10.sln new file mode 100644 index 0000000..1fb1d6c --- /dev/null +++ b/Managed-OSVR.win10.sln @@ -0,0 +1,40 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.6 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientKit", "ClientKit/ClientKit.win10.csproj", "{438A507E-5DA4-499F-AD91-DED7B3ADF291}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|ARM = Debug|ARM + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|ARM = Release|ARM + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {438A507E-5DA4-499F-AD91-DED7B3ADF291}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {438A507E-5DA4-499F-AD91-DED7B3ADF291}.Debug|Any CPU.Build.0 = Debug|Any CPU + {438A507E-5DA4-499F-AD91-DED7B3ADF291}.Debug|ARM.ActiveCfg = Debug|ARM + {438A507E-5DA4-499F-AD91-DED7B3ADF291}.Debug|ARM.Build.0 = Debug|ARM + {438A507E-5DA4-499F-AD91-DED7B3ADF291}.Debug|x64.ActiveCfg = Debug|x64 + {438A507E-5DA4-499F-AD91-DED7B3ADF291}.Debug|x64.Build.0 = Debug|x64 + {438A507E-5DA4-499F-AD91-DED7B3ADF291}.Debug|x86.ActiveCfg = Debug|x86 + {438A507E-5DA4-499F-AD91-DED7B3ADF291}.Debug|x86.Build.0 = Debug|x86 + {438A507E-5DA4-499F-AD91-DED7B3ADF291}.Release|Any CPU.ActiveCfg = Release|Any CPU + {438A507E-5DA4-499F-AD91-DED7B3ADF291}.Release|Any CPU.Build.0 = Release|Any CPU + {438A507E-5DA4-499F-AD91-DED7B3ADF291}.Release|ARM.ActiveCfg = Release|ARM + {438A507E-5DA4-499F-AD91-DED7B3ADF291}.Release|ARM.Build.0 = Release|ARM + {438A507E-5DA4-499F-AD91-DED7B3ADF291}.Release|x64.ActiveCfg = Release|x64 + {438A507E-5DA4-499F-AD91-DED7B3ADF291}.Release|x64.Build.0 = Release|x64 + {438A507E-5DA4-499F-AD91-DED7B3ADF291}.Release|x86.ActiveCfg = Release|x86 + {438A507E-5DA4-499F-AD91-DED7B3ADF291}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal From 78df42682008e9197f45dce4cde95f14bf43540e Mon Sep 17 00:00:00 2001 From: Yannick Date: Sun, 14 May 2017 13:44:12 +0200 Subject: [PATCH 2/4] Updated the proj file --- ClientKit/ClientKit.win10.csproj | 6 ++++-- ClientKit/Properties/OSVR.rd.xml | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ClientKit/ClientKit.win10.csproj b/ClientKit/ClientKit.win10.csproj index e4568bd..93d3253 100644 --- a/ClientKit/ClientKit.win10.csproj +++ b/ClientKit/ClientKit.win10.csproj @@ -9,7 +9,7 @@ Properties OSVR OSVR.ClientKit - en-EN + en-US UAP 10.0.15063.0 10.0.10586.0 @@ -135,7 +135,9 @@ - + + Designer + diff --git a/ClientKit/Properties/OSVR.rd.xml b/ClientKit/Properties/OSVR.rd.xml index 7c6bf27..8b0049d 100644 --- a/ClientKit/Properties/OSVR.rd.xml +++ b/ClientKit/Properties/OSVR.rd.xml @@ -25,7 +25,7 @@ https://go.microsoft.com/fwlink/?LinkID=391919 --> - + From 1210639a22d479324e20b1c2b7cedfcd108149a8 Mon Sep 17 00:00:00 2001 From: Yannick Date: Fri, 19 May 2017 12:25:24 +0200 Subject: [PATCH 3/4] WIP --- ClientKit/ClientKit.cs | 30 ++++++++++++++++++++++++++++-- ClientKit/MatrixConventions.cs | 15 +++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/ClientKit/ClientKit.cs b/ClientKit/ClientKit.cs index 0123494..8b29515 100644 --- a/ClientKit/ClientKit.cs +++ b/ClientKit/ClientKit.cs @@ -69,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() { @@ -111,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 @@ -126,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); @@ -149,6 +174,7 @@ public class ClientContext : IDisposable [DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)] internal extern static Byte osvrClientClearRoomToWorldTransform(SafeClientContextHandle ctx); +#endif #endregion ClientKit C functions @@ -409,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. diff --git a/ClientKit/MatrixConventions.cs b/ClientKit/MatrixConventions.cs index 934624d..b9d5642 100644 --- a/ClientKit/MatrixConventions.cs +++ b/ClientKit/MatrixConventions.cs @@ -154,11 +154,26 @@ internal static class MatrixConventionsNative private const string OSVRUtilDll = "osvrUtil"; #endif + +#if WINDOWS_UWP + public static Byte osvrPose3ToMatrixd(ref Pose3 pose, MatrixConventionsFlags flags, out Matrix44d mat) + { + mat = new Matrix44d(); + return 0; + } + + public static Byte osvrPose3ToMatrixf(ref Pose3 pose, MatrixConventionsFlags flags, out Matrix44f mat) + { + mat = new Matrix44f(); + return 0; + } +#else [DllImport(OSVRUtilDll, CallingConvention = CallingConvention.Cdecl)] public static extern Byte osvrPose3ToMatrixd(ref Pose3 pose, MatrixConventionsFlags flags, out Matrix44d mat); [DllImport(OSVRUtilDll, CallingConvention = CallingConvention.Cdecl)] public static extern Byte osvrPose3ToMatrixf(ref Pose3 pose, MatrixConventionsFlags flags, out Matrix44f mat); +#endif } public static class MatrixConventions From ca07bdd7e0768b96772813c7a212c3785ac263db Mon Sep 17 00:00:00 2001 From: Yannick Date: Fri, 19 May 2017 12:56:27 +0200 Subject: [PATCH 4/4] Don't use DLLImport when targeting windows store apps. Note that this dll have to be used as a placeholder in Unity --- ClientKit/Display.cs | 145 +++++++++++++++++++++++++++++++++- ClientKit/ImagingInterface.cs | 4 + ClientKit/Interface.cs | 31 +++++++- ClientKit/JointClientKit.cs | 12 +++ 4 files changed, 189 insertions(+), 3 deletions(-) diff --git a/ClientKit/Display.cs b/ClientKit/Display.cs index 62d0622..9794139 100644 --- a/ClientKit/Display.cs +++ b/ClientKit/Display.cs @@ -103,9 +103,149 @@ internal static class DisplayConfigNative { // library name. private const string OSVRCoreDll = "__Internal"; #else - private const string OSVRCoreDll = "osvrClientKit"; + private const string OSVRCoreDll = "osvrClientKit"; #endif - + +#if WINDOWS_UWP + + public static Byte osvrClientGetDisplay(SafeClientContextHandle context, out SafeDisplayConfigHandle display) + { + display = null; + return 0; + } + + public static Byte osvrClientFreeDisplay(IntPtr display) { return 0; } + public static Byte osvrClientCheckDisplayStartup(SafeDisplayConfigHandle context) { return 0; } + + public static Byte osvrClientGetNumDisplayInputs(SafeDisplayConfigHandle display, out DisplayInputCount numDisplayInputs) + { + numDisplayInputs = new EyeCount(); + return 0; + } + + + public static Byte osvrClientGetDisplayDimensions(SafeDisplayConfigHandle display, DisplayInputCount displayInputIndex, out DisplayDimension width, out DisplayDimension height) + { + width = new ViewportDimension(); + height = new ViewportDimension(); + return 0; + } + + public static Byte osvrClientGetNumViewers(SafeDisplayConfigHandle display, out ViewerCount viewers) + { + viewers = new ViewerCount(); + return 0; + } + + public static Byte osvrClientGetViewerPose(SafeDisplayConfigHandle display, + ViewerCount viewer, out Pose3 pose) + { + pose = new Pose3(); + return 0; + } + + public static Byte osvrClientGetNumEyesForViewer(SafeDisplayConfigHandle display, + ViewerCount viewer, out EyeCount eyes) + { + eyes = new EyeCount(); + return 0; + } + + public static Byte osvrClientGetViewerEyePose(SafeDisplayConfigHandle display, + ViewerCount viewer, EyeCount eye, out Pose3 pose) + { + pose = new Pose3(); + return 0; + } + + public static Byte osvrClientGetViewerEyeViewMatrixd(SafeDisplayConfigHandle display, + ViewerCount viewer, EyeCount eye, MatrixConventionsFlags flags, out Matrix44d mat) + { + mat = new Matrix44d(); + return 0; + } + + public static Byte osvrClientGetViewerEyeViewMatrixf(SafeDisplayConfigHandle display, + ViewerCount viewer, EyeCount eye, MatrixConventionsFlags flags, out Matrix44f mat) + { + mat = new Matrix44f(); + return 0; + } + + + public static Byte osvrClientGetNumSurfacesForViewerEye(SafeDisplayConfigHandle display, + ViewerCount viewer, EyeCount eye, out SurfaceCount surfaces) + { + surfaces = new ViewerCount(); + return 0; + } + + public static Byte osvrClientGetRelativeViewportForViewerEyeSurface(SafeDisplayConfigHandle display, + ViewerCount viewer, EyeCount eye, SurfaceCount surface, + out ViewportDimension left, out ViewportDimension bottom, out ViewportDimension width, out ViewportDimension height) + { + left = new ViewportDimension(); + bottom = new ViewportDimension(); + width = new ViewportDimension(); + height = new ViewportDimension(); + return 0; + } + + public static Byte osvrClientGetViewerEyeSurfaceDisplayInputIndex(SafeDisplayConfigHandle display, + ViewerCount viewer, EyeCount eye, SurfaceCount surface, out DisplayInputCount displayInput) + { + displayInput = new EyeCount(); + return 0; + } + + public static Byte osvrClientGetViewerEyeSurfaceProjectionMatrixd(SafeDisplayConfigHandle display, + ViewerCount viewer, EyeCount eye, SurfaceCount surface, double near, double far, + MatrixConventionsFlags flags, out Matrix44d matrix) + { + matrix = new Matrix44d(); + return 0; + } + + public static Byte osvrClientGetViewerEyeSurfaceProjectionMatrixf(SafeDisplayConfigHandle display, + ViewerCount viewer, EyeCount eye, SurfaceCount surface, float near, float far, + MatrixConventionsFlags flags, out Matrix44f matrix) + { + matrix = new Matrix44f(); + return 0; + } + + public static Byte osvrClientGetViewerEyeSurfaceProjectionClippingPlanes(SafeDisplayConfigHandle display, + ViewerCount viewer, EyeCount eye, SurfaceCount surface, + out double left, out double right, out double bottom, out double top) + { + left = 0; + right = 0; + bottom = 0; + top = 0; + return 0; + } + + public static Byte osvrClientDoesViewerEyeSurfaceWantDistortion(SafeDisplayConfigHandle display, + ViewerCount viewer, EyeCount eye, SurfaceCount surface, [MarshalAs(UnmanagedType.I1)]out bool distortionRequested) + { + distortionRequested = false; + return 0; + } + + public static Byte osvrClientGetViewerEyeSurfaceRadialDistortionPriority(SafeDisplayConfigHandle display, + ViewerCount viewer, EyeCount eye, SurfaceCount surface, out DistortionPriority priority) + { + priority = 0; + return 0; + } + + public static Byte osvrClientGetViewerEyeSurfaceRadialDistortion(SafeDisplayConfigHandle display, + ViewerCount viewer, EyeCount eye, SurfaceCount surface, out RadialDistortionParameters distortionParams) + { + distortionParams = new RadialDistortionParameters(); + return 0; + } +#else [DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)] public extern static Byte osvrClientGetDisplay(SafeClientContextHandle context, out SafeDisplayConfigHandle display); @@ -184,6 +324,7 @@ public extern static Byte osvrClientGetViewerEyeSurfaceRadialDistortionPriority( [DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)] public extern static Byte osvrClientGetViewerEyeSurfaceRadialDistortion(SafeDisplayConfigHandle display, ViewerCount viewer, EyeCount eye, SurfaceCount surface, out RadialDistortionParameters distortionParams); +#endif } public struct Viewport diff --git a/ClientKit/ImagingInterface.cs b/ClientKit/ImagingInterface.cs index ecc7c40..ef6bde1 100644 --- a/ClientKit/ImagingInterface.cs +++ b/ClientKit/ImagingInterface.cs @@ -42,8 +42,12 @@ internal static class ImagingInterfaceNative const string OSVR_CORE_DLL = "osvrClientKit"; #endif +#if WINDOWS_UWP + public static Byte osvrClientFreeImage(SafeClientContextHandle ctx, IntPtr imageData) { return 0; } +#else [DllImport(OSVR_CORE_DLL, CallingConvention = CallingConvention.Cdecl)] public static extern Byte osvrClientFreeImage(SafeClientContextHandle ctx, IntPtr imageData); +#endif } /// diff --git a/ClientKit/Interface.cs b/ClientKit/Interface.cs index a358650..870beb5 100644 --- a/ClientKit/Interface.cs +++ b/ClientKit/Interface.cs @@ -103,7 +103,35 @@ public class Interface : IDisposable //typedef struct OSVR_ClientInterfaceObject *OSVR_ClientInterface; //typedef char OSVR_ReturnCode; (0 == OSVR_RETURN_SUCCESS; 1 == OSVR_RETURN_FAILURE) - +#if WINDOWS_UWP + public static Byte osvrRegisterPositionCallback(SafeClientInterfaceHandle iface, [MarshalAs(UnmanagedType.FunctionPtr)] PositionCallback cb, IntPtr /*void**/ userdata) { return 0; } + public static Byte osvrRegisterPoseCallback(SafeClientInterfaceHandle iface, PoseCallback cb, IntPtr /*void**/ userdata) { return 0; } + public static Byte osvrRegisterOrientationCallback(SafeClientInterfaceHandle iface, [MarshalAs(UnmanagedType.FunctionPtr)] OrientationCallback cb, IntPtr /*void**/ userdata) { return 0; } + public static Byte osvrRegisterButtonCallback(SafeClientInterfaceHandle iface, [MarshalAs(UnmanagedType.FunctionPtr)] ButtonCallback cb, IntPtr /*void**/ userdata) { return 0; } + public static Byte osvrRegisterAnalogCallback(SafeClientInterfaceHandle iface, [MarshalAs(UnmanagedType.FunctionPtr)] AnalogCallback cb, IntPtr /*void**/ userdata) { return 0; } + public static Byte osvrRegisterLocation2DCallback(SafeClientInterfaceHandle iface, [MarshalAs(UnmanagedType.FunctionPtr)] Location2DCallback cb, IntPtr /*void**/ userdata) { return 0; } + public static Byte osvrRegisterDirectionCallback(SafeClientInterfaceHandle iface, [MarshalAs(UnmanagedType.FunctionPtr)] DirectionCallback cb, IntPtr /*void**/ userdata) { return 0; } + public static Byte osvrRegisterEyeTracker2DCallback(SafeClientInterfaceHandle iface, [MarshalAs(UnmanagedType.FunctionPtr)] EyeTracker2DCallback cb, IntPtr /*void**/ userdata) { return 0; } + public static Byte osvrRegisterEyeTracker3DCallback(SafeClientInterfaceHandle iface, [MarshalAs(UnmanagedType.FunctionPtr)] EyeTracker3DCallback cb, IntPtr /*void**/ userdata) { return 0; } + public static Byte osvrRegisterEyeTrackerBlinkCallback(SafeClientInterfaceHandle iface, [MarshalAs(UnmanagedType.FunctionPtr)] EyeTrackerBlinkCallback cb, IntPtr /*void**/ userdata) { return 0; } + public static Byte osvrRegisterImagingCallback(SafeClientInterfaceHandle iface, [MarshalAs(UnmanagedType.FunctionPtr)] ImagingCallback cb, IntPtr /*void**/ userdata) { return 0; } + public static Byte osvrRegisterNaviVelocityCallback(SafeClientInterfaceHandle iface, [MarshalAs(UnmanagedType.FunctionPtr)] NaviVelocityCallback cb, IntPtr /*void*/ userdata) { return 0; } + public static Byte osvrRegisterNaviPositionCallback(SafeClientInterfaceHandle iface, [MarshalAs(UnmanagedType.FunctionPtr)] NaviPositionCallback cb, IntPtr /*void*/ userdata) { return 0; } + public static Byte osvrClientGetInterface(SafeClientContextHandle ctx, string path, ref SafeClientInterfaceHandle iface) { return 0; } + public static Byte osvrGetPoseState(SafeClientInterfaceHandle iface, ref TimeValue timestamp, ref Pose3 state) { return 0; } + public static Byte osvrGetPositionState(SafeClientInterfaceHandle iface, ref TimeValue timestamp, ref Vec3 state) { return 0; } + public static Byte osvrGetOrientationState(SafeClientInterfaceHandle iface, ref TimeValue timestamp, ref Quaternion state) { return 0; } + public static Byte osvrGetButtonState(SafeClientInterfaceHandle iface, ref TimeValue timestamp, ref Byte state) { return 0; } + public static Byte osvrGetAnalogState(SafeClientInterfaceHandle iface, ref TimeValue timestamp, ref Double state) { return 0; } + public static Byte osvrGetLocation2DState(SafeClientInterfaceHandle iface, ref TimeValue timestamp, ref Vec2 state) { return 0; } + public static Byte osvrGetDirectionState(SafeClientInterfaceHandle iface, ref TimeValue timestamp, ref Vec3 state) { return 0; } + public static Byte osvrGetEyeTracker2DState(SafeClientInterfaceHandle iface, ref TimeValue timestamp, ref Vec2 state) { return 0; } + public static Byte osvrGetEyeTracker3DState(SafeClientInterfaceHandle iface, ref TimeValue timestamp, ref EyeTracker3DState state) { return 0; } + public static Byte osvrGetEyeTrackerBlinkState(SafeClientInterfaceHandle iface, ref TimeValue timestamp, [MarshalAs(UnmanagedType.I1)]ref bool state) { return 0; } + public static Byte osvrGetNaviVelocityState(SafeClientInterfaceHandle iface, ref TimeValue timestamp, ref Vec2 state) { return 0; } + public static Byte osvrGetNaviPositionState(SafeClientInterfaceHandle iface, ref TimeValue timestamp, ref Vec2 state) { return 0; } + public static Byte osvrClientFreeInterface(IntPtr iface) { return 0; } +#else [DllImport(OSVR_CORE_DLL, CallingConvention = CallingConvention.Cdecl)] public extern static Byte osvrRegisterPositionCallback(SafeClientInterfaceHandle iface, [MarshalAs(UnmanagedType.FunctionPtr)] PositionCallback cb, IntPtr /*void**/ userdata); @@ -184,6 +212,7 @@ public class Interface : IDisposable [DllImport(OSVR_CORE_DLL, CallingConvention = CallingConvention.Cdecl)] public extern static Byte osvrClientFreeInterface(IntPtr iface); +#endif #endregion diff --git a/ClientKit/JointClientKit.cs b/ClientKit/JointClientKit.cs index 98791f6..8ef26a4 100644 --- a/ClientKit/JointClientKit.cs +++ b/ClientKit/JointClientKit.cs @@ -50,6 +50,17 @@ internal static class JointClientKitNative private const string JointClientKitDll = "osvrJointClientKit"; #endif +#if WINDOWS_UWP + public static IntPtr osvrJointClientCreateOptions() { return IntPtr.Zero; } + public static Byte osvrJointClientOptionsAutoloadPlugins(IntPtr options) { return 0; } + public static Byte osvrJointClientOptionsLoadPlugin(IntPtr options, string pluginName) { return 0; } + public static Byte osvrJointClientOptionsInstantiateDriver(IntPtr options, string pluginName, string driverName, string parameters) { return 0; } + public static Byte osvrJointClientOptionsAddAlias(IntPtr options, string path, string source) { return 0; } + public static Byte osvrJointClientOptionsAddAliases(IntPtr options, string aliases) { return 0; } + public static Byte osvrJointClientOptionsAddString(IntPtr options, string path, string s) { return 0; } + public static Byte osvrJointClientOptionsTriggerHardwareDetect(IntPtr options) { return 0; } + public static SafeClientContextHandle osvrJointClientInit(string applicationIdentifier, IntPtr options) { return null; } +#else [DllImport(JointClientKitDll, CallingConvention = CallingConvention.Cdecl)] public extern static IntPtr /*SafeJointClientOptionsHandle*/ osvrJointClientCreateOptions(); @@ -82,6 +93,7 @@ public extern static Byte osvrJointClientOptionsAddString(IntPtr /*SafeJointClie [DllImport(JointClientKitDll, CallingConvention = CallingConvention.Cdecl)] public extern static SafeClientContextHandle osvrJointClientInit( string applicationIdentifier, IntPtr /*SafeJointClientOptionsHandle*/ options); +#endif } ///