-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for "select" voice command with OpenXR (#10661)
* Add support for "select" voice command with OpenXR * Update MicrosoftOpenXRGGVHand.cs
- Loading branch information
1 parent
d092fa9
commit a839860
Showing
3 changed files
with
176 additions
and
0 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
Assets/MRTK/Providers/OpenXR/Scripts/MicrosoftOpenXRGGVHand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using Microsoft.MixedReality.Toolkit.Input; | ||
using Microsoft.MixedReality.Toolkit.Utilities; | ||
using Microsoft.MixedReality.Toolkit.XRSDK.Input; | ||
using UnityEngine; | ||
|
||
namespace Microsoft.MixedReality.Toolkit.XRSDK.OpenXR | ||
{ | ||
/// <summary> | ||
/// A GGV (Gaze, Gesture, and Voice) hand instance for OpenXR. | ||
/// Used only for the purposes of acting on the select keyword detected by HoloLens 2. | ||
/// </summary> | ||
[MixedRealityController( | ||
SupportedControllerType.GGVHand, | ||
new[] { Handedness.Left, Handedness.Right, Handedness.None })] | ||
internal class MicrosoftOpenXRGGVHand : GenericXRSDKController | ||
{ | ||
public MicrosoftOpenXRGGVHand( | ||
TrackingState trackingState, | ||
Handedness controllerHandedness, | ||
IMixedRealityInputSource inputSource = null, | ||
MixedRealityInteractionMapping[] interactions = null) | ||
: base(trackingState, controllerHandedness, inputSource, interactions, new SimpleHandDefinition(controllerHandedness)) | ||
{ } | ||
|
||
internal void UpdateVoiceState(bool isPressed) | ||
{ | ||
MixedRealityInteractionMapping interactionMapping = null; | ||
|
||
for (int i = 0; i < Interactions?.Length; i++) | ||
{ | ||
MixedRealityInteractionMapping currentInteractionMapping = Interactions[i]; | ||
|
||
if (currentInteractionMapping.AxisType == AxisType.Digital && currentInteractionMapping.InputType == DeviceInputType.Select) | ||
{ | ||
interactionMapping = currentInteractionMapping; | ||
break; | ||
} | ||
} | ||
|
||
if (interactionMapping == null) | ||
{ | ||
return; | ||
} | ||
|
||
interactionMapping.BoolData = isPressed; | ||
|
||
// If our value changed raise it. | ||
if (interactionMapping.Changed) | ||
{ | ||
// Raise input system event if it's enabled | ||
if (interactionMapping.BoolData) | ||
{ | ||
CoreServices.InputSystem?.RaiseOnInputDown(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction); | ||
} | ||
else | ||
{ | ||
CoreServices.InputSystem?.RaiseOnInputUp(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction); | ||
} | ||
} | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Assets/MRTK/Providers/OpenXR/Scripts/MicrosoftOpenXRGGVHand.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters