Example #1
0
        private void ButtonUpdate()
        {
            bool activeTouchPad = controller.GetPress(FinchControllerElement.Touch) && controller.TouchAxes.SqrMagnitude() > epsilon;

            foreach (var b in Buttons)
            {
                b.UpdateState(controller.GetPress(b.Type) && (b.Type != FinchControllerElement.Touch || activeTouchPad));
            }
        }
Example #2
0
        private static void UpdateFinch()
        {
            if (finchProvider != null)
            {
                finchProvider.ReadState(State);
            }

            switch (FinchSettings.DeviceType)
            {
            case FinchControllerType.Dash:
            {
                for (int i = 0; i < (int)FinchChirality.Last; ++i)
                {
                    if (State.CalibrationButtonPressed[i])
                    {
                        Calibrate((FinchChirality)i);

                        if (FinchSettings.RecenterMode == FinchRecenterMode.Forward)
                        {
                            UnityEngine.XR.InputTracking.Recenter();
                        }
                    }
                }
                break;
            }

            case FinchControllerType.Shift:
            {
                if ((LeftController.GetPress(FinchControllerElement.ButtonZero) && RightController.GetPressDown(FinchControllerElement.ButtonZero)) ||
                    (RightController.GetPress(FinchControllerElement.ButtonZero) && LeftController.GetPressDown(FinchControllerElement.ButtonZero)))
                {
                    Calibrate(FinchChirality.Right);
                    Calibrate(FinchChirality.Left);

                    if (FinchSettings.RecenterMode == FinchRecenterMode.Forward)
                    {
                        UnityEngine.XR.InputTracking.Recenter();
                    }
                }
                break;
            }
            }

            if (tryToAssignControllersNextUpdate)
            {
                tryToAssignControllersNextUpdate = !AssignControllers();
            }
        }
        void Update()
        {
            FinchController controller = FinchVR.GetFinchController(Chirality);

            if (touchRenderer == null || controller == null)
            {
                return;
            }

            touchRenderer.material = TouchOpaque;

            if (controller.IsTouching())
            {
                if (!wasTouching)
                {
                    wasTouching             = true;
                    elapsedScaleTimeSeconds = 0.0f;
                }

                Vector3 scale = Vector3.Lerp(Vector3.zero,
                                             TouchpadPointDimensions,
                                             elapsedScaleTimeSeconds / TouchpadPointScaleDurationSeconds);

                transform.localScale = scale;

                float x = TouchpadRadius * controller.GetTouchAxes().x;
                float y = 0.01f;
                float z = TouchpadPointYOffset + TouchpadRadius * controller.GetTouchAxes().y;
                transform.localPosition = new Vector3(x, y, z);
            }
            else
            {
                if (wasTouching)
                {
                    wasTouching             = false;
                    elapsedScaleTimeSeconds = 0.0f;
                }

                Vector3 scale = Vector3.Lerp(TouchpadPointDimensions,
                                             Vector3.zero,
                                             elapsedScaleTimeSeconds / TouchpadPointScaleDurationSeconds);

                transform.localScale = scale;
            }

            if (controller.GetPress(FinchControllerElement.ButtonThumb))
            {
                Vector3 scale = TouchpadPointDimensions;
                scale.x = TouchpadRadius * 4;
                scale.z = TouchpadRadius * 4;

                transform.localScale = scale;

                float x = 0f;
                float y = 0.01f;
                float z = TouchpadPointYOffset;
                transform.localPosition = new Vector3(x, y, z);
            }

            elapsedScaleTimeSeconds += Time.deltaTime;
        }