Exemple #1
0
        /// <summary>
        /// Returns time of pressing.
        /// </summary>
        /// <param name="chirality">Controller chirality</param>
        /// <param name="element">Controller element</param>
        /// <returns>Controller element pressing time.</returns>
        public static float GetPressTime(FinchChirality chirality, FinchControllerElement element)
        {
            if (chirality > FinchChirality.Left)
            {
                throw new ArgumentException();
            }

            return(FinchInput.GetPressTime((FinchNodeType)chirality, element));
        }
Exemple #2
0
        void Update()
        {
            FinchChirality chirality = GetChirality();

            foreach (TutorialObject i in Tutorials)
            {
                i.Tutorial.SetActive(chirality == i.Chirality || i.Chirality == FinchChirality.Any && (chirality == FinchChirality.Left || chirality == FinchChirality.Right));
            }
        }
        private void CheckChirality(bool vibrate)
        {
            FinchChirality left  = FinchCore.GetCapacitySensor(FinchNodeType.LeftHand);
            FinchChirality right = FinchCore.GetCapacitySensor(FinchNodeType.RightHand);

            if (left == FinchChirality.Unknown && FinchController.Left.IsConnected && right == FinchChirality.Unknown && FinchController.Right.IsConnected)
            {
                Sprite.sprite = NoneHoldBoth;
                return;
            }

            if (left == FinchChirality.Unknown && FinchController.Left.IsConnected || right == FinchChirality.Unknown && FinchController.Right.IsConnected)
            {
                Sprite.sprite = NoneHoldOne;
                return;
            }

            if (left == FinchChirality.Both && FinchController.Left.IsConnected && right == FinchChirality.Both && FinchController.Right.IsConnected)
            {
                Sprite.sprite = BothHoldBoth;
                return;
            }

            if (left == FinchChirality.Both && FinchController.Left.IsConnected || right == FinchChirality.Both && FinchController.Right.IsConnected)
            {
                Sprite.sprite = BothHoldOne;
                return;
            }

            if (left == FinchChirality.Left && FinchController.Left.IsConnected && right == FinchChirality.Left && FinchController.Right.IsConnected)
            {
                Sprite.sprite = BothLeftHold;
                return;
            }

            if (left == FinchChirality.Right && FinchController.Left.IsConnected && right == FinchChirality.Right && FinchController.Right.IsConnected)
            {
                Sprite.sprite = BothRightHold;
                return;
            }

            if (FinchCore.NodesState.GetControllersCount() == 0)
            {
                Sprite.sprite = NoneHoldBoth;
                return;
            }

            if (vibrate)
            {
                FinchController.Left.HapticPulse(100);
                FinchController.Right.HapticPulse(100);
            }

            FinchCore.BindsControllers();
            PlayableSet.RememberNodes();
            NextStep();
        }
        protected static void InitializeWatches()
        {
            calibrationLongPressStopWatch  = new Stopwatch[(int)FinchChirality.Last];
            handsCalibrationDelayStopWatch = new Stopwatch();

            for (FinchChirality i = 0; i < FinchChirality.Last; ++i)
            {
                calibrationLongPressStopWatch[(int)i] = new Stopwatch();
            }
        }
Exemple #5
0
    void Update()
    {
        FinchController controller = FinchController.Left.IsConnected ? FinchController.Left : FinchController.Right;
        FinchChirality  chirality  = FinchCore.GetCapacitySensor(controller.Node);

        if (chirality == FinchChirality.Left || chirality == FinchChirality.Right)
        {
            LeftHand.SetActive(chirality == FinchChirality.Left);
            RightHand.SetActive(chirality == FinchChirality.Right);
        }
    }
Exemple #6
0
        /// <summary>
        /// Returns the controller according to it's chirality.
        /// </summary>
        /// <param name="chirality">Right or left</param>
        /// <returns>Finch Controller of specified chirality.</returns>
        public static FinchController GetController(FinchChirality chirality)
        {
            switch (chirality)
            {
            case FinchChirality.Left:
                return(Left);

            case FinchChirality.Right:
                return(Right);

            default:
                return(null);
            }
        }
        private Quaternion GetFPose(FinchChirality chirality)
        {
            switch (chirality)
            {
            case FinchChirality.Left:
                return(fPoseLeft);

            case FinchChirality.Right:
                return(fPoseRight);

            default:
                return(Quaternion.identity);
            }
        }
    private bool anyWasPressedUp(FinchChirality chirality, FinchController controller)
    {
        for (int i = 0; i <= (int)FinchControllerElement.ButtonGrip; ++i)
        {
            if (controller.GetPressUp((FinchControllerElement)i))
            {
                return(true);
            }
        }

        if (controller.GetPressUp(FinchControllerElement.ButtonThumb))
        {
            return(true);
        }

        return(false);
    }
