/// <summary> /// This event is fired while the user is talking. As the recognizer listens, it provides text of what it's heard so far. /// </summary> /// <param name="text">The currently hypothesized recognition.</param> private void DictationRecognizer_DictationHypothesis(string text) { Profiler.BeginSample("[MRTK] WindowsDictationInputProvider.DictationRecognizer_DictationHypothesis"); // We don't want to append to textSoFar yet, because the hypothesis may have changed on the next event. dictationResult = $"{textSoFar} {text}..."; IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; inputSystem?.RaiseDictationHypothesis(inputSource, dictationResult); Profiler.EndSample(); // DictationHypothesis }
/// <summary> /// Constructor. /// </summary> /// <param name="registrar">The <see cref="IMixedRealityServiceRegistrar"/> instance that loaded the data provider.</param> /// <param name="inputSystem">The <see cref="Microsoft.MixedReality.Toolkit.Input.IMixedRealityInputSystem"/> instance that receives data from this provider.</param> /// <param name="name">Friendly name of the service.</param> /// <param name="priority">Service priority. Used to determine order of instantiation.</param> /// <param name="profile">The service's configuration profile.</param> public BaseInputDeviceManager( IMixedRealityServiceRegistrar registrar, IMixedRealityInputSystem inputSystem, string name, uint priority, BaseMixedRealityProfile profile) : base(registrar, inputSystem, name, priority, profile) { if (inputSystem == null) { Debug.LogError($"{name} requires a valid input system instance."); } InputSystem = inputSystem; }
private void OnPhraseRecognized(ConfidenceLevel confidence, TimeSpan phraseDuration, DateTime phraseStartTime, string text) { IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; for (int i = 0; i < Commands?.Length; i++) { if (Commands[i].LocalizedKeyword == text) { inputSystem?.RaiseSpeechCommandRecognized(InputSource, (RecognitionConfidenceLevel)confidence, phraseDuration, phraseStartTime, Commands[i]); break; } } }
/// <summary> /// Resets all cached system references to null /// </summary> public static void ResetCacheReferences() { serviceCache.Clear(); boundarySystem = null; cameraSystem = null; diagnosticsSystem = null; focusProvider = null; inputSystem = null; raycastProvider = null; sceneSystem = null; spatialAwarenessSystem = null; teleportSystem = null; }
/// <summary> /// Constructor. /// </summary> /// <param name="inputSystem">The <see cref="Microsoft.MixedReality.Toolkit.Input.IMixedRealityInputSystem"/> instance that receives data from this provider.</param> /// <param name="name">Friendly name of the service.</param> /// <param name="priority">Service priority. Used to determine order of instantiation.</param> /// <param name="profile">The service's configuration profile.</param> public OpenXREyeGazeDataProvider( IMixedRealityInputSystem inputSystem, string name, uint priority, BaseMixedRealityProfile profile) : base(inputSystem, name, priority, profile) { gazeSmoother = new EyeGazeSmoother(); // Register for these events to forward along, in case code is still registering for the obsolete actions gazeSmoother.OnSaccade += GazeSmoother_OnSaccade; gazeSmoother.OnSaccadeX += GazeSmoother_OnSaccadeX; gazeSmoother.OnSaccadeY += GazeSmoother_OnSaccadeY; }
private OculusQuestHand GetOrAddHand(Handedness handedness, OVRHand ovrHand) { if (trackedHands.ContainsKey(handedness)) { return(trackedHands[handedness]); } Material handMaterial = null; if (handedness == Handedness.Right) { if (rightHandMaterial == null) { rightHandMaterial = new Material(MRTKOculusConfig.Instance.CustomHandMaterial); } handMaterial = rightHandMaterial; } else { if (leftHandMaterial == null) { leftHandMaterial = new Material(MRTKOculusConfig.Instance.CustomHandMaterial); } handMaterial = leftHandMaterial; } // Add new hand var pointers = RequestPointers(SupportedControllerType.ArticulatedHand, handedness); var inputSourceType = InputSourceType.Hand; IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; var inputSource = inputSystem?.RequestNewGenericInputSource($"Oculus Quest {handedness} Hand", pointers, inputSourceType); var controller = new OculusQuestHand(TrackingState.Tracked, handedness, ovrHand, handMaterial, inputSource); // Code is obsolete later on, but older MRTK versions require it. #pragma warning disable 618 controller.SetupConfiguration(typeof(OculusQuestHand)); #pragma warning restore 618 for (int i = 0; i < controller.InputSource?.Pointers?.Length; i++) { controller.InputSource.Pointers[i].Controller = controller; } inputSystem?.RaiseSourceDetected(controller.InputSource, controller); trackedHands.Add(handedness, controller); return(controller); }
/// <summary> /// Gets or adds a controller using the InputDevice name provided. /// </summary> /// <param name="inputDevice">The InputDevice from XR SDK.</param> /// <returns>The controller reference.</returns> protected virtual GenericXRSDKController GetOrAddController(InputDevice inputDevice) { // If a device is already registered with the ID provided, just return it. if (ActiveControllers.ContainsKey(inputDevice)) { var controller = ActiveControllers[inputDevice]; Debug.Assert(controller != null); return(controller); } Handedness controllingHand; if (inputDevice.characteristics.HasFlag(InputDeviceCharacteristics.Left)) { controllingHand = Handedness.Left; } else if (inputDevice.characteristics.HasFlag(InputDeviceCharacteristics.Right)) { controllingHand = Handedness.Right; } else { controllingHand = Handedness.None; } var currentControllerType = GetCurrentControllerType(inputDevice); Type controllerType = GetControllerType(currentControllerType); InputSourceType inputSourceType = GetInputSourceType(currentControllerType); IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; IMixedRealityPointer[] pointers = RequestPointers(currentControllerType, controllingHand); IMixedRealityInputSource inputSource = inputSystem?.RequestNewGenericInputSource($"{currentControllerType} Controller {controllingHand}", pointers, inputSourceType); GenericXRSDKController detectedController = Activator.CreateInstance(controllerType, TrackingState.NotTracked, controllingHand, inputSource, null) as GenericXRSDKController; if (detectedController == null || !detectedController.Enabled) { // Controller failed to be set up correctly. Debug.LogError($"Failed to create {controllerType.Name} controller"); // Return null so we don't raise the source detected. return(null); } for (int i = 0; i < detectedController.InputSource?.Pointers?.Length; i++) { detectedController.InputSource.Pointers[i].Controller = detectedController; } ActiveControllers.Add(inputDevice, detectedController); return(detectedController); }
/// <inheritdoc /> public override void Disable() { IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; if (SimulatedMotionControllerDictionary.ContainsKey(Handedness.Left)) { UnplugSimulatedMotionController(Handedness.Left); } if (SimulatedMotionControllerDictionary.ContainsKey(Handedness.Right)) { UnplugSimulatedMotionController(Handedness.Right); } }
/// <summary> /// This event is fired when an error occurs. /// </summary> /// <param name="error">The string representation of the error reason.</param> /// <param name="hresult">The int representation of the hresult.</param> private void DictationRecognizer_DictationError(string error, int hresult) { Profiler.BeginSample("[MRTK] WindowsDictationInputProvider.DictationRecognizer_DictationError"); dictationResult = $"{error}\nHRESULT: {hresult}"; IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; inputSystem?.RaiseDictationError(inputSource, dictationResult); textSoFar = null; dictationResult = string.Empty; Profiler.EndSample(); // DictationError }
/// <summary> /// This event is fired after the user pauses, typically at the end of a sentence. The full recognized string is returned here. /// </summary> /// <param name="text">The text that was heard by the recognizer.</param> /// <param name="confidence">A representation of how confident (rejected, low, medium, high) the recognizer is of this recognition.</param> private void DictationRecognizer_DictationResult(string text, ConfidenceLevel confidence) { Profiler.BeginSample("[MRTK] WindowsDictationInputProvider.DictationRecognizer_DictationResult"); textSoFar.Append($"{text}. "); dictationResult = textSoFar.ToString(); IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; inputSystem?.RaiseDictationResult(inputSource, dictationResult); Profiler.EndSample(); // DictationResult }
/// <inheritdoc /> public override void Disable() { IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; foreach (var genericJoystick in ActiveControllers) { if (genericJoystick.Value != null) { inputSystem?.RaiseSourceLost(genericJoystick.Value.InputSource, genericJoystick.Value); } } ActiveControllers.Clear(); }
/// <summary> /// SDK Interaction Source Detected Event handler /// </summary> /// <param name="args">SDK source detected event arguments</param> private void InteractionManager_InteractionSourceDetected(InteractionSourceDetectedEventArgs args) { bool raiseSourceDetected = !activeControllers.ContainsKey(args.state.source.id); var controller = GetController(args.state.source); if (controller != null && raiseSourceDetected) { IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; inputSystem?.RaiseSourceDetected(controller.InputSource, controller); } controller?.UpdateController(args.state); }
private void RemoveTouchController(Touch touch) { UnityTouchController controller; if (!ActiveTouches.TryGetValue(touch.fingerId, out controller)) { return; } controller.EndTouch(); IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; inputSystem?.RaiseSourceLost(controller.InputSource, controller); }
void MLControllerDisconnected(byte controllerId) { MLControllerContainer controllerContainer = GetConnectedController(controllerId); if (controllerContainer != null) { IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; inputSystem?.RaiseSourceLost(controllerContainer.mrtkController.InputSource, controllerContainer.mrtkController); trackedControls.Remove(controllerContainer.mrtkController); RecyclePointers(controllerContainer.mrtkController.InputSource); controllerContainer.mrtkController.CleanupController(); ConnectedControllers.Remove(controllerId); } return; }
/// <inheritdoc /> public override void Enable() { if (!Application.isPlaying || (Commands == null) || (Commands.Length == 0)) { return; } if (InputSystemProfile == null) { return; } IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; InputSource = inputSystem?.RequestNewGenericInputSource("Windows Speech Input Source", sourceType: InputSourceType.Voice); var newKeywords = new string[Commands.Length]; for (int i = 0; i < Commands.Length; i++) { newKeywords[i] = Commands[i].LocalizedKeyword; } RecognitionConfidenceLevel = InputSystemProfile.SpeechCommandsProfile.SpeechRecognitionConfidenceLevel; if (keywordRecognizer == null) { try { keywordRecognizer = new KeywordRecognizer(newKeywords, (ConfidenceLevel)RecognitionConfidenceLevel); } catch (UnityException ex) { Debug.LogWarning($"Failed to start keyword recognizer. Are microphone permissions granted? Exception: {ex}"); keywordRecognizer = null; return; } keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized; } if (InputSystemProfile.SpeechCommandsProfile.SpeechRecognizerStartBehavior == AutoStartBehavior.AutoStart) { StartRecognition(); } }
public override void Disable() { base.Disable(); IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; foreach (var hand in trackedHands) { if (hand.Value != null) { inputSystem?.RaiseSourceLost(hand.Value.InputSource, hand.Value); } } trackedHands.Clear(); }
/// <summary> /// This event is fired when the recognizer stops, whether from StartRecording() being called, a timeout occurring, or some other error. /// Typically, this will simply return "Complete". In this case, we check to see if the recognizer timed out. /// </summary> /// <param name="cause">An enumerated reason for the session completing.</param> private void DictationRecognizer_DictationComplete(DictationCompletionCause cause) { // If Timeout occurs, the user has been silent for too long. if (cause == DictationCompletionCause.TimeoutExceeded) { Microphone.End(deviceName); dictationResult = "Dictation has timed out. Please try again."; } IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; inputSystem?.RaiseDictationComplete(inputSource, dictationResult, dictationAudioClip); textSoFar = null; dictationResult = string.Empty; }
/// <inheritdoc /> public async Task <AudioClip> StopRecordingAsync() { using (StopRecordingAsyncPerfMarker.Auto()) { #if UNITY_STANDALONE_WIN || UNITY_WSA || UNITY_EDITOR_WIN if (!IsListening || isTransitioning || !Application.isPlaying) { Debug.LogWarning("Unable to stop recording"); return(null); } IsListening = false; isTransitioning = true; IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; if (hasListener) { inputSystem?.PopModalInputHandler(); hasListener = false; } Microphone.End(deviceName); if (dictationRecognizer.Status == SpeechSystemStatus.Running) { dictationRecognizer.Stop(); } await waitUntilDictationRecognizerHasStopped; Debug.Assert(dictationRecognizer.Status == SpeechSystemStatus.Stopped); PhraseRecognitionSystem.Restart(); await waitUntilPhraseRecognitionSystemHasStarted; Debug.Assert(PhraseRecognitionSystem.Status == SpeechSystemStatus.Running); isTransitioning = false; return(dictationAudioClip); #else await Task.CompletedTask; return(null); #endif } }
/// <summary> /// Gets or adds a controller using the joystick name provided. /// </summary> /// <param name="joystickName">The name of the joystick from Unity's <see href="https://docs.unity3d.com/ScriptReference/Input.GetJoystickNames.html">Input.GetJoystickNames</see></param> /// <returns>A new controller reference.</returns> protected virtual GenericJoystickController GetOrAddController(string joystickName) { IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; if (ActiveControllers.ContainsKey(joystickName)) { var controller = ActiveControllers[joystickName]; Debug.Assert(controller != null); return(controller); } Type controllerType; switch (GetCurrentControllerType(joystickName)) { default: return(null); case SupportedControllerType.GenericUnity: controllerType = typeof(GenericJoystickController); break; case SupportedControllerType.Xbox: controllerType = typeof(XboxController); break; } var inputSource = inputSystem?.RequestNewGenericInputSource($"{controllerType.Name} Controller", sourceType: InputSourceType.Controller); var detectedController = Activator.CreateInstance(controllerType, TrackingState.NotTracked, Handedness.None, inputSource, null) as GenericJoystickController; if (detectedController == null) { Debug.LogError($"Failed to create {controllerType.Name} controller"); return(null); } if (!detectedController.SetupConfiguration(controllerType)) { // Controller failed to be setup correctly. // Return null so we don't raise the source detected. return(null); } ActiveControllers.Add(joystickName, detectedController); return(detectedController); }
private void HandleOnControllerConnected(byte controllerId) { MLInputController controller = MLInput.GetController(controllerId); if (mlInputControllers.Exists((device) => device.Id == controllerId)) { Debug.LogWarning(string.Format("Connected controller with id {0} already connected.", controllerId)); return; } mlInputControllers.Add(controller); // Generate MRTK Controller Handedness controllingHand; if (controller.Type == MLInputControllerType.Control && controller.Hand == MLInput.Hand.Left) { controllingHand = Handedness.Left; } else if (controller.Type == MLInputControllerType.Control && controller.Hand == MLInput.Hand.Right) { controllingHand = Handedness.Right; } else { controllingHand = Handedness.Other; } var currentControllerType = SupportedControllerType.GenericOpenVR; var controllerType = typeof(MagicLeapController); var pointers = RequestPointers(currentControllerType, controllingHand); IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; var inputSource = inputSystem?.RequestNewGenericInputSource($"{currentControllerType} Controller {controllingHand}", pointers, InputSourceType.Controller); var detectedController = new MagicLeapController(TrackingState.Tracked, controllingHand, inputSource); detectedController.SetupConfiguration(controllerType); for (int i = 0; i < detectedController.InputSource?.Pointers?.Length; i++) { detectedController.InputSource.Pointers[i].Controller = detectedController; } ActiveControllers.Add(controllerId, detectedController); inputSystem?.RaiseSourceDetected(detectedController.InputSource, detectedController); }
private void OnPhraseRecognized(ConfidenceLevel confidence, TimeSpan phraseDuration, DateTime phraseStartTime, string text) { Profiler.BeginSample("[MRTK] WindowsSpeechInputProvider.OnPhraseRecognized"); IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; for (int i = 0; i < Commands?.Length; i++) { if (Commands[i].LocalizedKeyword == text) { inputSystem?.RaiseSpeechCommandRecognized(InputSource, (RecognitionConfidenceLevel)confidence, phraseDuration, phraseStartTime, Commands[i]); break; } } Profiler.EndSample(); // OnPhraseRecognized }
/// <summary> /// Constructor. /// </summary> /// <param name="inputSystem">The <see cref="Microsoft.MixedReality.Toolkit.Input.IMixedRealityInputSystem"/> instance that receives data from this provider.</param> /// <param name="name">Friendly name of the service.</param> /// <param name="priority">Service priority. Used to determine order of instantiation.</param> /// <param name="profile">The service's configuration profile.</param> public WindowsMixedRealityEyeGazeDataProvider( IMixedRealityInputSystem inputSystem, string name, uint priority, BaseMixedRealityProfile profile) : base(inputSystem, name, priority, profile) { eyesApiAvailable = WindowsApiChecker.IsPropertyAvailable( "Windows.UI.Input.Spatial", "SpatialPointerPose", "Eyes"); #if (UNITY_WSA && DOTNETWINRT_PRESENT) || WINDOWS_UWP if (eyesApiAvailable) { eyesApiAvailable &= EyesPose.IsSupported(); } #endif // (UNITY_WSA && DOTNETWINRT_PRESENT) || WINDOWS_UWP }
public IEnumerator LoadHandInteractionExamplesScene() { AsyncOperation loadOp = SceneManager.LoadSceneAsync(HandInteractionExamplesSceneName); loadOp.allowSceneActivation = true; while (!loadOp.isDone) { yield return(null); } yield return(new WaitForSeconds(ScenePlayDuration)); IMixedRealityInputSystem inputSystem = null; MixedRealityServiceRegistry.TryGetService(out inputSystem); Assert.NotNull(inputSystem); }
private OculusQuestHand GetOrAddHand(Handedness handedness, OVRHand ovrHand) { if (trackedHands.ContainsKey(handedness)) { return(trackedHands[handedness]); } // Add new hand var pointers = RequestPointers(SupportedControllerType.ArticulatedHand, handedness); var inputSourceType = InputSourceType.Hand; IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; var inputSource = inputSystem?.RequestNewGenericInputSource($"Oculus Quest {handedness} Hand", pointers, inputSourceType); if (!inactiveHandCache.TryGetValue(handedness, out var handController)) { handController = new OculusQuestHand(TrackingState.Tracked, handedness, inputSource); handController.InitializeHand(ovrHand, MRTKOculusConfig.Instance.CustomHandMaterial); } inactiveHandCache.Remove(handedness); for (int i = 0; i < handController.InputSource?.Pointers?.Length; i++) { handController.InputSource.Pointers[i].Controller = handController; } if (MRTKOculusConfig.Instance.ActiveTeleportPointerMode == MRTKOculusConfig.TeleportPointerMode.Custom && MixedRealityToolkit.IsTeleportSystemEnabled) { if (!teleportPointers.TryGetValue(handedness, out CustomTeleportPointer pointer)) { pointer = GameObject.Instantiate(MRTKOculusConfig.Instance.CustomTeleportPrefab).GetComponent <CustomTeleportPointer>(); pointer.gameObject.SetActive(false); teleportPointers.Add(handedness, pointer); } pointer.Controller = handController; handController.TeleportPointer = pointer; } inputSystem?.RaiseSourceDetected(handController.InputSource, handController); trackedHands.Add(handedness, handController); return(handController); }
private OculusQuestController GetOrAddController(Handedness handedness) { if (trackedControllers.ContainsKey(handedness)) { return(trackedControllers[handedness]); } var pointers = RequestPointers(SupportedControllerType.ArticulatedHand, handedness); var inputSourceType = InputSourceType.Hand; IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; var inputSource = inputSystem?.RequestNewGenericInputSource($"Oculus Quest {handedness} Controller", pointers, inputSourceType); if (!inactiveControllerCache.TryGetValue(handedness, out var controller)) { controller = new OculusQuestController(TrackingState.Tracked, handedness, inputSource); controller.UpdateAvatarMaterial(MRTKOculusConfig.Instance.CustomHandMaterial); } inactiveHandCache.Remove(handedness); controller.ApplyHandMaterial(); for (int i = 0; i < controller.InputSource?.Pointers?.Length; i++) { controller.InputSource.Pointers[i].Controller = controller; } if (MixedRealityToolkit.IsTeleportSystemEnabled) { if (!teleportPointers.TryGetValue(handedness, out CustomTeleportPointer pointer)) { pointer = GameObject.Instantiate(MRTKOculusConfig.Instance.CustomTeleportPrefab).GetComponent <CustomTeleportPointer>(); teleportPointers.Add(handedness, pointer); } pointer.Controller = controller; controller.TeleportPointer = pointer; } inputSystem?.RaiseSourceDetected(controller.InputSource, controller); trackedControllers.Add(handedness, controller); return(controller); }
void MLControllerButtonUp(byte controllerId, MLInput.Controller.Button button) { //Implement bumper and home buttons up if (controllerId == this.mlController.Id) { IMixedRealityInputSystem inputSystem = CoreServices.InputSystem; switch (button) { case MLInput.Controller.Button.Bumper: Interactions[2].BoolData = false; inputSystem?.RaiseOnInputUp(InputSource, ControllerHandedness, Interactions[2].MixedRealityInputAction); break; case MLInput.Controller.Button.HomeTap: Interactions[3].BoolData = false; inputSystem?.RaiseOnInputUp(InputSource, ControllerHandedness, Interactions[3].MixedRealityInputAction); break; } } }
void MLControllerButtonDown(byte controllerId, MLInput.Controller.Button button) { // Implement bumper down; do no implement home button down (bc of the implementation of it) if (controllerId == this.mlController.Id) { IMixedRealityInputSystem inputSystem = CoreServices.InputSystem; switch (button) { case MLInput.Controller.Button.Bumper: Interactions[2].BoolData = true; inputSystem?.RaiseOnInputDown(InputSource, ControllerHandedness, Interactions[2].MixedRealityInputAction); break; case MLInput.Controller.Button.HomeTap: Interactions[3].BoolData = true; inputSystem?.RaiseOnInputDown(InputSource, ControllerHandedness, Interactions[3].MixedRealityInputAction); break; } } }
private LeapMotionHand GetOrAddHand(Hand hand) { var handId = hand.Id; var handedness = GetHandedness(hand); if (trackedHands.ContainsKey(handId)) { var existingHand = trackedHands[handId]; if (existingHand.ControllerHandedness == handedness) { return(existingHand); } else { RemoveHandDevice(handId); } } // Add new hand IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; var pointers = RequestPointers(SupportedControllerType.ArticulatedHand, handedness); var inputSourceType = InputSourceType.Hand; var inputSource = inputSystem?.RequestNewGenericInputSource($"Leap Motion Hand {handId}", pointers, inputSourceType); var controller = new LeapMotionHand(TrackingState.Tracked, handedness, inputSource); controller.SetupConfiguration(typeof(LeapMotionHand), inputSourceType); for (int i = 0; i < controller.InputSource?.Pointers?.Length; i++) { controller.InputSource.Pointers[i].Controller = controller; } inputSystem?.RaiseSourceDetected(inputSource, controller); trackedHands.Add(handId, controller); UpdateActiveControllers(); return(controller); }
public IEnumerator TestToggleProfilerCommand() { // Confirm that the diagnostics system is enabled. IMixedRealityDiagnosticsSystem diagnosticsSystem = null; MixedRealityServiceRegistry.TryGetService <IMixedRealityDiagnosticsSystem>(out diagnosticsSystem); Assert.IsNotNull(diagnosticsSystem, "The diagnostics system is not enabled in the scene."); yield return(null); // This test uses the input system to simulate speech commands. IMixedRealityInputSystem inputSystem = null; MixedRealityServiceRegistry.TryGetService <IMixedRealityInputSystem>(out inputSystem); Assert.IsNotNull(inputSystem, "The input system is not enabled in the scene."); yield return(null); // Verify that the VisualProfiler is enabled. Assert.IsTrue(diagnosticsSystem.ShowProfiler, "The VisualProfiler is not active."); yield return(null); int frameDelay = 10; // Toggle the profiler visualization off. var gazeInputSource = inputSystem.DetectedInputSources.Where(x => x.SourceName.Equals("Gaze")).First(); inputSystem.RaiseSpeechCommandRecognized( gazeInputSource, RecognitionConfidenceLevel.High, new TimeSpan(), DateTime.Now, new SpeechCommands("toggle profiler", KeyCode.Alpha9, MixedRealityInputAction.None)); // It may take a few frames before the event is handled and the system responds to the state change. for (int i = 0; i < frameDelay; i++) { yield return(null); } // Verify that the VisualProfiler is disabled. Assert.IsFalse(diagnosticsSystem.ShowProfiler, "The VisualProfiler is active (should be inactive)."); yield return(null); }
/// <inheritdoc /> public override void Update() { IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; if (!Application.isPlaying || inputSystem == null) { return; } if (!isTransitioning && IsListening && !Microphone.IsRecording(deviceName) && dictationRecognizer.Status == SpeechSystemStatus.Running) { // If the microphone stops as a result of timing out, make sure to manually stop the dictation recognizer. StopRecording(); } if (!hasFailed && dictationRecognizer.Status == SpeechSystemStatus.Failed) { hasFailed = true; inputSystem.RaiseDictationError(inputSource, "Dictation recognizer has failed!"); } }