Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Commit

Permalink
Native Oculus Pre-Updates (#213)
Browse files Browse the repository at this point in the history
* Some pre updates for the native Oculus support:

* Renamed existing OpenVR controller definitions to match other extensions
* Added FixedUpdate and LateUpdate to services definitions

* Finalising File renames
Updated to 2019.1.7f1
  • Loading branch information
SimonDarksideJ authored Jun 23, 2019
1 parent e3df669 commit 885f54f
Show file tree
Hide file tree
Showing 18 changed files with 117 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected override void Awake()
{
ControllerMappings = new[]
{
new MixedRealityControllerMapping("Oculus Go Controller", typeof(OculusGoController), Handedness.Both),
new MixedRealityControllerMapping("Oculus Go Controller", typeof(OculusGoOpenVRController), Handedness.Both),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected override void Awake()
{
ControllerMappings = new[]
{
new MixedRealityControllerMapping("Oculus Remote Controller", typeof(OculusRemoteController)),
new MixedRealityControllerMapping("Oculus Remote Controller", typeof(OculusRemoteOpenVRController)),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ protected override void Awake()
{
ControllerMappings = new[]
{
new MixedRealityControllerMapping("Oculus Touch Controller Left", typeof(OculusTouchController), Handedness.Left),
new MixedRealityControllerMapping("Oculus Touch Controller Right", typeof(OculusTouchController), Handedness.Right),
new MixedRealityControllerMapping("Oculus Touch Controller Left", typeof(OculusTouchOpenVRController), Handedness.Left),
new MixedRealityControllerMapping("Oculus Touch Controller Right", typeof(OculusTouchOpenVRController), Handedness.Right),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ protected override void Awake()
{
ControllerMappings = new[]
{
new MixedRealityControllerMapping("Vive Wand Controller Left", typeof(ViveWandController), Handedness.Left),
new MixedRealityControllerMapping("Vive Wand Controller Right", typeof(ViveWandController), Handedness.Right),
new MixedRealityControllerMapping("Vive Wand Controller Left", typeof(ViveWandOpenVRController), Handedness.Left),
new MixedRealityControllerMapping("Vive Wand Controller Right", typeof(ViveWandOpenVRController), Handedness.Right),
};
}

Expand Down
10 changes: 10 additions & 0 deletions Interfaces/IMixedRealityService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ public interface IMixedRealityService : IDisposable
/// </summary>
void Update();

/// <summary>
/// Optional LateUpdate function to perform updates after the end of the last Update cycle.
/// </summary>
void LateUpdate();

/// <summary>
/// Optional FixedUpdate function to perform updates that are fixed to the Physics timestep.
/// </summary>
void FixedUpdate();

/// <summary>
/// Optional Disable function to pause the service.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace XRTK.Providers.Controllers.OpenVR
{
public class OculusGoController : GenericOpenVRController
public class OculusGoOpenVRController : GenericOpenVRController
{
/// <summary>
/// Constructor.
Expand All @@ -18,7 +18,7 @@ public class OculusGoController : GenericOpenVRController
/// <param name="controllerHandedness"></param>
/// <param name="inputSource"></param>
/// <param name="interactions"></param>
public OculusGoController(TrackingState trackingState, Handedness controllerHandedness, IMixedRealityInputSource inputSource = null, MixedRealityInteractionMapping[] interactions = null)
public OculusGoOpenVRController(TrackingState trackingState, Handedness controllerHandedness, IMixedRealityInputSource inputSource = null, MixedRealityInteractionMapping[] interactions = null)
: base(trackingState, controllerHandedness, inputSource, interactions)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace XRTK.Providers.Controllers.OpenVR
{
public class OculusRemoteController : GenericOpenVRController
public class OculusRemoteOpenVRController : GenericOpenVRController
{
/// <summary>
/// Constructor.
Expand All @@ -17,7 +17,7 @@ public class OculusRemoteController : GenericOpenVRController
/// <param name="controllerHandedness"></param>
/// <param name="inputSource"></param>
/// <param name="interactions"></param>
public OculusRemoteController(TrackingState trackingState, Handedness controllerHandedness, IMixedRealityInputSource inputSource = null, MixedRealityInteractionMapping[] interactions = null)
public OculusRemoteOpenVRController(TrackingState trackingState, Handedness controllerHandedness, IMixedRealityInputSource inputSource = null, MixedRealityInteractionMapping[] interactions = null)
: base(trackingState, controllerHandedness, inputSource, interactions)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace XRTK.Providers.Controllers.OpenVR
{
public class OculusTouchController : GenericOpenVRController
public class OculusTouchOpenVRController : GenericOpenVRController
{
/// <summary>
/// Constructor.
Expand All @@ -18,7 +18,7 @@ public class OculusTouchController : GenericOpenVRController
/// <param name="controllerHandedness"></param>
/// <param name="inputSource"></param>
/// <param name="interactions"></param>
public OculusTouchController(TrackingState trackingState, Handedness controllerHandedness,
public OculusTouchOpenVRController(TrackingState trackingState, Handedness controllerHandedness,
IMixedRealityInputSource inputSource = null, MixedRealityInteractionMapping[] interactions = null)
: base(trackingState, controllerHandedness, inputSource, interactions)
{
Expand Down
10 changes: 5 additions & 5 deletions Providers/Controllers/OpenVR/OpenVRDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,19 @@ protected override GenericJoystickController GetOrAddController(string joystickN
controllerType = typeof(GenericOpenVRController);
break;
case SupportedControllerType.ViveWand:
controllerType = typeof(ViveWandController);
controllerType = typeof(ViveWandOpenVRController);
break;
case SupportedControllerType.ViveKnuckles:
controllerType = typeof(ViveKnucklesController);
controllerType = typeof(ViveKnucklesOpenVRController);
break;
case SupportedControllerType.OculusTouch:
controllerType = typeof(OculusTouchController);
controllerType = typeof(OculusTouchOpenVRController);
break;
case SupportedControllerType.OculusRemote:
controllerType = typeof(OculusRemoteController);
controllerType = typeof(OculusRemoteOpenVRController);
break;
case SupportedControllerType.OculusGo:
controllerType = typeof(OculusGoController);
controllerType = typeof(OculusGoOpenVRController);
break;
case SupportedControllerType.WindowsMixedReality:
controllerType = typeof(WindowsMixedRealityOpenVRMotionController);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace XRTK.Providers.Controllers.OpenVR
{
public class ViveKnucklesController : GenericOpenVRController
public class ViveKnucklesOpenVRController : GenericOpenVRController
{
/// <summary>
/// Constructor.
Expand All @@ -18,7 +18,7 @@ public class ViveKnucklesController : GenericOpenVRController
/// <param name="controllerHandedness"></param>
/// <param name="inputSource"></param>
/// <param name="interactions"></param>
public ViveKnucklesController(TrackingState trackingState, Handedness controllerHandedness, IMixedRealityInputSource inputSource = null, MixedRealityInteractionMapping[] interactions = null)
public ViveKnucklesOpenVRController(TrackingState trackingState, Handedness controllerHandedness, IMixedRealityInputSource inputSource = null, MixedRealityInteractionMapping[] interactions = null)
: base(trackingState, controllerHandedness, inputSource, interactions)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace XRTK.Providers.Controllers.OpenVR
{
public class ViveWandController : GenericOpenVRController
public class ViveWandOpenVRController : GenericOpenVRController
{
/// <summary>
/// Constructor.
Expand All @@ -18,7 +18,7 @@ public class ViveWandController : GenericOpenVRController
/// <param name="controllerHandedness"></param>
/// <param name="inputSource"></param>
/// <param name="interactions"></param>
public ViveWandController(TrackingState trackingState, Handedness controllerHandedness, IMixedRealityInputSource inputSource = null, MixedRealityInteractionMapping[] interactions = null)
public ViveWandOpenVRController(TrackingState trackingState, Handedness controllerHandedness, IMixedRealityInputSource inputSource = null, MixedRealityInteractionMapping[] interactions = null)
: base(trackingState, controllerHandedness, inputSource, interactions)
{
}
Expand Down
6 changes: 6 additions & 0 deletions Services/BaseService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ public virtual void Enable() { }
/// <inheritdoc />
public virtual void Update() { }

/// <inheritdoc />
public virtual void LateUpdate() { }

/// <inheritdoc />
public virtual void FixedUpdate() { }

/// <inheritdoc />
public virtual void Disable() { }

Expand Down
80 changes: 80 additions & 0 deletions Services/MixedRealityToolkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,22 @@ private void Update()
}
}

private void LateUpdate()
{
if (Application.isPlaying)
{
LateUpdateAllServices();
}
}

private void FixedUpdate()
{
if (Application.isPlaying)
{
FixedUpdateAllServices();
}
}

private void OnDisable()
{
if (Application.isPlaying)
Expand Down Expand Up @@ -1274,6 +1290,70 @@ private void UpdateAllServices()
}
}

private void LateUpdateAllServices()
{
// If the Mixed Reality Toolkit is not configured, stop.
if (activeProfile == null) { return; }

// Update all systems
foreach (var system in activeSystems)
{
try
{
system.Value.LateUpdate();
}
catch (Exception e)
{
Debug.LogError($"{e.Message}\n{e.StackTrace}");
}
}

// Update all registered runtime services
foreach (var service in registeredMixedRealityServices)
{
try
{
service.Item2.LateUpdate();
}
catch (Exception e)
{
Debug.LogError($"{e.Message}\n{e.StackTrace}");
}
}
}

private void FixedUpdateAllServices()
{
// If the Mixed Reality Toolkit is not configured, stop.
if (activeProfile == null) { return; }

// Update all systems
foreach (var system in activeSystems)
{
try
{
system.Value.FixedUpdate();
}
catch (Exception e)
{
Debug.LogError($"{e.Message}\n{e.StackTrace}");
}
}

// Update all registered runtime services
foreach (var service in registeredMixedRealityServices)
{
try
{
service.Item2.FixedUpdate();
}
catch (Exception e)
{
Debug.LogError($"{e.Message}\n{e.StackTrace}");
}
}
}

private void DisableAllServices()
{
// If the Mixed Reality Toolkit is not configured, stop.
Expand Down

0 comments on commit 885f54f

Please sign in to comment.