// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using Microsoft.MixedReality.Toolkit.Utilities; using System; using System.Collections.Generic; using UnityEngine; namespace Microsoft.MixedReality.Toolkit.Input { /// /// Manager interface for a Input system in the Mixed Reality Toolkit /// All replacement systems for providing Input System functionality should derive from this interface /// public interface IMixedRealityInputSystem : IMixedRealityEventSystem { /// /// Event that's raised when the Input is enabled. /// event Action InputEnabled; /// /// Event that's raised when the Input is disabled. /// event Action InputDisabled; /// /// List of the Interaction Input Sources as detected by the input manager like hands or motion controllers. /// HashSet DetectedInputSources { get; } /// /// List of s currently detected by the input manager. /// /// /// This property is similar to , as this is a subset of those s in that list. /// HashSet DetectedControllers { get; } /// /// Typed representation of the ConfigurationProfile property. /// MixedRealityInputSystemProfile InputSystemProfile { get; } /// /// The current Focus Provider that's been implemented by this Input System. /// IMixedRealityFocusProvider FocusProvider { get; } /// /// The current Raycast Provider that's been implemented by this Input System. /// IMixedRealityRaycastProvider RaycastProvider { get; } /// /// The current Gaze Provider that's been implemented by this Input System. /// IMixedRealityGazeProvider GazeProvider { get; } /// /// The current Eye Gaze Provider that's been implemented by this Input System. /// IMixedRealityEyeGazeProvider EyeGazeProvider { get; } /// /// Indicates if input is currently enabled or not. /// bool IsInputEnabled { get; } /// /// Push a disabled input state onto the Input System. /// While input is disabled no events will be sent out and the cursor displays /// a waiting animation. /// void PushInputDisable(); /// /// Pop disabled input state. When the last disabled state is /// popped off the stack input will be re-enabled. /// void PopInputDisable(); /// /// Clear the input disable stack, which will immediately re-enable input. /// void ClearInputDisableStack(); /// /// Push a game object into the modal input stack. Any input handlers /// on the game object are given priority to input events before any focused objects. /// /// The input handler to push void PushModalInputHandler(GameObject inputHandler); /// /// Remove the last game object from the modal input stack. /// void PopModalInputHandler(); /// /// Clear all modal input handlers off the stack. /// void ClearModalInputStack(); /// /// Push a game object into the fallback input stack. Any input handlers on /// the game object are given input events when no modal or focused objects consume the event. /// /// The input handler to push void PushFallbackInputHandler(GameObject inputHandler); /// /// Remove the last game object from the fallback input stack. /// void PopFallbackInputHandler(); /// /// Clear all fallback input handlers off the stack. /// void ClearFallbackInputStack(); #region Input Events #region Input Source Events /// /// Generates a new unique input source id. /// /// All Input Sources are required to call this method in their constructor or initialization. /// a new unique Id for the input source. uint GenerateNewSourceId(); IMixedRealityInputSource RequestNewGenericInputSource(string name, IMixedRealityPointer[] pointers = null, InputSourceType sourceType = InputSourceType.Other); BaseGlobalInputSource RequestNewGlobalInputSource(string name, IMixedRealityFocusProvider focusProvider = null, InputSourceType sourceType = InputSourceType.Other); /// /// Raise the event that the Input Source was detected. /// /// The detected Input Source. void RaiseSourceDetected(IMixedRealityInputSource source, IMixedRealityController controller = null); /// /// Raise the event that the Input Source was lost. /// /// The lost Input Source. void RaiseSourceLost(IMixedRealityInputSource source, IMixedRealityController controller = null); /// /// Raise the event that the Input Source's tracking state has changed. /// void RaiseSourceTrackingStateChanged(IMixedRealityInputSource source, IMixedRealityController controller, TrackingState state); /// /// Raise the event that the Input Source position was changed. /// void RaiseSourcePositionChanged(IMixedRealityInputSource source, IMixedRealityController controller, Vector2 position); /// /// Raise the event that the Input Source position was changed. /// void RaiseSourcePositionChanged(IMixedRealityInputSource source, IMixedRealityController controller, Vector3 position); /// /// Raise the event that the Input Source position was changed. /// void RaiseSourceRotationChanged(IMixedRealityInputSource source, IMixedRealityController controller, Quaternion rotation); /// /// Raise the event that the Input Source position was changed. /// void RaiseSourcePoseChanged(IMixedRealityInputSource source, IMixedRealityController controller, MixedRealityPose position); #endregion Input Source Events #region Focus Events /// /// Raise the pre-focus changed event. /// /// This event is useful for doing logic before the focus changed event. /// The pointer that the focus change event is raised on. /// The old focused object. /// The new focused object. void RaisePreFocusChanged(IMixedRealityPointer pointer, GameObject oldFocusedObject, GameObject newFocusedObject); /// /// Raise the focus changed event. /// /// The pointer that the focus change event is raised on. /// The old focused object. /// The new focused object. void RaiseFocusChanged(IMixedRealityPointer pointer, GameObject oldFocusedObject, GameObject newFocusedObject); /// /// Raise the focus enter event. /// /// The pointer that has focus. /// The GameObject that the pointer has entered focus on. void RaiseFocusEnter(IMixedRealityPointer pointer, GameObject focusedObject); /// /// Raise the focus exit event. /// /// The pointer that has lost focus. /// The GameObject that the pointer has exited focus on. void RaiseFocusExit(IMixedRealityPointer pointer, GameObject unfocusedObject); #endregion Focus Events #region Pointers #region Pointer Down /// /// Raise the pointer down event. /// /// The pointer where the event originates. void RaisePointerDown(IMixedRealityPointer pointer, MixedRealityInputAction inputAction, Handedness handedness = Handedness.None, IMixedRealityInputSource inputSource = null); #endregion Pointer Down #region Pointer Dragged /// /// Raise the pointer dragged event. /// /// The pointer where the event originates. void RaisePointerDragged(IMixedRealityPointer pointer, MixedRealityInputAction inputAction, Handedness handedness = Handedness.None, IMixedRealityInputSource inputSource = null); #endregion Pointer Dragged #region Pointer Click /// /// Raise the pointer clicked event. /// void RaisePointerClicked(IMixedRealityPointer pointer, MixedRealityInputAction inputAction, int count, Handedness handedness = Handedness.None, IMixedRealityInputSource inputSource = null); #endregion Pointer Click #region Pointer Up /// /// Raise the pointer up event. /// void RaisePointerUp(IMixedRealityPointer pointer, MixedRealityInputAction inputAction, Handedness handedness = Handedness.None, IMixedRealityInputSource inputSource = null); #endregion Pointer Up #endregion Pointers #region Generic Input Events #region Input Down /// /// Raise the input down event. /// void RaiseOnInputDown(IMixedRealityInputSource source, Handedness handedness, MixedRealityInputAction inputAction); #endregion Input Down #region Input Up /// /// Raise the input up event. /// void RaiseOnInputUp(IMixedRealityInputSource source, Handedness handedness, MixedRealityInputAction inputAction); #endregion Input Up #region Float Input Changed /// /// Raise Float Input Changed. /// void RaiseFloatInputChanged(IMixedRealityInputSource source, Handedness handedness, MixedRealityInputAction inputAction, float inputValue); #endregion Float Input Changed #region Input Position Changed /// /// Raise the 2 degrees of freedom input event. /// void RaisePositionInputChanged(IMixedRealityInputSource source, Handedness handedness, MixedRealityInputAction inputAction, Vector2 position); /// /// Raise the 3 degrees of freedom input event. /// void RaisePositionInputChanged(IMixedRealityInputSource source, Handedness handedness, MixedRealityInputAction inputAction, Vector3 position); #endregion Input Position Changed #region Input Rotation Changed /// /// Raise the 3 degrees of freedom input event. /// void RaiseRotationInputChanged(IMixedRealityInputSource source, Handedness handedness, MixedRealityInputAction inputAction, Quaternion rotation); #endregion Input Rotation Changed #region Input Pose Changed /// /// Raise the 6 degrees of freedom input event. /// void RaisePoseInputChanged(IMixedRealityInputSource source, Handedness handedness, MixedRealityInputAction inputAction, MixedRealityPose inputData); #endregion Input Pose Changed #endregion Generic Input Events #region Generic Gesture Events /// /// Raise the Gesture Started Event. /// void RaiseGestureStarted(IMixedRealityController controller, MixedRealityInputAction action); /// /// Raise the Gesture Updated Event. /// void RaiseGestureUpdated(IMixedRealityController controller, MixedRealityInputAction action); /// /// Raise the Gesture Updated Event. /// void RaiseGestureUpdated(IMixedRealityController controller, MixedRealityInputAction action, Vector2 inputData); /// /// Raise the Gesture Updated Event. /// void RaiseGestureUpdated(IMixedRealityController controller, MixedRealityInputAction action, Vector3 inputData); /// /// Raise the Gesture Updated Event. /// void RaiseGestureUpdated(IMixedRealityController controller, MixedRealityInputAction action, Quaternion inputData); /// /// Raise the Gesture Updated Event. /// void RaiseGestureUpdated(IMixedRealityController controller, MixedRealityInputAction action, MixedRealityPose inputData); /// /// Raise the Gesture Completed Event. /// void RaiseGestureCompleted(IMixedRealityController controller, MixedRealityInputAction action); /// /// Raise the Gesture Completed Event. /// void RaiseGestureCompleted(IMixedRealityController controller, MixedRealityInputAction action, Vector2 inputData); /// /// Raise the Gesture Completed Event. /// void RaiseGestureCompleted(IMixedRealityController controller, MixedRealityInputAction action, Vector3 inputData); /// /// Raise the Gesture Completed Event. /// void RaiseGestureCompleted(IMixedRealityController controller, MixedRealityInputAction action, Quaternion inputData); /// /// Raise the Gesture Completed Event. /// void RaiseGestureCompleted(IMixedRealityController controller, MixedRealityInputAction action, MixedRealityPose inputData); /// /// Raise the Gesture Canceled Event. /// void RaiseGestureCanceled(IMixedRealityController controller, MixedRealityInputAction action); #endregion #region Speech Keyword Events /// /// /// void RaiseSpeechCommandRecognized(IMixedRealityInputSource source, RecognitionConfidenceLevel confidence, TimeSpan phraseDuration, DateTime phraseStartTime, SpeechCommands command); #endregion Speech Keyword Events #region Dictation Events /// /// /// void RaiseDictationHypothesis(IMixedRealityInputSource source, string dictationHypothesis, AudioClip dictationAudioClip = null); /// /// /// void RaiseDictationResult(IMixedRealityInputSource source, string dictationResult, AudioClip dictationAudioClip = null); /// /// /// void RaiseDictationComplete(IMixedRealityInputSource source, string dictationResult, AudioClip dictationAudioClip); /// /// /// void RaiseDictationError(IMixedRealityInputSource source, string dictationResult, AudioClip dictationAudioClip = null); #endregion Dictation Events #region Hand Events /// /// Notify system that articulated hand joint info has been updated /// void RaiseHandJointsUpdated(IMixedRealityInputSource source, Handedness handedness, IDictionary jointPoses); /// /// Notify system that articulated hand mesh has been updated /// void RaiseHandMeshUpdated(IMixedRealityInputSource source, Handedness handedness, HandMeshInfo handMeshInfo); void RaiseOnTouchStarted(IMixedRealityInputSource source, IMixedRealityController controller, Handedness handedness, Vector3 touchPoint); void RaiseOnTouchUpdated(IMixedRealityInputSource source, IMixedRealityController controller, Handedness handedness, Vector3 touchPoint); void RaiseOnTouchCompleted(IMixedRealityInputSource source, IMixedRealityController controller, Handedness handedness, Vector3 touchPoint); #endregion Hand Events #endregion Input Events } }