Spatial​Gesture​Recognizer Spatial​Gesture​Recognizer Spatial​Gesture​Recognizer Class

Definition

Interprets user interactions from hands, spatial controllers, and system voice commands to surface spatial gesture events, which users target using their gaze or a spatial controller's pointing ray.

public : sealed class SpatialGestureRecognizer : ISpatialGestureRecognizerpublic sealed class SpatialGestureRecognizer : ISpatialGestureRecognizerPublic NotInheritable Class SpatialGestureRecognizer Implements ISpatialGestureRecognizer
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10586.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced v2)

Remarks

Spatial gestures are a key form of input for Mixed Reality headsets such as HoloLens. By routing interactions from the SpatialInteractionManager to a hologram's SpatialGestureRecognizer, apps can detect Tap, Hold, Manipulation, and Navigation events uniformly across hands, voice, and spatial controllers.

Note that spatial gestures are not detected for input from gamepads, keyboards or mice.

SpatialGestureRecognizer performs only the minimal disambiguation between the set of gestures that you request. For example, if you request just Tap, the user may hold their finger down as long as they like and a Tap will still occur. If you request both Tap and Hold, after about a second of holding down their finger, the gesture will promote to a Hold and a Tap will no longer occur.

To use SpatialGestureRecognizer, handle the SpatialInteractionManager's InteractionDetected event and grab the SpatialPointerPose exposed there. Use the user's gaze ray from this pose to intersect with the holograms and surface meshes in the user's surroundings, in order to determine what the user is intending to interact with. Then, route the SpatialInteraction in the event arguments to the target hologram's SpatialGestureRecognizer, using its CaptureInteraction method. This starts interpreting that interaction according to the SpatialGestureSettings set on that recognizer at creation time or by TrySetGestureSettings.

When targeting a spatial interaction, such as a hand gesture, spatial controller press or voice interaction, apps should choose a pointing ray available from the interaction's SpatialPointerPose, based on the nature of the interaction's SpatialInteractionSource:

  • If the interaction source does not support pointing (IsPointingSupported is false), the app should target based on the user's gaze, available through the Head property.
  • If the interaction source does support pointing (IsPointingSupported is true), the app may instead target based on the source's pointing pose, available through the TryGetInteractionSourcePose method.

The app should then intersect the chosen pointing ray with its own holograms or with the spatial mapping mesh to render cursors and determine what the user is intending to interact with.

Constructors

SpatialGestureRecognizer(SpatialGestureSettings) SpatialGestureRecognizer(SpatialGestureSettings) SpatialGestureRecognizer(SpatialGestureSettings)

Initializes a new SpatialGestureRecognizer with the specified gesture settings.

public : SpatialGestureRecognizer(SpatialGestureSettings settings)public SpatialGestureRecognizer(SpatialGestureSettings settings)Public Sub New(settings As SpatialGestureSettings)
Parameters
settings
SpatialGestureSettings SpatialGestureSettings SpatialGestureSettings

The gesture settings for the new recognizer.

Attributes

Properties

GestureSettings GestureSettings GestureSettings

Gets the current SpatialGestureSettings for this recognizer.

public : SpatialGestureSettings GestureSettings { get; }public SpatialGestureSettings GestureSettings { get; }Public ReadOnly Property GestureSettings As SpatialGestureSettings
Attributes

Methods

CancelPendingGestures() CancelPendingGestures() CancelPendingGestures()

Cancels any in-progress gestures, abandoning any interactions that have been captured.

public : void CancelPendingGestures()public void CancelPendingGestures()Public Function CancelPendingGestures() As void
Attributes

CaptureInteraction(SpatialInteraction) CaptureInteraction(SpatialInteraction) CaptureInteraction(SpatialInteraction)

Subscribe this SpatialGestureRecognizer to track all input events that occur as part of this interaction.

public : void CaptureInteraction(SpatialInteraction interaction)public void CaptureInteraction(SpatialInteraction interaction)Public Function CaptureInteraction(interaction As SpatialInteraction) As void
Parameters
interaction
SpatialInteraction SpatialInteraction SpatialInteraction

The SpatialInteraction to capture from the SpatialInteractionManager's InteractionDetected event.

Attributes

