コード例 #1
0
        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, null));
            controller.SetupConfiguration(typeof(Input.MagicLeapHand));

            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);
        }
コード例 #2
0
        private void RemoveHandDevice(Input.MagicLeapHand hand)
        {
            if (hand == null)
            {
                return;
            }

            hand.CleanupHand();
            CoreServices.InputSystem?.RaiseSourceLost(hand.InputSource, hand);
            trackedHands.Remove(hand.ControllerHandedness);

            RecyclePointers(hand.InputSource);
        }