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 void RemoveControllerDevice(SimpleWebXRController controller) { if (controller == null) { return; } CoreServices.InputSystem?.RaiseSourceLost(controller.InputSource, controller); trackedControllers.Remove(controller.ControllerHandedness); RecyclePointers(controller.InputSource); }