Remarks

To use SpatialGestureRecognizer, handle the SpatialInteractionManager's InteractionDetected event and get the SpatialPointerPose for that point in time by calling TryGetPointerPose on the event arguments. Grab the user's gaze ray from this SpatialPointerPose and intersect it with the holograms and surfaces in the user's surroundings, in order to determine what the user is intending to interact with. Then, route the SpatialInteraction in the event arguments to the target hologram's SpatialGestureRecognizer, using its CaptureInteraction method. This starts interpreting that interaction according to the SpatialGestureSettings set at creation time on that recognizer.

Note that you may choose to have more than one SpatialGestureRecognizer capture the same interaction. In this case, events will surface from both recognizers according to the SpatialGestureSettings of each. This can be useful if, for example, you have one hologram that supports Tap that is logically contained within a hologram that supports NavigationRailsY for scrolling, and you want to allow either gesture when gazing at the inner hologram.

TrySetGestureSettings(SpatialGestureSettings) TrySetGestureSettings(SpatialGestureSettings) TrySetGestureSettings(SpatialGestureSettings)

Attempt to change the gesture settings for this recognizer. This will only succeed if there are no gestures in progress at the time.

public : PlatForm::Boolean TrySetGestureSettings(SpatialGestureSettings settings)public bool TrySetGestureSettings(SpatialGestureSettings settings)Public Function TrySetGestureSettings(settings As SpatialGestureSettings) As bool
Parameters
settings
SpatialGestureSettings SpatialGestureSettings SpatialGestureSettings

The new SpatialGestureSettings to switch to.

Returns
PlatForm::Boolean bool bool

Whether the switch was successful.

Attributes

Events

HoldCanceled HoldCanceled HoldCanceled

Occurs when a Hold gesture is canceled.

public : event TypedEventHandler HoldCanceledpublic event TypedEventHandler HoldCanceledPublic Event HoldCanceled
Attributes

Remarks

For hand interactions, this event fires when the relevant hand that had a HoldStarted is lost during the gesture.

For voice interactions, this event does not fire.

For spatial controllers, this event fires when the relevant controller that had a HoldStarted is lost during the gesture.

HoldCompleted HoldCompleted HoldCompleted

Occurs when a Hold gesture completes.

public : event TypedEventHandler HoldCompletedpublic event TypedEventHandler HoldCompletedPublic Event HoldCompleted
Attributes

Remarks

For hand interactions, this event fires when the finger is released after HoldStarted.

For voice interactions, this event does not fire.

For spatial controllers, this event fires when the Select trigger or button is released after HoldStarted.

HoldStarted HoldStarted HoldStarted

Occurs when an interaction becomes a Hold gesture.

public : event TypedEventHandler HoldStartedpublic event TypedEventHandler HoldStartedPublic Event HoldStarted
Attributes

Remarks

For hand interactions, this event fires when a finger is held pressed for longer than the Hold time threshold.

For voice interactions, this event does not fire.

For spatial controllers, this event fires when the Select trigger or button is held pressed for longer than the Hold time threshold.

ManipulationCanceled ManipulationCanceled ManipulationCanceled

Occurs when a Manipulation gesture is canceled.

public : event TypedEventHandler ManipulationCanceledpublic event TypedEventHandler ManipulationCanceledPublic Event ManipulationCanceled
Attributes

Remarks

For hand interactions, this event fires when the relevant hand that had a ManipulationStarted is lost during the gesture.

For voice interactions and spatial controllers, this event does not fire.

ManipulationCompleted ManipulationCompleted ManipulationCompleted

Occurs when a Manipulation gesture is completed.

public : event TypedEventHandler ManipulationCompletedpublic event TypedEventHandler ManipulationCompletedPublic Event ManipulationCompleted
Attributes

Remarks

For hand interactions, this event fires when the finger is released after ManipulationStarted.

For voice interactions and spatial controllers, this event does not fire.

ManipulationStarted ManipulationStarted ManipulationStarted

Occurs when an interaction becomes a Manipulation gesture.

public : event TypedEventHandler ManipulationStartedpublic event TypedEventHandler ManipulationStartedPublic Event ManipulationStarted
Attributes

Remarks

