// Returns true or false depending on whether the read value exceeds the demanded deadzone.
        // Acts as a mirror of Unity.Input.GetButton() for the BetterKnuckleGestures library.
        public bool IsFingerDown(BKI_Hand hand, BKI_Finger finger)
        {
            BKI_HandValues handVals = null;

            switch (hand)
            {
            case BKI_Hand.right:
                handVals = rightHandValues;
                break;

            case BKI_Hand.left:
                handVals = leftHandValues;
                break;
            }
            switch (finger)
            {
            case BKI_Finger.thumb: return(handVals.GetFingerValue(finger) >= DEFAULT_PRESSED_DEADZONE);

            case BKI_Finger.index: return(handVals.GetFingerValue(finger) >= DEFAULT_PRESSED_DEADZONE);

            case BKI_Finger.middle: return(handVals.GetFingerValue(finger) >= DEFAULT_PRESSED_DEADZONE);

            case BKI_Finger.ring: return(handVals.GetFingerValue(finger) >= DEFAULT_PRESSED_DEADZONE);

            case BKI_Finger.pinky: return(handVals.GetFingerValue(finger) >= DEFAULT_PRESSED_DEADZONE);

            default: return(false);
            }
        }
        // Returns the rotational value read directly from the rotations before being applied to the mesh.
        public float GetFingerValueRaw(BKI_Hand hand, BKI_Finger finger)
        {
            BKI_HandValues handVals = null;

            switch (hand)
            {
            case BKI_Hand.right:
                handVals = rightHandValues;
                break;

            case BKI_Hand.left:
                handVals = leftHandValues;
                break;
            }
            switch (finger)
            {
            case BKI_Finger.thumb: return(handVals.GetFingerValueRaw(finger));

            case BKI_Finger.index: return(handVals.GetFingerValueRaw(finger));

            case BKI_Finger.middle: return(handVals.GetFingerValueRaw(finger));

            case BKI_Finger.ring: return(handVals.GetFingerValueRaw(finger));

            case BKI_Finger.pinky: return(handVals.GetFingerValueRaw(finger));

            default: return(0);
            }
        }
        // Compares the right hand gesture list if there is any valid gesture and sets the current active gesture to the valid gesture.
        private void CheckRightHandGestures()
        {
            if (combiActive)
            {
                return;
            }
            BKI_HandValues vals = BKI_FingerCurler.BKI_Curler_Instance.rightHandValues;

            foreach (BKI_FunctionalGesture gesture in rightHandGestures)
            {
                if (gesture == null || gesture == activeRhGesture)
                {
                    break;
                }

                if (IsGestureValid(BKI_UIType.right, gesture.gestureId))
                {
                    if (activeRhGesture == null || activeRhGesture != gesture)
                    {
                        EnterRightHandGesture(gesture);
                    }
                    break;
                }
                else if (activeRhGesture != gesture)
                {
                    ExitRhGesture();
                }
            }
        }
        private void Start()
        {
            // Mandatory ValveVR setup.
            RightHandSkeleton.SetRangeOfMotion(EVRSkeletalMotionRange.WithoutController);
            LeftHandSkeleton.SetRangeOfMotion(EVRSkeletalMotionRange.WithoutController);

            // Sets up storage classes for both hands.
            leftHandValues  = new BKI_HandValues(LeftHandSkeleton, lhMagicNumbers);
            rightHandValues = new BKI_HandValues(RightHandSkeleton, rhMagicNumbers);
        }
        // Returns current value.
        public bool IsHandGripping(BKI_Hand hand)
        {
            BKI_HandValues vals = (hand == BKI_Hand.left) ? leftHandValues : rightHandValues;
            BKI_SteamVR_Behaviour_Skeleton skel = (hand == BKI_Hand.left) ? leftHandSkeleton : rightHandSkeleton;

            bool canDoLoop = skel.IsFingerFrozen(BKI_Finger.thumb) && (skel.IsFingerFrozen(BKI_Finger.index) || skel.IsFingerFrozen(BKI_Finger.middle) || skel.IsFingerFrozen(BKI_Finger.ring) || skel.IsFingerFrozen(BKI_Finger.pinky));

            if (canDoLoop)
            {
                for (int i = 1; i < 5; i++)
                {
                    if (!(skel.IsFingerFrozen((BKI_Finger)i) && !(vals.GetFingerValue((BKI_Finger)i) < 0.1f)))
                    {
                        continue;
                    }
                    if (
                        (colliderManager.GetRegisteredPickupable(hand, BKI_Finger.thumb) != null &&
                         (colliderManager.GetRegisteredPickupable(hand, (BKI_Finger)i)) != null) &&
                        colliderManager.GetRegisteredPickupable(hand, BKI_Finger.thumb).GetPickupable() == colliderManager.GetRegisteredPickupable(hand, (BKI_Finger)i).GetPickupable())
                    {
                        if (hand == BKI_Hand.right)
                        {
                            rhGrippedObject = colliderManager.GetRegisteredPickupable(hand, BKI_Finger.thumb);
                        }
                        else
                        {
                            lhGrippedObject = colliderManager.GetRegisteredPickupable(hand, BKI_Finger.thumb);
                        }
                        return(true);
                    }
                }
            }
            else
            {
                if (hand == BKI_Hand.right)
                {
                    rhGrippedObject = null;
                }
                else
                {
                    lhGrippedObject = null;
                }
                return(false);
            }
            return(false);
        }