private void AddTouchController(Touch touch, Ray ray) { UnityTouchController controller; if (!ActiveTouches.TryGetValue(touch.fingerId, out controller)) { IMixedRealityInputSource inputSource = null; if (MixedRealityToolkit.InputSystem != null) { var pointers = RequestPointers(typeof(UnityTouchController), Handedness.Any, true); inputSource = MixedRealityToolkit.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); } MixedRealityToolkit.InputSystem?.RaiseSourceDetected(controller.InputSource, controller); controller.StartTouch(); UpdateTouchData(touch, ray); }
private void AddTouchController(Touch touch, Ray ray) { UnityTouchController controller; if (!ActiveTouches.TryGetValue(touch.fingerId, out controller)) { IMixedRealityInputSource inputSource = null; if (Service != null) { var pointers = RequestPointers(SupportedControllerType.TouchScreen, Handedness.Any); inputSource = Service.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; } } ActiveTouches.Add(touch.fingerId, controller); } Service?.RaiseSourceDetected(controller.InputSource, controller); controller.TouchData = touch; controller.StartTouch(); }