SpatialGestureRecognizer SpatialGestureRecognizer SpatialGestureRecognizer SpatialGestureRecognizer 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 : sealed class SpatialGestureRecognizer : ISpatialGestureRecognizer
struct winrt::Windows::UI::Input::Spatial::SpatialGestureRecognizer : ISpatialGestureRecognizer
public sealed class SpatialGestureRecognizer : ISpatialGestureRecognizer
Public NotInheritable Class SpatialGestureRecognizer Implements ISpatialGestureRecognizer
var spatialGestureRecognizer = new spatialGestureRecognizer(settings);
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 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.

Constructors

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

Initializes a new SpatialGestureRecognizer with the specified gesture settings.

Properties

GestureSettings GestureSettings GestureSettings GestureSettings GestureSettings

Gets the current SpatialGestureSettings for this recognizer.

Methods

CancelPendingGestures() CancelPendingGestures() CancelPendingGestures() CancelPendingGestures() CancelPendingGestures()

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

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

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

TrySetGestureSettings(SpatialGestureSettings) TrySetGestureSettings(SpatialGestureSettings) 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.

Events

HoldCanceled HoldCanceled HoldCanceled HoldCanceled HoldCanceled

Occurs when a Hold gesture is canceled.

HoldCompleted HoldCompleted HoldCompleted HoldCompleted HoldCompleted

Occurs when a Hold gesture completes.

HoldStarted HoldStarted HoldStarted HoldStarted HoldStarted

Occurs when an interaction becomes a Hold gesture.

ManipulationCanceled ManipulationCanceled ManipulationCanceled ManipulationCanceled ManipulationCanceled

Occurs when a Manipulation gesture is canceled.

ManipulationCompleted ManipulationCompleted ManipulationCompleted ManipulationCompleted ManipulationCompleted

Occurs when a Manipulation gesture is completed.

ManipulationStarted ManipulationStarted ManipulationStarted ManipulationStarted ManipulationStarted

Occurs when an interaction becomes a Manipulation gesture.

ManipulationUpdated ManipulationUpdated ManipulationUpdated ManipulationUpdated ManipulationUpdated

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

NavigationCanceled NavigationCanceled NavigationCanceled NavigationCanceled NavigationCanceled

Occurs when a Navigation gesture is canceled.

NavigationCompleted NavigationCompleted NavigationCompleted NavigationCompleted NavigationCompleted

Occurs when a Navigation gesture is completed.

NavigationStarted NavigationStarted NavigationStarted NavigationStarted NavigationStarted

Occurs when an interaction becomes a Navigation gesture.

NavigationUpdated NavigationUpdated NavigationUpdated NavigationUpdated NavigationUpdated

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

RecognitionEnded RecognitionEnded 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.

RecognitionStarted RecognitionStarted RecognitionStarted RecognitionStarted RecognitionStarted

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

Tapped Tapped Tapped Tapped Tapped

Occurs when a Tap or DoubleTap gesture is recognized.

See Also