Ejemplo n.º 1
0
        public virtual void ReadState(PlayerState outState)
        {
            if (!string.IsNullOrEmpty(errorDetails))
            {
                outState.ErrorDetails = errorDetails;
                Debug.LogError(errorDetails);
                return;
            }

            FinchUpdateError err = FinchUpdateError.NotInitialized;

            if (FinchSettings.HeadUpdateType == FinchHeadUpdateType.RotationUpdate)
            {
                err = FinchCore.Update(FinchVR.MainCamera != null ? FinchVR.MainCamera.rotation.ToFinch() : Camera.main.transform.rotation.ToFinch());
            }
            else if (FinchSettings.HeadUpdateType == FinchHeadUpdateType.RotationAndPositionUpdate)
            {
                err = FinchCore.Update(FinchVR.MainCamera.rotation.ToFinch(), FinchVR.MainCamera.position.ToFinch());
            }
            else
            {
                err = FinchCore.Update();
            }

            if (err != FinchUpdateError.None)
            {
                outState.ErrorDetails = "Error update Dash controller data: " + err;
                Debug.LogError(outState.ErrorDetails);
            }

            for (int i = 0; i < (int)FinchChirality.Last; ++i)
            {
                outState.ElementsBeginEvents[i] = FinchCore.GetEvents((FinchChirality)i, FinchEventType.Begin);
                outState.ElementsState[i]       = FinchCore.GetEvents((FinchChirality)i, FinchEventType.Process);
                outState.ElementsEndEvents[i]   = FinchCore.GetEvents((FinchChirality)i, FinchEventType.End);
                outState.IsTouching[i]          = FinchCore.GetEvent((FinchChirality)i, FinchControllerElement.Touchpad, FinchEventType.Process);
                outState.TouchAxes[i]           = FinchCore.GetTouchpadAxes((FinchChirality)i);
                outState.IndexTrigger[i]        = FinchCore.GetIndexTrigger((FinchChirality)i);
            }

            for (int i = 0; i < (int)FinchNodeType.Last; ++i)
            {
                outState.Gyro[i]  = FinchCore.GetBoneLocalAngularVelocity(PlayerState.Bones[(FinchNodeType)i]);
                outState.Accel[i] = FinchCore.GetBoneLocalAcceleration(PlayerState.Bones[(FinchNodeType)i]);
            }

            outState.NodesState = FinchCore.NodesState;

            if (FinchCore.ControllerType == FinchControllerType.Hand)
            {
                UpdateLongPressDetection(FinchControllerElement.Touchpad, true, outState);
                UpdateCalibrationDelay(outState);
            }
            else
            {
                UpdateLongPressDetection(FinchControllerElement.ButtonZero, false, outState);
            }
        }
Ejemplo n.º 2
0
        private void ResetCalibration()
        {
            bool wasLeftReverted  = FinchCore.Interop.FinchIsUpperArmReverted(FinchCore.Interop.FinchChirality.Left) == 1;
            bool wasRightReverted = FinchCore.Interop.FinchIsUpperArmReverted(FinchCore.Interop.FinchChirality.Right) == 1;

            FinchCore.ResetCalibration(FinchChirality.Both);

            if (wasLeftReverted)
            {
                FinchCore.Interop.FinchRevertUpperArm(FinchCore.Interop.FinchChirality.Left);
            }

            if (wasRightReverted)
            {
                FinchCore.Interop.FinchRevertUpperArm(FinchCore.Interop.FinchChirality.Right);
            }

            FinchCore.Update();
            NodeAngleChecker.Update();
        }
Ejemplo n.º 3
0
 private void LateUpdate()
 {
     FinchCore.Update();
 }