Input Events
At the script level you consume input events by implementing one of the event handler interfaces shown in the table below.
Important
By default a script will receive events only while in focus by a pointer. To receive events while out of focus, in addition to implementing the desired handler interfaces, you have to do one of the following:
- (Preferred) Register the script as a global listener via
MixedRealityToolkit.InputSystem.RegisterHandler
inOnEnable
(UnregisterHandler
explicitly inOnDisable
).RegisterHandler
needs to be called multiple times for listening to global input events on multiple interfaces. This method is preferred becauseInputSystemGlobalHandlerListener
(see below) might be an unnecessary complication in most cases. - Derive the script from
InputSystemGlobalHandlerListener
. This component is provided primarily to ease migration fromInputSystemGlobalListener
. It should also be used if having anInputSystem
property on the component is beneficial (it is used in the rest of component's logic). It requires implementing its abstract methodsRegisterHandlers
andUnregisterHandlers
. In these implementationsMixedRealityToolkit.InputSystem.RegisterHandler
should be used to list the interfaces the global events should be received for.
Handler | Events | Description |
---|---|---|
IMixedRealitySourceStateHandler |
Source Detected / Lost | Raised when an input source is detected/lost, like when an articulated hand is detected or lost track of. |
IMixedRealitySourcePoseHandler |
Source Pose Changed | Raised on source pose changes. The source pose represents the general pose of the input source. Specific poses, like the grip or pointer pose in a six DOF controller, can be obtained via IMixedRealityInputHandler<MixedRealityPose> . |
IMixedRealityInputHandler |
Input Down / Up | Raised on changes to binary inputs like buttons. |
IMixedRealityInputHandler<T> |
Input Changed | Raised on changes to inputs of the given type. T can take the following values: float (e.g. analog trigger), Vector2 (e.g. gamepad thumbstick), Vector3 (e.g. position-only tracked device), Quaternion (e.g. orientation-only tracked device) and MixedRealityPose (e.g. fully tracked device). |
IMixedRealitySpeechHandler |
Speech Keyword Recognized | Raised on recognition of one of the keywords configured in the Speech Commands Profile. |
IMixedRealityDictationHandler |
Dictation Hypothesis / Result / Complete / Error | Raised by dictation systems to report the results of a dictation session. |
IMixedRealityGestureHandler |
Gesture Started / Updated / Completed / Canceled | Raised on gesture detection. |
IMixedRealityGestureHandler<T> |
Gesture Updated / Completed | Raised on detection of gestures containing additional data of the given type. See Gesture Events for details on possible values for T. |
IMixedRealityHandJointHandler |
Hand Joints Updated | Raised by articulated hand controllers when hand joints are updated. |
IMixedRealityHandMeshHandler |
Hand Mesh Updated | Raised by articulated hand controllers when a hand mesh is updated. |
IMixedRealityInputActionHandler |
Action Started / Ended | Raise to indicate action start and end for inputs mapped to actions. |