Skip to content

Commit 94c6cb5

Browse files
committed
feat(SDK): add native Unity Windows Mixed Reality support
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.
1 parent a214f2f commit 94c6cb5

File tree

54 files changed

+6916
-687
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+6916
-687
lines changed

Assets/VRTK/Documentation/API.md

Lines changed: 750 additions & 1 deletion
Large diffs are not rendered by default.

Assets/VRTK/Documentation/GETTING_STARTED.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ For further information on getting started with the supported SDKs, please refer
4444
* [Simulator](/Assets/VRTK/Source/SDK/Simulator/README.md)
4545
* [SteamVR](/Assets/VRTK/Source/SDK/SteamVR/README.md)
4646
* [Oculus](/Assets/VRTK/Source/SDK/Oculus/README.md)
47+
* [Windows Mixed Reality](/Assets/VRTK/Source/SDK/WindowsMR/README.md)
4748
* [Daydream](/Assets/VRTK/Source/SDK/Daydream/README.md)
4849
* [HyperealVR](/Assets/VRTK/Source/SDK/HyperealVR/README.md)
4950
* [Ximmerse](/Assets/VRTK/Source/SDK/Ximmerse/README.md)

Assets/VRTK/Examples/ExampleResources/SceneResources/[001 - Interactions] ControllerEvents/Scripts/VRTKExample_ControllerEventsDelegateListeners.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public enum EventQuickSelect
2525
public bool triggerButtonEvents = true;
2626
public bool gripButtonEvents = true;
2727
public bool touchpadButtonEvents = true;
28+
public bool touchpadTwoButtonEvents = true;
2829
public bool buttonOneButtonEvents = true;
2930
public bool buttonTwoButtonEvents = true;
3031
public bool startMenuButtonEvents = true;
@@ -80,6 +81,10 @@ private void OnEnable()
8081
controllerEvents.TouchpadTouchStart += DoTouchpadTouchStart;
8182
controllerEvents.TouchpadTouchEnd += DoTouchpadTouchEnd;
8283
controllerEvents.TouchpadAxisChanged += DoTouchpadAxisChanged;
84+
controllerEvents.TouchpadTwoPressed += DoTouchpadTwoPressed;
85+
controllerEvents.TouchpadTwoReleased += DoTouchpadTwoReleased;
86+
controllerEvents.TouchpadTwoTouchStart += DoTouchpadTwoTouchStart;
87+
controllerEvents.TouchpadTwoTouchEnd += DoTouchpadTwoTouchEnd;
8388
controllerEvents.TouchpadTwoAxisChanged += DoTouchpadTwoAxisChanged;
8489
controllerEvents.TouchpadSenseAxisChanged += DoTouchpadSenseAxisChanged;
8590

@@ -135,6 +140,10 @@ private void OnDisable()
135140
controllerEvents.TouchpadTouchStart -= DoTouchpadTouchStart;
136141
controllerEvents.TouchpadTouchEnd -= DoTouchpadTouchEnd;
137142
controllerEvents.TouchpadAxisChanged -= DoTouchpadAxisChanged;
143+
controllerEvents.TouchpadTwoPressed -= DoTouchpadTwoPressed;
144+
controllerEvents.TouchpadTwoReleased -= DoTouchpadTwoReleased;
145+
controllerEvents.TouchpadTwoTouchStart -= DoTouchpadTwoTouchStart;
146+
controllerEvents.TouchpadTwoTouchEnd -= DoTouchpadTwoTouchEnd;
138147
controllerEvents.TouchpadTwoAxisChanged -= DoTouchpadTwoAxisChanged;
139148
controllerEvents.TouchpadSenseAxisChanged -= DoTouchpadSenseAxisChanged;
140149

