private Input.MagicLeapHand GetOrAddHand(MLHandTracking.Hand mlHand, Handedness handedness) { 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($"Magic Leap {handedness} Hand", pointers, inputSourceType); var controller = new Input.MagicLeapHand(TrackingState.Tracked, handedness, inputSource); controller.Initalize(new ManagedHand(mlHand)); 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); }
private SimpleWebXRHand GetOrAddHand(Handedness handedness) { if (trackedHands.ContainsKey(handedness)) { return(trackedHands[handedness]); } var pointers = RequestPointers(SupportedControllerType.ArticulatedHand, handedness); var inputSourceType = InputSourceType.Hand; IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; var inputSource = inputSystem?.RequestNewGenericInputSource($"WebXR {handedness} Hand", pointers, inputSourceType); var handController = new SimpleWebXRHand(TrackingState.Tracked, handedness, inputSource); for (int i = 0; i < handController.InputSource?.Pointers?.Length; i++) { handController.InputSource.Pointers[i].Controller = handController; } inputSystem?.RaiseSourceDetected(handController.InputSource, handController); trackedHands.Add(handedness, handController); return(handController); }
private OculusHand 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); OculusHand handDevice = new OculusHand(TrackingState.Tracked, handedness, inputSource); handDevice.InitializeHand(ovrHand, SettingsProfile); for (int i = 0; i < handDevice.InputSource?.Pointers?.Length; i++) { handDevice.InputSource.Pointers[i].Controller = handDevice; } inputSystem?.RaiseSourceDetected(handDevice.InputSource, handDevice); trackedHands.Add(handedness, handDevice); return(handDevice); }
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); var controller = new OculusQuestController(TrackingState.Tracked, handedness, inputSource); // Code is obsolete later on, but older MRTK versions require it. #pragma warning disable 618 controller.SetupConfiguration(typeof(OculusQuestController)); #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); trackedControllers.Add(handedness, controller); return(controller); }
private SimpleWebXRController 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($"WebXR {handedness} Controller", pointers, inputSourceType); if (!inactiveControllerCache.TryGetValue(handedness, out var controller)) { controller = new SimpleWebXRController(TrackingState.Tracked, handedness, inputSource); } for (int i = 0; i < controller.InputSource?.Pointers?.Length; i++) { controller.InputSource.Pointers[i].Controller = controller; } inputSystem?.RaiseSourceDetected(controller.InputSource, controller); trackedControllers.Add(handedness, controller); return(controller); }
private OculusQuestHand GetOrAddHand(Handedness handedness) { 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); var controller = new OculusQuestHand(TrackingState.Tracked, handedness, inputSource); controller.SetupConfiguration(typeof(OculusQuestHand)); 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); }
private void RefreshDevices() { Profiler.BeginSample("[MRTK] UnityJoystickManager.RefreshDevices"); IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; var joystickNames = UInput.GetJoystickNames(); if (joystickNames.Length <= 0) { Profiler.EndSample(); // RefreshDevices - no devices return; } if (lastDeviceList != null && joystickNames.Length == lastDeviceList.Length) { for (int i = 0; i < lastDeviceList.Length; i++) { if (joystickNames[i].Equals(lastDeviceList[i])) { continue; } if (ActiveControllers.ContainsKey(lastDeviceList[i])) { var controller = GetOrAddController(lastDeviceList[i]); if (controller != null) { inputSystem?.RaiseSourceLost(controller.InputSource, controller); } RemoveController(lastDeviceList[i]); } } } for (var i = 0; i < joystickNames.Length; i++) { if (string.IsNullOrEmpty(joystickNames[i])) { continue; } if (!ActiveControllers.ContainsKey(joystickNames[i])) { var controller = GetOrAddController(joystickNames[i]); if (controller != null) { inputSystem?.RaiseSourceDetected(controller.InputSource, controller); } } } lastDeviceList = joystickNames; Profiler.EndSample(); // RefreshDevices }
private void RefreshDevices() { IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; var joystickNames = UInput.GetJoystickNames(); if (joystickNames.Length <= 0) { return; } if (lastDeviceList != null && joystickNames.Length == lastDeviceList.Length) { for (int i = 0; i < lastDeviceList.Length; i++) { if (joystickNames[i].Equals(lastDeviceList[i])) { continue; } if (ActiveControllers.ContainsKey(lastDeviceList[i])) { var controller = GetOrAddController(lastDeviceList[i]); if (controller != null) { inputSystem?.RaiseSourceLost(controller.InputSource, controller); } ActiveControllers.Remove(lastDeviceList[i]); } else { Debug.Log("Controller does not contains kye"); } } } for (var i = 0; i < joystickNames.Length; i++) { if (string.IsNullOrEmpty(joystickNames[i])) { continue; } if (!ActiveControllers.ContainsKey(joystickNames[i])) { var controller = GetOrAddController(joystickNames[i]); if (controller != null) { inputSystem?.RaiseSourceDetected(controller.InputSource, controller); } } } lastDeviceList = joystickNames; }
/// <inheritdoc /> public override void Enable() { if (!UInput.mousePresent) { Disable(); return; } #if UNITY_EDITOR if (UnityEditor.EditorWindow.focusedWindow != null) { UnityEditor.EditorWindow.focusedWindow.ShowNotification(new GUIContent("Press \"ESC\" to regain mouse control")); } #endif Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; IMixedRealityInputSource mouseInputSource = null; MixedRealityRaycaster.DebugEnabled = true; const Handedness handedness = Handedness.Any; System.Type controllerType = typeof(MouseController); // Make sure that the handedness declared in the controller attribute matches what we expect { var controllerAttribute = MixedRealityControllerAttribute.Find(controllerType); if (controllerAttribute != null) { Handedness[] handednesses = controllerAttribute.SupportedHandedness; Debug.Assert(handednesses.Length == 1 && handednesses[0] == Handedness.Any, "Unexpected mouse handedness declared in MixedRealityControllerAttribute"); } } IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; if (inputSystem != null) { var pointers = RequestPointers(SupportedControllerType.Mouse, handedness); mouseInputSource = inputSystem.RequestNewGenericInputSource("Mouse Input", pointers); } Controller = new MouseController(TrackingState.NotApplicable, handedness, mouseInputSource); if (mouseInputSource != null) { for (int i = 0; i < mouseInputSource.Pointers.Length; i++) { mouseInputSource.Pointers[i].Controller = Controller; } } Controller.SetupConfiguration(typeof(MouseController)); inputSystem?.RaiseSourceDetected(Controller.InputSource, Controller); }
void MLControllerConnected(byte controllerId) { #if PLATFORM_LUMIN MLInput.Controller mlController = MLInput.GetController(controllerId); if (mlController.Type == MLInput.Controller.ControlType.Control) { if (!ConnectedControllers.ContainsKey(controllerId)) { Handedness handedness = mlController.Hand == MLInput.Hand.Right ? Handedness.Right : Handedness.Left; switch (CurrentControllerSettings) { case HandSettings.None: return; case HandSettings.Left: if (handedness != Handedness.Left) { return; } break; case HandSettings.Right: if (handedness != Handedness.Right) { return; } break; case HandSettings.Both: break; } var pointers = RequestPointers(SupportedControllerType.GenericUnity, handedness); var inputSourceType = InputSourceType.Controller; IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; var inputSource = inputSystem?.RequestNewGenericInputSource($"Magic Leap {handedness} Controller", pointers, inputSourceType); MagicLeapMRTKController controller = new MagicLeapMRTKController(mlController, TrackingState.Tracked, handedness, inputSource); for (int i = 0; i < controller.InputSource?.Pointers?.Length; i++) { controller.InputSource.Pointers[i].Controller = controller; } inputSystem?.RaiseSourceDetected(controller.InputSource, controller); ConnectedControllers[controllerId] = new MLControllerContainer() { controllerId = controllerId, mrtkController = controller }; trackedControls.Add(controller); } } #endif }
/// <inheritdoc /> public override void Enable() { if (!UInput.mousePresent) { Disable(); return; } if (Controller != null) { // device manager has already been set up return; } IMixedRealityInputSource mouseInputSource = null; MixedRealityRaycaster.DebugEnabled = true; const Handedness handedness = Handedness.Any; System.Type controllerType = typeof(MouseController); // Make sure that the handedness declared in the controller attribute matches what we expect { var controllerAttribute = MixedRealityControllerAttribute.Find(controllerType); if (controllerAttribute != null) { Handedness[] handednesses = controllerAttribute.SupportedHandedness; Debug.Assert(handednesses.Length == 1 && handednesses[0] == Handedness.Any, "Unexpected mouse handedness declared in MixedRealityControllerAttribute"); } } IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; if (inputSystem != null) { var pointers = RequestPointers(SupportedControllerType.Mouse, handedness); mouseInputSource = inputSystem.RequestNewGenericInputSource("Mouse Input", pointers); } Controller = new MouseController(TrackingState.NotApplicable, handedness, mouseInputSource); if (mouseInputSource != null) { for (int i = 0; i < mouseInputSource.Pointers.Length; i++) { mouseInputSource.Pointers[i].Controller = Controller; } } Controller.SetupConfiguration(typeof(MouseController)); inputSystem?.RaiseSourceDetected(Controller.InputSource, Controller); }
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> /// 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 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 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); }
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); }
/// <summary> /// SDK Interaction Source Detected Event handler /// </summary> /// <param name="args">SDK source detected event arguments</param> private void InteractionManager_InteractionSourceDetected(InteractionSourceDetectedEventArgs args) { // Avoids a Unity Editor bug detecting a controller from the previous run during the first frame #if UNITY_EDITOR if (Time.frameCount <= 1) { return; } #endif 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); }
void PlugSimulatedMotionController(Handedness controllerHandedness) { MixedRealityRaycaster.DebugEnabled = true; System.Type controllerType = typeof(SimulatedMotionController); // Make sure that the handedness declared in the controller attribute matches what we expect { var controllerAttribute = MixedRealityControllerAttribute.Find(controllerType); if (controllerAttribute != null) { Handedness[] handednesses = controllerAttribute.SupportedHandedness; //Debug.Assert(handednesses.Length == 3 && handednesses[0] == Handedness.Any, "Unexpected mouse handedness declared in MixedRealityControllerAttribute"); } } IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; var pointers = RequestPointers(SupportedControllerType.GenericOpenVR, controllerHandedness); IMixedRealityInputSource inputSource = inputSystem.RequestNewGenericInputSource("Mouse Input", pointers, InputSourceType.Controller); SimulatedMotionController simulatedMotionController = new SimulatedMotionController(TrackingState.Tracked, controllerHandedness, inputSource); simulatedMotionController.SetupConfiguration(controllerType); if (inputSource != null) { for (int i = 0; i < inputSource.Pointers.Length; i++) { inputSource.Pointers[i].Controller = simulatedMotionController; } } SimulatedMotionControllerDictionary.Add(controllerHandedness, simulatedMotionController); inputSystem?.RaiseSourceDetected(simulatedMotionController.InputSource, simulatedMotionController); }
private void AddTouchController(Touch touch, Ray ray) { UnityTouchController controller; IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; if (!ActiveTouches.TryGetValue(touch.fingerId, out controller)) { IMixedRealityInputSource inputSource = null; if (inputSystem != null) { var pointers = RequestPointers(SupportedControllerType.TouchScreen, Handedness.Any); inputSource = inputSystem.RequestNewGenericInputSource($"Touch {touch.fingerId}", pointers); } controller = new UnityTouchController(TrackingState.NotApplicable, Handedness.Any, inputSource); if (inputSource != null) { for (int i = 0; i < inputSource.Pointers.Length; i++) { inputSource.Pointers[i].Controller = controller; var touchPointer = (IMixedRealityTouchPointer)inputSource.Pointers[i]; touchPointer.TouchRay = ray; touchPointer.FingerId = touch.fingerId; } } controller.SetupConfiguration(typeof(UnityTouchController)); ActiveTouches.Add(touch.fingerId, controller); } inputSystem?.RaiseSourceDetected(controller.InputSource, controller); controller.StartTouch(); UpdateTouchData(touch, ray); }
/// <inheritdoc/> public override void Enable() { if (!Application.isPlaying) { return; } if (InputSystemProfile == null) { return; } IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem; RegisterGestureEvents(); RegisterNavigationEvents(); if ((inputSystem != null) && InputSystemProfile.GesturesProfile != null) { var gestureProfile = InputSystemProfile.GesturesProfile; GestureSettings = gestureProfile.ManipulationGestures; NavigationSettings = gestureProfile.NavigationGestures; RailsNavigationSettings = gestureProfile.RailsNavigationGestures; UseRailsNavigation = gestureProfile.UseRailsNavigation; for (int i = 0; i < gestureProfile.Gestures.Length; i++) { var gesture = gestureProfile.Gestures[i]; switch (gesture.GestureType) { case GestureInputType.Hold: holdAction = gesture.Action; break; case GestureInputType.Manipulation: manipulationAction = gesture.Action; break; case GestureInputType.Navigation: navigationAction = gesture.Action; break; } } } InteractionManager.InteractionSourceDetected += InteractionManager_InteractionSourceDetected; InteractionManager.InteractionSourceLost += InteractionManager_InteractionSourceLost; InteractionManager.InteractionSourcePressed += InteractionManager_InteractionSourcePressed; InteractionManager.InteractionSourceReleased += InteractionManager_InteractionSourceReleased; numInteractionManagerStates = InteractionManager.GetCurrentReading(interactionmanagerStates); // Avoids a Unity Editor bug detecting a controller from the previous run during the first frame #if !UNITY_EDITOR // NOTE: We update the source state data, in case an app wants to query it on source detected. for (var i = 0; i < numInteractionManagerStates; i++) { var controller = GetController(interactionmanagerStates[i].source); if (controller != null) { controller.UpdateController(interactionmanagerStates[i]); inputSystem?.RaiseSourceDetected(controller.InputSource, controller); } } #endif if ((inputSystem != null) && InputSystemProfile.GesturesProfile != null && InputSystemProfile.GesturesProfile.WindowsGestureAutoStart == AutoStartBehavior.AutoStart) { GestureRecognizerEnabled = true; } }