Exemple #9
0
 /// <summary>
 /// Calibrates specified hand. FinchSettings.RecenterMode setting
 /// </summary>
 /// <param name="chirality">Right or left</param>
 public static void Calibrate(FinchChirality chirality)
 {
     if (finchProvider != null)
     {
         if (chirality == FinchChirality.Right)
         {
             HapticPulse(FinchNodeType.RightHand, 50);
             wasCalibratedNextUpdateRight = true;
         }
         else if (chirality == FinchChirality.Left)
         {
             HapticPulse(FinchNodeType.LeftHand, 50);
             wasCalibratedNextUpdateLeft = true;
         }
         finchProvider.Calibrate(chirality, FinchSettings.RecenterMode);
     }
 }
        protected override void Update()
        {
            FinchChirality handedness     = FinchSettings.PreferredHandedness;
            bool           rightConnected = FinchVR.RightController.IsHandNodeConnected();
            bool           leftConnected  = FinchVR.LeftController.IsHandNodeConnected();

            if (HideDisconnectedController)
            {
                UpdateControllerObjectActive(Controller, ((handedness == FinchChirality.Right) && rightConnected) || ((handedness == FinchChirality.Left) && leftConnected));
            }
            else
            {
                UpdateControllerObjectActive(Controller, true);
            }


            base.Update();
            UpdateHandTransform(Controller, FinchVR.MainController);
        }
        /// <summary>
        /// Creates new instance of the FinchController with specified chirality.
        /// </summary>
        /// <param name="chirality">Right or left</param>
        public FinchController(FinchChirality chirality)
        {
            Chirality = chirality;
            switch (chirality)
            {
            case FinchChirality.Left:
                Bone     = FinchBone.LeftHandCenter;
                NodeType = FinchNodeType.LeftHand;
                break;

            case FinchChirality.Right:
                Bone     = FinchBone.RightHandCenter;
                NodeType = FinchNodeType.RightHand;
                break;

            default:
                Bone     = FinchBone.Unknown;
                NodeType = FinchNodeType.Unknown;
                break;
            }
        }
    private void detectPress(FinchChirality chirality)
    {
        FinchController controller = chirality == FinchChirality.Right ? RightController : LeftController;
        FinchNodeType   nodeType   = chirality == FinchChirality.Right ? FinchNodeType.RightHand : FinchNodeType.LeftHand;
        bool            wasInvoked = false;

        if (FinchDownEvent != null && controller.GetPressDown(button))
        {
            FinchDownEvent.Invoke();
            wasInvoked = true;
        }

        if (FinchUpEvent != null && RightController.GetPressUp(button))
        {
            FinchUpEvent.Invoke();
            wasInvoked = true;
        }

        if (Vibration && wasInvoked)
        {
            FinchVR.HapticPulse(nodeType, VibrationTimeMs);
        }
    }
Exemple #13
0
        /// <summary>
        /// Returns element pressed state.
        /// </summary>
        /// <param name="chirality">Controller chirality</param>
        /// <param name="element">Controller element</param>
        /// <returns>Is the controller element pressed</returns>
        public static bool GetPress(FinchChirality chirality, FinchControllerElement element)
        {
            bool left  = FinchInput.GetPress(FinchNodeType.LeftHand, element);
            bool right = FinchInput.GetPress(FinchNodeType.RightHand, element);

            switch (chirality)
            {
            case FinchChirality.Right:
                return(right);

            case FinchChirality.Left:
                return(left);

            case FinchChirality.Any:
                return(left || right);

            case FinchChirality.Both:
                return(left && right);

            default:
                return(false);
            }
        }