For hand interactions, this event fires when a finger is pressed and then moves outside of the small Manipulation deadzone.

For voice interactions and spatial controllers, this event does not fire.

ManipulationUpdated ManipulationUpdated ManipulationUpdated

Occurs when a Manipulation gesture is updated due to hand movement.

public : event TypedEventHandler ManipulationUpdatedpublic event TypedEventHandler ManipulationUpdatedPublic Event ManipulationUpdated
Attributes

Remarks

For hand interactions, this event fires when the relevant hand that had a ManipulationStarted updates its position.

For voice interactions and spatial controllers, this event does not fire.

NavigationCanceled NavigationCanceled NavigationCanceled

Occurs when a Navigation gesture is canceled.

public : event TypedEventHandler NavigationCanceledpublic event TypedEventHandler NavigationCanceledPublic Event NavigationCanceled
Attributes

Remarks

For hand interactions, this event fires when the relevant hand that had a NavigationStarted is lost during the gesture.

For voice interactions, this event does not fire.

For spatial controllers, this event fires when the relevant controller that had a NavigationStarted is lost during the gesture.

NavigationCompleted NavigationCompleted NavigationCompleted

Occurs when a Navigation gesture is completed.

public : event TypedEventHandler NavigationCompletedpublic event TypedEventHandler NavigationCompletedPublic Event NavigationCompleted
Attributes

Remarks

For hand interactions, this event fires when the finger is released after NavigationStarted.

For voice interactions, this event does not fire.

For spatial controllers, this event fires when the Select trigger or button is released after NavigationStarted.

NavigationStarted NavigationStarted NavigationStarted

Occurs when an interaction becomes a Navigation gesture.

public : event TypedEventHandler NavigationStartedpublic event TypedEventHandler NavigationStartedPublic Event NavigationStarted
Attributes

Remarks

For hand interactions, this event fires when a finger is pressed and then moves outside of the small Navigation deadzone.

For voice interactions, this event does not fire.

For spatial controllers, this event fires when the Select trigger or button is pressed and then the controller is moved outside of the small Navigation deadzone.

NavigationUpdated NavigationUpdated NavigationUpdated

Occurs when a Navigation gesture is updated due to hand or spatial controller movement.

public : event TypedEventHandler NavigationUpdatedpublic event TypedEventHandler NavigationUpdatedPublic Event NavigationUpdated
Attributes

Remarks

For hand interactions, this event fires when the relevant hand that had a NavigationStarted updates its position.

For voice interactions, this event does not fire.

For spatial controllers, this event fires when the relevant controller that had a NavigationStarted is moved.

RecognitionEnded RecognitionEnded RecognitionEnded

Occurs when recognition of gestures is done, either due to completion of a gesture or cancellation. This is the last event to fire.

public : event TypedEventHandler RecognitionEndedpublic event TypedEventHandler RecognitionEndedPublic Event RecognitionEnded
Attributes

Remarks

For hand interactions, this event fires on finger release.

For voice interactions, this event fires after a system voice command like "Select" has been processed.

For spatial controllers, this event fires when the Select trigger or button is released.

This also fires if the relevant interaction source is lost during recognition.

RecognitionStarted RecognitionStarted RecognitionStarted

Occurs when recognition of gestures begins. This is the first event to fire.

public : event TypedEventHandler RecognitionStartedpublic event TypedEventHandler RecognitionStartedPublic Event RecognitionStarted
Attributes

Remarks

This event fires when there is no active gesture and the gesture recognizer is told to capture an interaction. Note that events will only fire if the interaction could possibly trigger at least one of the gestures requested in the SpatialGestureSettings.

For hand interactions, this event fires on finger press.

For voice interactions, this event fires when a system voice command like "Select" is spoken.

For spatial controllers, this event fires when the Select trigger or button is pressed.

Tapped Tapped Tapped

Occurs when a Tap or DoubleTap gesture is recognized.

public : event TypedEventHandler Tappedpublic event TypedEventHandler TappedPublic Event Tapped
Attributes

Remarks

For hand interactions, this event fires on finger release after a finger press.

For voice interactions, this event fires after the system voice command "Select" has been processed.

For controllers, this event fires when the Select trigger or button is released after it was pressed.