Skip to content

Commit

Permalink
feat(SDK): add native Unity Windows Mixed Reality support
Browse files Browse the repository at this point in the history
Support for the Unity Windows Mixed Reality WSA namespace to allow
for Windows Mixed Reality headsets and controllers to be used within
VRTK.

A number of reflection methods have been abstracted into the
Shared Methods class to remove errors when building on the Unity WSA
platform with the .NET scripting backend. These errors are caused
by the alternative version of .NET and differing ways of handling
reflection code.

Controller visualisation is provided by a 3rd party repository and
instructions of how to use are provided in the WindowsMR README.md
file.

A massive thanks to @tomwim for all his hard work on this and thanks
to @DDReaper for continued support along the way.
  • Loading branch information
thestonefox committed Mar 21, 2018
1 parent a214f2f commit 94c6cb5
Show file tree
Hide file tree
Showing 54 changed files with 6,916 additions and 687 deletions.
751 changes: 750 additions & 1 deletion Assets/VRTK/Documentation/API.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Assets/VRTK/Documentation/GETTING_STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ For further information on getting started with the supported SDKs, please refer
* [Simulator](/Assets/VRTK/Source/SDK/Simulator/README.md)
* [SteamVR](/Assets/VRTK/Source/SDK/SteamVR/README.md)
* [Oculus](/Assets/VRTK/Source/SDK/Oculus/README.md)
* [Windows Mixed Reality](/Assets/VRTK/Source/SDK/WindowsMR/README.md)
* [Daydream](/Assets/VRTK/Source/SDK/Daydream/README.md)
* [HyperealVR](/Assets/VRTK/Source/SDK/HyperealVR/README.md)
* [Ximmerse](/Assets/VRTK/Source/SDK/Ximmerse/README.md)
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public enum EventQuickSelect
public bool triggerButtonEvents = true;
public bool gripButtonEvents = true;
public bool touchpadButtonEvents = true;
public bool touchpadTwoButtonEvents = true;
public bool buttonOneButtonEvents = true;
public bool buttonTwoButtonEvents = true;
public bool startMenuButtonEvents = true;
Expand Down Expand Up @@ -80,6 +81,10 @@ private void OnEnable()
controllerEvents.TouchpadTouchStart += DoTouchpadTouchStart;
controllerEvents.TouchpadTouchEnd += DoTouchpadTouchEnd;
controllerEvents.TouchpadAxisChanged += DoTouchpadAxisChanged;
controllerEvents.TouchpadTwoPressed += DoTouchpadTwoPressed;
controllerEvents.TouchpadTwoReleased += DoTouchpadTwoReleased;
controllerEvents.TouchpadTwoTouchStart += DoTouchpadTwoTouchStart;
controllerEvents.TouchpadTwoTouchEnd += DoTouchpadTwoTouchEnd;
controllerEvents.TouchpadTwoAxisChanged += DoTouchpadTwoAxisChanged;
controllerEvents.TouchpadSenseAxisChanged += DoTouchpadSenseAxisChanged;

Expand Down Expand Up @@ -135,6 +140,10 @@ private void OnDisable()
controllerEvents.TouchpadTouchStart -= DoTouchpadTouchStart;
controllerEvents.TouchpadTouchEnd -= DoTouchpadTouchEnd;
controllerEvents.TouchpadAxisChanged -= DoTouchpadAxisChanged;
controllerEvents.TouchpadTwoPressed -= DoTouchpadTwoPressed;
controllerEvents.TouchpadTwoReleased -= DoTouchpadTwoReleased;
controllerEvents.TouchpadTwoTouchStart -= DoTouchpadTwoTouchStart;
controllerEvents.TouchpadTwoTouchEnd -= DoTouchpadTwoTouchEnd;
controllerEvents.TouchpadTwoAxisChanged -= DoTouchpadTwoAxisChanged;
controllerEvents.TouchpadSenseAxisChanged -= DoTouchpadSenseAxisChanged;

