Esempio n. 1
0
        private 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;

            var inputSource = Service?.RequestNewGenericInputSource($"Magic Leap {handedness} Hand", pointers, inputSourceType);

            var controller = new 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;
            }

            Service?.RaiseSourceDetected(controller.InputSource, controller);
            trackedHands.Add(handedness, controller);

            return(controller);
        }
Esempio n. 2
0
        private void RemoveHandDevice(MagicLeapHand hand)
        {
            if (hand == null)
            {
                return;
            }

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

            RecyclePointers(hand.InputSource);
        }