Share via


SpatialGestureRecognizer Class

Definition

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

public ref class SpatialGestureRecognizer sealed
/// [Windows.Foundation.Metadata.Activatable(Windows.UI.Input.Spatial.ISpatialGestureRecognizerFactory, 131072, "Windows.Foundation.UniversalApiContract")]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 131072)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class SpatialGestureRecognizer final
[Windows.Foundation.Metadata.Activatable(typeof(Windows.UI.Input.Spatial.ISpatialGestureRecognizerFactory), 131072, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 131072)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class SpatialGestureRecognizer
function SpatialGestureRecognizer(settings)
Public NotInheritable Class SpatialGestureRecognizer
Inheritance
Object Platform::Object IInspectable SpatialGestureRecognizer
Attributes

Windows requirements

Device family
Windows 10 (introduced in 10.0.10586.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced in v2.0)

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 motion 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, motion 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 pointer 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.

For applications using the gaze-and-commit input model, particularly on HoloLens (first gen), SpatialGestureRecognizer can be used to to enable composite gestures built on top of the 'select' event. 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 input devices, without having to handle presses and releases manually.

Constructors

SpatialGestureRecognizer(SpatialGestureSettings)

Initializes a new SpatialGestureRecognizer with the specified gesture settings.

Properties

GestureSettings

Gets the current SpatialGestureSettings for this recognizer.

Methods

CancelPendingGestures()

Cancels all in-progress gestures and abandons any captured interactions.

CaptureInteraction(SpatialInteraction)

Track all input events that occur as part of the specified interaction.

TrySetGestureSettings(SpatialGestureSettings)

Attempts to change the gesture settings for this recognizer.

Events

HoldCanceled

Occurs when a Hold gesture is canceled.

HoldCompleted

Occurs when a Hold gesture completes.

HoldStarted

Occurs when an interaction becomes a Hold gesture.

ManipulationCanceled

Occurs when a Manipulation gesture is canceled.

ManipulationCompleted

Occurs when a Manipulation gesture is completed.

ManipulationStarted

Occurs when an interaction becomes a Manipulation gesture.

ManipulationUpdated

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

NavigationCanceled

Occurs when a Navigation gesture is canceled.

NavigationCompleted

Occurs when a Navigation gesture is completed.

NavigationStarted

Occurs when an interaction becomes a Navigation gesture.

NavigationUpdated

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

RecognitionEnded

Occurs when gesture recognition ends, due to completion or cancellation of a gesture (this is the last event to fire).

RecognitionStarted

Occurs when gesture recognition begins (this is the first event to fire).

Tapped

Occurs when a Tap or DoubleTap gesture is recognized.

Applies to

See also