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
59 changes: 20 additions & 39 deletions ClientKit/ClientKit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
/// </copyright>

/// </copyright>
using System;
using System.Runtime.InteropServices;
using System.Text;
Expand Down Expand Up @@ -52,19 +52,10 @@ protected override bool ReleaseHandle()
/// </summary>
public class ServerAutoStarter : IDisposable
{
#if MANAGED_OSVR_INTERNAL_PINVOKE
// On iOS and Xbox 360, plugins are statically linked into
// the executable, so we have to use __Internal as the
// library name.
private const string OSVRCoreDll = "__Internal";
#else
private const string OSVRCoreDll = "osvrClientKit";
#endif

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
internal extern static void osvrClientAttemptServerAutoStart();

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

public ServerAutoStarter()
Expand Down Expand Up @@ -105,41 +96,31 @@ public class ClientContext : IDisposable
{
#region ClientKit C functions

// Should be defined if used with Unity and UNITY_IOS or UNITY_XBOX360 are defined
#if MANAGED_OSVR_INTERNAL_PINVOKE
// On iOS and Xbox 360, plugins are statically linked into
// the executable, so we have to use __Internal as the
// library name.
private const string OSVRCoreDll = "__Internal";
#else
private const string OSVRCoreDll = "osvrClientKit";
#endif

public static Byte OSVR_RETURN_SUCCESS = 0x0;
public static Byte OSVR_RETURN_FAILURE = 0x1;

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
public extern static SafeClientContextHandle osvrClientInit([MarshalAs(UnmanagedType.LPStr)] string applicationIdentifier, [MarshalAs(UnmanagedType.U4)] uint flags);

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
public extern static Byte osvrClientUpdate(SafeClientContextHandle ctx);

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
public extern static Byte osvrClientShutdown(IntPtr /*OSVR_ClientContext*/ ctx);

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
public extern static Byte osvrClientGetStringParameterLength(SafeClientContextHandle ctx, string path, out UIntPtr len);

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
public extern static Byte osvrClientGetStringParameter(SafeClientContextHandle ctx, string path, StringBuilder buf, UIntPtr len);

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
internal extern static Byte osvrClientCheckStatus(SafeClientContextHandle ctx);

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
internal extern static Byte osvrClientSetRoomRotationUsingHead(SafeClientContextHandle ctx);

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

#endregion ClientKit C functions
Expand Down Expand Up @@ -568,12 +549,12 @@ public string getStringParameter(string path)


/// <summary>
/// Updates the internal "room to world" transformation (applied to all
/// tracker data for this client context instance) based on the user's head
/// orientation, so that the direction the user is facing becomes -Z to your
/// application. Only rotates about the Y axis (yaw).
///
/// Note that this method internally calls osvrClientUpdate() to get a head pose
/// Updates the internal "room to world" transformation (applied to all
/// tracker data for this client context instance) based on the user's head
/// orientation, so that the direction the user is facing becomes -Z to your
/// application. Only rotates about the Y axis (yaw).
///
/// Note that this method internally calls osvrClientUpdate() to get a head pose
/// so your callbacks may be called during its execution!
/// </summary>
public void SetRoomRotationUsingHead()
Expand All @@ -587,8 +568,8 @@ public void SetRoomRotationUsingHead()


/// <summary>
/// Clears/resets the internal "room to world" transformation back to an
/// identity transformation - that is, clears the effect of any other
/// Clears/resets the internal "room to world" transformation back to an
/// identity transformation - that is, clears the effect of any other
/// manipulation of the room to world transform.
/// </summary>
public void ClearRoomToWorldTransform()
Expand Down
1 change: 1 addition & 0 deletions ClientKit/ClientKit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<Compile Include="InterfaceAdapter.cs" />
<Compile Include="InterfaceBase.cs" />
<Compile Include="JointClientKit.cs" />
<Compile Include="OSVRLibNames.cs" />
<Compile Include="Location2DInterface.cs" />
<Compile Include="MatrixConventions.cs" />
<Compile Include="NaviPositionInterface.cs" />
Expand Down
49 changes: 20 additions & 29 deletions ClientKit/Display.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,91 +89,82 @@ public struct ProjectionClippingPlanes
}

internal static class DisplayConfigNative {
#if MANAGED_OSVR_INTERNAL_PINVOKE
// On iOS and Xbox 360, plugins are statically linked into
// the executable, so we have to use __Internal as the
// library name.
private const string OSVRCoreDll = "__Internal";
#else
private const string OSVRCoreDll = "osvrClientKit";
#endif

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
public extern static Byte osvrClientGetDisplay(SafeClientContextHandle context, out SafeDisplayConfigHandle display);

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
public extern static Byte osvrClientFreeDisplay(IntPtr display);

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
public extern static Byte osvrClientCheckDisplayStartup(SafeDisplayConfigHandle context);

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
public extern static Byte osvrClientGetNumDisplayInputs(SafeDisplayConfigHandle display, out DisplayInputCount numDisplayInputs);

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
public extern static Byte osvrClientGetDisplayDimensions(SafeDisplayConfigHandle display,
DisplayInputCount displayInputIndex, out DisplayDimension width, out DisplayDimension height);

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
public extern static Byte osvrClientGetNumViewers(SafeDisplayConfigHandle display, out ViewerCount viewers);

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
public extern static Byte osvrClientGetViewerPose(SafeDisplayConfigHandle display,
ViewerCount viewer, out Pose3 pose);

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
public extern static Byte osvrClientGetNumEyesForViewer(SafeDisplayConfigHandle display,
ViewerCount viewer, out EyeCount eyes);

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
public extern static Byte osvrClientGetViewerEyePose(SafeDisplayConfigHandle display,
ViewerCount viewer, EyeCount eye, out Pose3 pose);

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
public extern static Byte osvrClientGetViewerEyeViewMatrixd(SafeDisplayConfigHandle display,
ViewerCount viewer, EyeCount eye, MatrixConventionsFlags flags, out Matrix44d mat);

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
public extern static Byte osvrClientGetViewerEyeViewMatrixf(SafeDisplayConfigHandle display,
ViewerCount viewer, EyeCount eye, MatrixConventionsFlags flags, out Matrix44f mat);

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
public extern static Byte osvrClientGetNumSurfacesForViewerEye(SafeDisplayConfigHandle display,
ViewerCount viewer, EyeCount eye, out SurfaceCount surfaces);

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
public extern static Byte osvrClientGetRelativeViewportForViewerEyeSurface(SafeDisplayConfigHandle display,
ViewerCount viewer, EyeCount eye, SurfaceCount surface,
out ViewportDimension left, out ViewportDimension bottom, out ViewportDimension width, out ViewportDimension height);

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
public extern static Byte osvrClientGetViewerEyeSurfaceDisplayInputIndex(SafeDisplayConfigHandle display,
ViewerCount viewer, EyeCount eye, SurfaceCount surface, out DisplayInputCount displayInput);

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
public extern static Byte osvrClientGetViewerEyeSurfaceProjectionMatrixd(SafeDisplayConfigHandle display,
ViewerCount viewer, EyeCount eye, SurfaceCount surface, double near, double far,
MatrixConventionsFlags flags, out Matrix44d matrix);

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
public extern static Byte osvrClientGetViewerEyeSurfaceProjectionMatrixf(SafeDisplayConfigHandle display,
ViewerCount viewer, EyeCount eye, SurfaceCount surface, float near, float far,
MatrixConventionsFlags flags, out Matrix44f matrix);

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
public extern static Byte osvrClientGetViewerEyeSurfaceProjectionClippingPlanes(SafeDisplayConfigHandle display,
ViewerCount viewer, EyeCount eye, SurfaceCount surface,
out double left, out double right, out double bottom, out double top);

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
public extern static Byte osvrClientDoesViewerEyeSurfaceWantDistortion(SafeDisplayConfigHandle display,
ViewerCount viewer, EyeCount eye, SurfaceCount surface, [MarshalAs(UnmanagedType.I1)]out bool distortionRequested);

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
public extern static Byte osvrClientGetViewerEyeSurfaceRadialDistortionPriority(SafeDisplayConfigHandle display,
ViewerCount viewer, EyeCount eye, SurfaceCount surface, out DistortionPriority priority);

[DllImport(OSVRCoreDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
public extern static Byte osvrClientGetViewerEyeSurfaceRadialDistortion(SafeDisplayConfigHandle display,
ViewerCount viewer, EyeCount eye, SurfaceCount surface, out RadialDistortionParameters distortionParams);
}
Expand Down
11 changes: 1 addition & 10 deletions ClientKit/ImagingInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,7 @@ public static ImagingInterface GetImagingInterface(this ClientContext context, s

internal static class ImagingInterfaceNative
{
#if UNITY_IPHONE || UNITY_XBOX360
// On iOS and Xbox 360, plugins are statically linked into
// the executable, so we have to use __Internal as the
// library name.
const string OSVR_CORE_DLL = "__Internal";
#else
const string OSVR_CORE_DLL = "osvrClientKit";
#endif

[DllImport(OSVR_CORE_DLL, CallingConvention = CallingConvention.Cdecl)]
[DllImport(OSVRLibNames.ClientKit, CallingConvention = CallingConvention.Cdecl)]
public static extern Byte osvrClientFreeImage(SafeClientContextHandle ctx, IntPtr imageData);
}

Expand Down
Loading