@@ -169,6 +178,7 @@ private void LateUpdate()
169178
triggerButtonEvents = false;
170179
gripButtonEvents = false;
171180
touchpadButtonEvents = false;
181+
touchpadTwoButtonEvents = false;
172182
buttonOneButtonEvents = false;
173183
buttonTwoButtonEvents = false;
174184
startMenuButtonEvents = false;
@@ -188,6 +198,7 @@ private void LateUpdate()
188198
triggerButtonEvents = true;
189199
gripButtonEvents = true;
190200
touchpadButtonEvents = true;
201+
touchpadTwoButtonEvents = true;
191202
buttonOneButtonEvents = true;
192203
buttonTwoButtonEvents = true;
193204
startMenuButtonEvents = true;
@@ -207,6 +218,7 @@ private void LateUpdate()
207218
triggerButtonEvents = true;
208219
gripButtonEvents = true;
209220
touchpadButtonEvents = true;
221+
touchpadTwoButtonEvents = true;
210222
buttonOneButtonEvents = true;
211223
buttonTwoButtonEvents = true;
212224
startMenuButtonEvents = true;
@@ -226,6 +238,7 @@ private void LateUpdate()
226238
triggerButtonEvents = false;
227239
gripButtonEvents = false;
228240
touchpadButtonEvents = false;
241+
touchpadTwoButtonEvents = false;
229242
buttonOneButtonEvents = false;
230243
buttonTwoButtonEvents = false;
231244
startMenuButtonEvents = false;
@@ -245,6 +258,7 @@ private void LateUpdate()
245258
triggerButtonEvents = false;
246259
gripButtonEvents = false;
247260
touchpadButtonEvents = false;
261+
touchpadTwoButtonEvents = false;
248262
buttonOneButtonEvents = false;
249263
buttonTwoButtonEvents = false;
250264
startMenuButtonEvents = false;
@@ -462,6 +476,38 @@ private void DoTouchpadAxisChanged(object sender, ControllerInteractionEventArgs
462476
}
463477
}
464478

479+
private void DoTouchpadTwoPressed(object sender, ControllerInteractionEventArgs e)
480+
{
481+
if (touchpadTwoButtonEvents)
482+
{
483+
DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "TOUCHPADTWO", "pressed down", e);
484+
}
485+
}
486+
487+
private void DoTouchpadTwoReleased(object sender, ControllerInteractionEventArgs e)
488+
{
489+
if (touchpadTwoButtonEvents)
490+
{
491+
DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "TOUCHPADTWO", "released", e);
492+
}
493+
}
494+
495+
private void DoTouchpadTwoTouchStart(object sender, ControllerInteractionEventArgs e)
496+
{
497+
if (touchpadTwoButtonEvents)
498+
{
499+
DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "TOUCHPADTWO", "touched", e);
500+
}
501+
}
502+
503+
private void DoTouchpadTwoTouchEnd(object sender, ControllerInteractionEventArgs e)
504+
{
505+
if (touchpadTwoButtonEvents)
506+
{
507+
DebugLogger(VRTK_ControllerReference.GetRealIndex(e.controllerReference), "TOUCHPADTWO", "untouched", e);
508+
}
509+
}
510+
465511
private void DoTouchpadTwoAxisChanged(object sender, ControllerInteractionEventArgs e)
466512
{
467513
if (touchpadTwoAxisEvents)

Assets/VRTK/Examples/ExampleResources/SceneResources/[005 - Interactions] InteractableObjects/Scripts/ToggleCustomHands.cs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,34 +72,40 @@ protected virtual void ToggleSDKVisibility()
7272
{
7373
VRTK_ControllerReference leftController = VRTK_ControllerReference.GetControllerReference(VRTK_DeviceFinder.GetControllerLeftHand(true));
7474
VRTK_ControllerReference rightController = VRTK_ControllerReference.GetControllerReference(VRTK_DeviceFinder.GetControllerRightHand(true));
75-
7675
switch (sdkType.name)
7776
{
7877
case "SteamVR":
79-
ToggleSteamVRRenderer(leftController.actual);
80-
ToggleSteamVRRenderer(rightController.actual);
78+
ToggleControllerRenderer(leftController.actual, "Model");
79+
ToggleControllerRenderer(rightController.actual, "Model");
8180
break;
8281
case "Oculus":
83-
ToggleOculusRenderer(leftController.model);
84-
ToggleOculusRenderer(rightController.model);
82+
ToggleControllerRenderer(leftController.model);
83+
ToggleControllerRenderer(rightController.model);
84+
break;
85+
case "WindowsMR":
86+
ToggleControllerRenderer(leftController.model, "glTFController");
87+
ToggleControllerRenderer(rightController.model, "glTFController");
8588
break;
8689
}
8790
}
8891
}
8992

90-
protected virtual void ToggleSteamVRRenderer(GameObject controller)
91-
{
92-
if (controller != null)
93-
{
94-
controller.transform.Find("Model").gameObject.SetActive(!state);
95-
}
96-
}
97-
98-
protected virtual void ToggleOculusRenderer(GameObject controller)
93+
protected virtual void ToggleControllerRenderer(GameObject controller, string findPath = "")
9994
{
10095
if (controller != null)
10196
{
102-
controller.SetActive(!state);
97+
if (findPath == "")
98+
{
99+
controller.SetActive(!state);
100+
}
101+
else
102+
{
103+
Transform childModel = controller.transform.Find(findPath);
104+
if (childModel != null)
105+
{
106+
childModel.gameObject.SetActive(!state);
107+
}
108+
}
103109
}
104110
}
105111

0 commit comments

Comments
 (0)