Exemple #14
0
        private static bool AssignControllers(bool isOnAwake = false)
        {
            FinchChirality        handedness       = FinchSettings.PreferredHandedness;
            FinchControllersCount controllersCount = FinchSettings.ControllersCount;
            bool leftConnected  = LeftController.IsHandNodeConnected();
            bool rightConnected = RightController.IsHandNodeConnected();

            if (handedness >= FinchChirality.Last)
            {
                FinchSettings.PreferredHandedness = handedness = FinchChirality.Right;
                Debug.Log("Setting \"Preferred Handedness\" was not set correctly, setting to default value \"Right\"");
            }

            if ((finchProvider != null) && !isOnAwake && (controllersCount == FinchControllersCount.One) && (leftConnected ^ rightConnected))
            {
                if ((handedness == FinchChirality.Left) && !leftConnected)
                {
                    finchProvider.SwapNodes(FinchNodeType.RightHand, FinchNodeType.LeftHand);
                }
                else if ((handedness == FinchChirality.Right) && !rightConnected)
                {
                    finchProvider.SwapNodes(FinchNodeType.RightHand, FinchNodeType.LeftHand);
                }
            }

            if (handedness == FinchChirality.Left)
            {
                MainController     = LeftController;
                OptionalController = RightController;
            }
            else
            {
                MainController     = RightController;
                OptionalController = LeftController;
            }
            return(leftConnected || rightConnected);
        }
        protected static void UpdateLongPressDetection(FinchControllerElement element, bool handsDevice, PlayerState outState)
        {
            for (FinchChirality i = 0; i < FinchChirality.Last; ++i)
            {
                if (handsDevice)
                {
                    calibrationButtonState[(int)i] = false;
                }
                else
                {
                    outState.CalibrationButtonPressed[(int)i] = false;
                }

                if (FinchCore.GetEvent(i, element, FinchEventType.Begin))
                {
                    calibrationLongPressStopWatch[(int)i].Start();
                }

                if (FinchCore.GetEvent(i, element, FinchEventType.End))
                {
                    calibrationLongPressStopWatch[(int)i].Reset();
                }

                if (calibrationLongPressStopWatch[(int)i].ElapsedMilliseconds >= LongPressTimeMs)
                {
                    if (handsDevice)
                    {
                        calibrationButtonState[(int)i] = true;
                    }
                    else
                    {
                        outState.CalibrationButtonPressed[(int)i] = true;
                        calibrationLongPressStopWatch[(int)i].Reset();
                    }
                }
            }
        }
Exemple #16
0
 public static extern void FinchResetCalibration(FinchChirality chirality);
Exemple #17
0
 public static extern float FinchGetIndexTrigger(FinchChirality chirality);
Exemple #18
0
 public static extern ushort FinchGetEvents(FinchChirality chirality, FinchEventType type);
Exemple #19
0
 public static extern FinchVector2 FinchGetTouchpadAxes(FinchChirality chirality);
Exemple #20
0
 /// <summary>
 ///     Calculates axis calibration matrices by current pose.
 /// </summary>
 /// <param name="chirality"></param>
 /// <param name="mode"></param>
 public static void OnePoseAxisCalibration(FinchChirality chirality, FinchRecenterMode mode)
 {
     Interop.FinchOnePoseAxisCalibration(chirality, mode);
 }
Exemple #21
0
 public static extern void FinchOnePoseAxisCalibration(FinchChirality chirality, FinchRecenterMode mode);
Exemple #22
0
 /// <summary>
 ///     Resets calibrate the selected chirality.
 /// </summary>
 /// <param name="chirality"></param>
 public static void ResetCalibration(FinchChirality chirality)
 {
     Interop.FinchResetCalibration(chirality);
 }
Exemple #23
0
 /// <summary>
 ///     Returns the value of the index trigger.
 /// </summary>
 /// <param name="chirality"></param>
 /// <returns></returns>
 public static float GetIndexTrigger(FinchChirality chirality)
 {
     return(Interop.FinchGetIndexTrigger(chirality));
 }
Exemple #24
0
 /// <summary>
 ///     Returns the events flag of controller's element.
 /// </summary>
 /// <param name="chirality"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public static ushort GetEvents(FinchChirality chirality, FinchEventType type)
 {
     return(Interop.FinchGetEvents(chirality, type));
 }
Exemple #25
0
 /// <summary>
 ///     Returns coordinates of the touchpad.
 /// </summary>
 /// <param name="chirality"></param>
 /// <returns></returns>
 public static Vector2 GetTouchpadAxes(FinchChirality chirality)
 {
     return(Interop.FinchGetTouchpadAxes(chirality).ToUnity());
 }
Exemple #26
0
 public static extern void FinchRecenter(FinchChirality chirality, FinchRecenterMode mode);
Exemple #27
0
 public static extern void FinchAxisCalibration(FinchChirality chirality, FinchAxisCalibrationStep step);
Exemple #28
0
 /// <summary>
 ///     Sets forward direction of user by selected direction of hand.
 /// </summary>
 /// <param name="chirality"></param>
 /// <param name="mode"></param>
 public static void Recenter(FinchChirality chirality, FinchRecenterMode mode)
 {
     Interop.FinchRecenter(chirality, mode);
 }
Exemple #29
0
 /// <summary>
 ///     Returns the selected event of controller's element.
 /// </summary>
 /// <param name="chirality"></param>
 /// <param name="element"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public static bool GetEvent(FinchChirality chirality, FinchControllerElement element, FinchEventType type)
 {
     return((Interop.FinchGetEvents(chirality, type) & (0x1 << (int)element)) != 0);
 }
Exemple #30
0
 /// <summary>
 ///     Full axis calibration.
 /// </summary>
 /// <param name="chirality"></param>
 /// <param name="step"></param>
 public static void AxisCalibration(FinchChirality chirality, FinchAxisCalibrationStep step)
 {
     Interop.FinchAxisCalibration(chirality, step);
 }