Skip to content

Commit db26e8b

Browse files
Documentation and clean-up pass
1 parent dd120bb commit db26e8b

File tree

5 files changed

+29
-52
lines changed

5 files changed

+29
-52
lines changed

Assets/MixedRealityToolkit/_Core/Devices/OpenVR/GenericOpenVRController.cs

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
namespace Microsoft.MixedReality.Toolkit.Internal.Devices.OpenVR
1313
{
14-
// TODO - Implement
1514
public class GenericOpenVRController : BaseController
1615
{
1716
public GenericOpenVRController(TrackingState trackingState, Handedness controllerHandedness, IMixedRealityInputSource inputSource = null, MixedRealityInteractionMapping[] interactions = null)
1817
: base(trackingState, controllerHandedness, inputSource, interactions)
1918
{
19+
//Prepare the Axis Mapping data for the OpenVR Controller
2020
Initialise();
2121

2222
//Verify the OpenVR Controller mappings are loaded
@@ -47,6 +47,9 @@ public GenericOpenVRController(TrackingState trackingState, Handedness controlle
4747

4848
private InputMappingAxisUtility.InputManagerAxis[] OpenVRControllerAxisMappings;
4949

50+
/// <summary>
51+
/// Mapping method to expose the Unity Input Manager mapping configuration
52+
/// </summary>
5053
public virtual InputMappingAxisUtility.InputManagerAxis[] ControllerAxisMappings => OpenVRControllerAxisMappings;
5154

5255
/// <summary>
@@ -68,8 +71,14 @@ public GenericOpenVRController(TrackingState trackingState, Handedness controlle
6871
"OPENVR_GRIP_RIGHT_CONTROLLER" // 11 - GRIP_RIGHT_CONTROLLER
6972
};
7073

74+
/// <summary>
75+
/// Mapping method to expose this controllers Unity Input Manager mapping array
76+
/// </summary>
7177
public virtual string[] VRInputMappings => OpenVRInputMappings;
7278

79+
/// <summary>
80+
/// Initialize the Axis mappings for the Unity Input Manager mappings
81+
/// </summary>
7382
public virtual void Initialise()
7483
{
7584
OpenVRControllerAxisMappings = new InputMappingAxisUtility.InputManagerAxis[]
@@ -211,8 +220,6 @@ protected void UpdateGripData(MixedRealityInteractionMapping interactionMapping)
211220
// If our value changed raise it.
212221
if (interactionMapping.Changed)
213222
{
214-
Debug.LogWarning($"Grip pressed for [{ControllerHandedness}] hand, set to [{gripButton}]");
215-
216223
//Raise input system Event if it enabled
217224
if (gripButton > 0)
218225
{
@@ -233,8 +240,6 @@ protected void UpdateGripData(MixedRealityInteractionMapping interactionMapping)
233240
// If our value changed raise it.
234241
if (interactionMapping.Changed)
235242
{
236-
Debug.LogWarning($"Grip pressed for [{ControllerHandedness}] hand, set to [{gripButton}]");
237-
238243
//Raise input system Event if it enabled
239244
InputSystem?.RaiseOnInputPressed(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, gripButton);
240245
}
@@ -263,8 +268,6 @@ protected void UpdateTouchPadData(MixedRealityInteractionMapping interactionMapp
263268
// If our value changed raise it.
264269
if (interactionMapping.Changed)
265270
{
266-
Debug.LogWarning($"TouchpadTouch pressed for [{ControllerHandedness}] hand, set to [{touchpadTouchButton}]");
267-
268271
//Raise input system Event if it enabled
269272
if (touchpadTouchButton)
270273
{
@@ -288,8 +291,6 @@ protected void UpdateTouchPadData(MixedRealityInteractionMapping interactionMapp
288291
// If our value changed raise it.
289292
if (interactionMapping.Changed)
290293
{
291-
Debug.LogWarning($"TouchpadPress pressed for [{ControllerHandedness}] hand, set to [{touchpadPressButton}]");
292-
293294
//Raise input system Event if it enabled
294295
if (touchpadPressButton)
295296
{
@@ -314,8 +315,6 @@ protected void UpdateTouchPadData(MixedRealityInteractionMapping interactionMapp
314315
//If our value changed raise it.
315316
if (interactionMapping.Changed)
316317
{
317-
Debug.LogWarning($"Touchpad pressed for [{ControllerHandedness}] hand, set to [{touchpadPosition}]");
318-
319318
//Raise input system Event if it enabled
320319
InputSystem?.RaisePositionInputChanged(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, touchpadPosition);
321320
}
@@ -346,8 +345,6 @@ protected void UpdateThumbStickData(MixedRealityInteractionMapping interactionMa
346345
// If our value changed raise it.
347346
if (interactionMapping.Changed)
348347
{
349-
Debug.LogWarning($"ThumbStickPress pressed for [{ControllerHandedness}] hand, set to [{thumbstickButton}]");
350-
351348
//Raise input system Event if it enabled
352349
if (thumbstickButton)
353350
{
@@ -372,8 +369,6 @@ protected void UpdateThumbStickData(MixedRealityInteractionMapping interactionMa
372369
// If our value changed raise it.
373370
if (interactionMapping.Changed)
374371
{
375-
Debug.LogWarning($"Thumbstick pressed for [{ControllerHandedness}] hand, set to [{thumbstickposition}]");
376-
377372
//Raise input system Event if it enabled
378373
InputSystem?.RaisePositionInputChanged(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, thumbstickposition);
379374
}
@@ -405,8 +400,6 @@ protected void UpdateTriggerData(MixedRealityInteractionMapping interactionMappi
405400
// If our value changed raise it.
406401
if (interactionMapping.Changed)
407402
{
408-
Debug.LogWarning($"Trigger pressed for [{ControllerHandedness}] hand, set to [{triggerButton}]");
409-
410403
//Raise input system Event if it enabled
411404
if (triggerButton)
412405
{
@@ -430,8 +423,6 @@ protected void UpdateTriggerData(MixedRealityInteractionMapping interactionMappi
430423
// If our value changed raise it.
431424
if (interactionMapping.Changed)
432425
{
433-
Debug.LogWarning($"Trigger pressed for [{ControllerHandedness}] hand, set to [{triggerAxis}] value");
434-
435426
//Raise input system Event if it enabled
436427
InputSystem?.RaiseOnInputPressed(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, triggerAxis);
437428
}
@@ -443,22 +434,21 @@ protected void UpdateTriggerData(MixedRealityInteractionMapping interactionMappi
443434
}
444435

445436
/// <summary>
446-
/// Update the Menu button state.
437+
/// Update the buttons state.
447438
/// </summary>
448439
/// <param name="interactionSourceState"></param>
449440
/// <param name="interactionMapping"></param>
450441
protected virtual void UpdateButtonData(MixedRealityInteractionMapping interactionMapping)
451442
{
452443
//Get the current Menu button state
453444
var menuButton = ControllerHandedness == Handedness.Left ? Input.GetKey(KeyCode.JoystickButton2) : Input.GetKey(KeyCode.JoystickButton0);
445+
454446
//Update the interaction data source
455447
interactionMapping.SetBoolValue(menuButton);
456448

457449
// If our value changed raise it.
458450
if (interactionMapping.Changed)
459451
{
460-
Debug.LogWarning($"Menu pressed for [{ControllerHandedness}] hand, set to [{menuButton}]");
461-
462452
//Raise input system Event if it enabled
463453
if (menuButton)
464454
{

Assets/MixedRealityToolkit/_Core/Devices/OpenVR/HTCViveController.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
namespace Microsoft.MixedReality.Toolkit.Internal.Devices.OpenVR
1010
{
11-
// TODO - Implement
1211
public class HTCViveController : GenericOpenVRController
1312
{
1413
public HTCViveController(TrackingState trackingState, Handedness controllerHandedness, IMixedRealityInputSource inputSource = null, MixedRealityInteractionMapping[] interactions = null)
@@ -18,6 +17,7 @@ public HTCViveController(TrackingState trackingState, Handedness controllerHande
1817

1918
private InputMappingAxisUtility.InputManagerAxis[] HTCViveControllerAxisMappings;
2019

20+
/// <inheritdoc />
2121
public override InputMappingAxisUtility.InputManagerAxis[] ControllerAxisMappings => HTCViveControllerAxisMappings;
2222

2323
/// <summary>
@@ -41,8 +41,10 @@ public HTCViveController(TrackingState trackingState, Handedness controllerHande
4141
"VIVE_GRIP_RIGHT_CONTROLLER" // 11 - GRIP_RIGHT_CONTROLLER
4242
};
4343

44+
/// <inheritdoc />
4445
public override string[] VRInputMappings => HTCViveInputMappings;
4546

47+
/// <inheritdoc />
4648
public override void Initialise()
4749
{
4850
HTCViveControllerAxisMappings = new InputMappingAxisUtility.InputManagerAxis[]

Assets/MixedRealityToolkit/_Core/Devices/OpenVR/OculusTouchController.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
namespace Microsoft.MixedReality.Toolkit.Internal.Devices.OpenVR
1010
{
11-
// TODO - Implement
1211
public class OculusTouchController : GenericOpenVRController
1312
{
1413
public OculusTouchController(TrackingState trackingState, Handedness controllerHandedness, IMixedRealityInputSource inputSource, MixedRealityInteractionMapping[] interactions)
@@ -18,6 +17,7 @@ public OculusTouchController(TrackingState trackingState, Handedness controllerH
1817

1918
private InputMappingAxisUtility.InputManagerAxis[] OcculusTouchControllerAxisMappings;
2019

20+
/// <inheritdoc />
2121
public override InputMappingAxisUtility.InputManagerAxis[] ControllerAxisMappings => OcculusTouchControllerAxisMappings;
2222

2323
/// <summary>
@@ -41,8 +41,10 @@ public OculusTouchController(TrackingState trackingState, Handedness controllerH
4141
"OTOUCH_GRIP_RIGHT_CONTROLLER" // 11 - GRIP_RIGHT_CONTROLLER
4242
};
4343

44+
/// <inheritdoc />
4445
public override string[] VRInputMappings => OcculusTouchInputMappings;
4546

47+
/// <inheritdoc />
4648
public override void Initialise()
4749
{
4850
OcculusTouchControllerAxisMappings = new InputMappingAxisUtility.InputManagerAxis[]

Assets/MixedRealityToolkit/_Core/Devices/OpenVR/OpenVRDeviceManager.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Microsoft.MixedReality.Toolkit.Internal.Devices.OpenVR
1313
{
14-
// TODO - Implement
1514
public class OpenVRDeviceManager : BaseDeviceManager
1615
{
1716
public OpenVRDeviceManager(string name, uint priority) : base(name, priority) { }
@@ -151,7 +150,7 @@ private IMixedRealityController GetOrAddController(XRNodeState xrNodeState)
151150
//TODO - Need logic to determine controller type (if possible)
152151
var detectedController = new GenericOpenVRController(TrackingState.NotTracked, controllingHand, inputSource);
153152
detectedController.SetupConfiguration(typeof(GenericOpenVRController));
154-
153+
detectedController.UpdateController(xrNodeState);
155154
activeControllers.Add(xrNodeState.nodeType, detectedController);
156155

157156
return detectedController;

Assets/MixedRealityToolkit/_Core/Devices/OpenVR/ValveKnucklesController.cs

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Microsoft.MixedReality.Toolkit.Internal.Devices.OpenVR
1313
{
14-
// TODO - Implement
1514
public class ValveKnucklesController : GenericOpenVRController
1615
{
1716
public ValveKnucklesController(TrackingState trackingState, Handedness controllerHandedness, IMixedRealityInputSource inputSource = null, MixedRealityInteractionMapping[] interactions = null)
@@ -21,6 +20,7 @@ public ValveKnucklesController(TrackingState trackingState, Handedness controlle
2120

2221
private InputMappingAxisUtility.InputManagerAxis[] ValveKnucklesControllerAxisMappings;
2322

23+
/// <inheritdoc />
2424
public override InputMappingAxisUtility.InputManagerAxis[] ControllerAxisMappings => ValveKnucklesControllerAxisMappings;
2525

2626
/// <summary>
@@ -52,8 +52,10 @@ public ValveKnucklesController(TrackingState trackingState, Handedness controlle
5252
"VKNUCKLES_PINKYFINGER_RIGHT_CONTROLLER", // 19 - PINKYFINGER_RIGHT_CONTROLLER
5353
};
5454

55+
/// <inheritdoc />
5556
public override string[] VRInputMappings => ValveKnucklesInputMappings;
5657

58+
/// <inheritdoc />
5759
public override void Initialise()
5860
{
5961
ValveKnucklesControllerAxisMappings = new InputMappingAxisUtility.InputManagerAxis[]
@@ -79,9 +81,9 @@ public override void Initialise()
7981

8082
#endregion Base override configuration
8183

82-
/// <summary>
83-
/// Update the controller data from the provided platform state
84-
/// </summary>
84+
#region Update data functions
85+
86+
/// <inheritdoc />
8587
public override void UpdateController(XRNodeState xrNodeState)
8688
{
8789
Debug.Assert(Interactions != null, "No interaction configuration for controller");
@@ -136,11 +138,7 @@ public override void UpdateController(XRNodeState xrNodeState)
136138
LastStateReading = xrNodeState;
137139
}
138140

139-
/// <summary>
140-
/// Update the Trigger input from the device
141-
/// </summary>
142-
/// <param name="interactionSourceState">The InteractionSourceState retrieved from the platform</param>
143-
/// <param name="interactionMapping"></param>
141+
/// <inheritdoc />
144142
protected void UpdateFingerData(MixedRealityInteractionMapping interactionMapping)
145143
{
146144
switch (interactionMapping.InputType)
@@ -156,8 +154,6 @@ protected void UpdateFingerData(MixedRealityInteractionMapping interactionMappin
156154
// If our value changed raise it.
157155
if (interactionMapping.Changed)
158156
{
159-
Debug.LogWarning($"Trigger pressed for [{ControllerHandedness}] hand, set to [{IndexFingerAxis}] value");
160-
161157
//Raise input system Event if it enabled
162158
InputSystem?.RaiseOnInputPressed(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, IndexFingerAxis);
163159
}
@@ -174,8 +170,6 @@ protected void UpdateFingerData(MixedRealityInteractionMapping interactionMappin
174170
// If our value changed raise it.
175171
if (interactionMapping.Changed)
176172
{
177-
Debug.LogWarning($"Trigger pressed for [{ControllerHandedness}] hand, set to [{MiddleFingerAxis}] value");
178-
179173
//Raise input system Event if it enabled
180174
InputSystem?.RaiseOnInputPressed(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, MiddleFingerAxis);
181175
}
@@ -192,8 +186,6 @@ protected void UpdateFingerData(MixedRealityInteractionMapping interactionMappin
192186
// If our value changed raise it.
193187
if (interactionMapping.Changed)
194188
{
195-
Debug.LogWarning($"Trigger pressed for [{ControllerHandedness}] hand, set to [{RingFingerAxis}] value");
196-
197189
//Raise input system Event if it enabled
198190
InputSystem?.RaiseOnInputPressed(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, RingFingerAxis);
199191
}
@@ -210,8 +202,6 @@ protected void UpdateFingerData(MixedRealityInteractionMapping interactionMappin
210202
// If our value changed raise it.
211203
if (interactionMapping.Changed)
212204
{
213-
Debug.LogWarning($"Trigger pressed for [{ControllerHandedness}] hand, set to [{PinkyFingerAxis}] value");
214-
215205
//Raise input system Event if it enabled
216206
InputSystem?.RaiseOnInputPressed(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, PinkyFingerAxis);
217207
}
@@ -222,11 +212,7 @@ protected void UpdateFingerData(MixedRealityInteractionMapping interactionMappin
222212
}
223213
}
224214

225-
/// <summary>
226-
/// Update the Menu button state.
227-
/// </summary>
228-
/// <param name="interactionSourceState"></param>
229-
/// <param name="interactionMapping"></param>
215+
/// <inheritdoc />
230216
protected override void UpdateButtonData(MixedRealityInteractionMapping interactionMapping)
231217
{
232218
switch (interactionMapping.InputType)
@@ -241,8 +227,6 @@ protected override void UpdateButtonData(MixedRealityInteractionMapping interact
241227
// If our value changed raise it.
242228
if (interactionMapping.Changed)
243229
{
244-
Debug.LogWarning($"Menu pressed for [{ControllerHandedness}] hand, set to [{menuButton}]");
245-
246230
//Raise input system Event if it enabled
247231
if (menuButton)
248232
{
@@ -265,8 +249,6 @@ protected override void UpdateButtonData(MixedRealityInteractionMapping interact
265249
// If our value changed raise it.
266250
if (interactionMapping.Changed)
267251
{
268-
Debug.LogWarning($"Menu pressed for [{ControllerHandedness}] hand, set to [{secondaryButton}]");
269-
270252
//Raise input system Event if it enabled
271253
if (secondaryButton)
272254
{
@@ -283,5 +265,7 @@ protected override void UpdateButtonData(MixedRealityInteractionMapping interact
283265
throw new IndexOutOfRangeException();
284266
}
285267
}
268+
269+
#endregion Update data functions
286270
}
287271
}

0 commit comments

Comments
 (0)