Expand Down Expand Up @@ -169,6 +178,7 @@ private void LateUpdate()
triggerButtonEvents = false;
gripButtonEvents = false;
touchpadButtonEvents = false;
touchpadTwoButtonEvents = false;
buttonOneButtonEvents = false;
buttonTwoButtonEvents = false;
startMenuButtonEvents = false;
Expand All @@ -188,6 +198,7 @@ private void LateUpdate()
triggerButtonEvents = true;
gripButtonEvents = true;
touchpadButtonEvents = true;
touchpadTwoButtonEvents = true;
buttonOneButtonEvents = true;
buttonTwoButtonEvents = true;
startMenuButtonEvents = true;
Expand All @@ -207,6 +218,7 @@ private void LateUpdate()
triggerButtonEvents = true;
gripButtonEvents = true;
touchpadButtonEvents = true;
touchpadTwoButtonEvents = true;
buttonOneButtonEvents = true;
buttonTwoButtonEvents = true;
startMenuButtonEvents = true;
Expand All @@ -226,6 +238,7 @@ private void LateUpdate()
triggerButtonEvents = false;
gripButtonEvents = false;
touchpadButtonEvents = false;
touchpadTwoButtonEvents = false;
buttonOneButtonEvents = false;
buttonTwoButtonEvents = false;
startMenuButtonEvents = false;
Expand All @@ -245,6 +258,7 @@ private void LateUpdate()
triggerButtonEvents = false;
gripButtonEvents = false;
touchpadButtonEvents = false;
touchpadTwoButtonEvents = false;
buttonOneButtonEvents = false;
buttonTwoButtonEvents = false;
startMenuButtonEvents = false;
Expand Down Expand Up @@ -462,6 +476,38 @@ private void DoTouchpadAxisChanged(object sender, ControllerInteractionEventArgs
}
}

private void DoTouchpadTwoPressed(object sender, ControllerInteractionEventArgs e)
{
if (touchpadTwoButtonEvents)
{
DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "TOUCHPADTWO", "pressed down", e);
}
}

private void DoTouchpadTwoReleased(object sender, ControllerInteractionEventArgs e)
{
if (touchpadTwoButtonEvents)
{
DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "TOUCHPADTWO", "released", e);
}
}

private void DoTouchpadTwoTouchStart(object sender, ControllerInteractionEventArgs e)
{
if (touchpadTwoButtonEvents)
{
DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "TOUCHPADTWO", "touched", e);
}
}

private void DoTouchpadTwoTouchEnd(object sender, ControllerInteractionEventArgs e)
{
if (touchpadTwoButtonEvents)
{
DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "TOUCHPADTWO", "untouched", e);
}
}

private void DoTouchpadTwoAxisChanged(object sender, ControllerInteractionEventArgs e)
{
if (touchpadTwoAxisEvents)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,34 +72,40 @@ protected virtual void ToggleSDKVisibility()
{
VRTK_ControllerReference leftController = VRTK_ControllerReference.GetControllerReference(VRTK_DeviceFinder.GetControllerLeftHand(true));
VRTK_ControllerReference rightController = VRTK_ControllerReference.GetControllerReference(VRTK_DeviceFinder.GetControllerRightHand(true));

switch (sdkType.name)
{
case "SteamVR":
ToggleSteamVRRenderer(leftController.actual);
ToggleSteamVRRenderer(rightController.actual);
ToggleControllerRenderer(leftController.actual, "Model");
ToggleControllerRenderer(rightController.actual, "Model");
break;
case "Oculus":
ToggleOculusRenderer(leftController.model);
ToggleOculusRenderer(rightController.model);
ToggleControllerRenderer(leftController.model);
ToggleControllerRenderer(rightController.model);
break;
case "WindowsMR":
ToggleControllerRenderer(leftController.model, "glTFController");
ToggleControllerRenderer(rightController.model, "glTFController");
break;
}
}
}

protected virtual void ToggleSteamVRRenderer(GameObject controller)
{
if (controller != null)
{
controller.transform.Find("Model").gameObject.SetActive(!state);
}
}

protected virtual void ToggleOculusRenderer(GameObject controller)
protected virtual void ToggleControllerRenderer(GameObject controller, string findPath = "")
{
if (controller != null)
{
controller.SetActive(!state);
if (findPath == "")
{
controller.SetActive(!state);
}
else
{
Transform childModel = controller.transform.Find(findPath);
if (childModel != null)
{
childModel.gameObject.SetActive(!state);
}
}
}
}

Expand Down
Loading

0 comments on commit 94c6cb5

Please sign in to comment.