Beispiel #1
0
 void Update()
 {
     if (RightController.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu))
     {
         if (!rightMenuActive)
         {
             rightMenuActive = true;
         }
         else
         {
             rightMenuActive = false;
         }
         if ((rightMenuActive && !userMenuActive && !locomotionMenuActive && !XRoomConsole) || (leftMenuActive && !userMenuActive && !locomotionMenuActive && !XRoomConsole))
         {
             userMenu.SetActive(true);
             userMenuActive = true;
         }
         else if (!rightMenuActive && !leftMenuActive)
         {
             userMenu.SetActive(false);
             locomotionMenu.SetActive(false);
             levelMenu.SetActive(false);
             userMenuActive = false;
         }
     }
     if (LeftController.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu))
     {
         if (!leftMenuActive)
         {
             leftMenuActive = true;
         }
         else
         {
             leftMenuActive = false;
         }
         if ((rightMenuActive && !userMenuActive && !locomotionMenuActive && !XRoomConsole) || (leftMenuActive && !userMenuActive && !locomotionMenuActive && !XRoomConsole))
         {
             userMenu.SetActive(true);
             userMenuActive = true;
         }
         else if (!rightMenuActive && !leftMenuActive)
         {
             userMenu.SetActive(false);
             locomotionMenu.SetActive(false);
             levelMenu.SetActive(false);
             userMenuActive = false;
         }
     }
 }
    protected override void Update()
    {
        base.Update();
        if (ButtonEventType == FinchButtonEventType.Right || ButtonEventType == FinchButtonEventType.Any)
        {
            detectPress(FinchChirality.Right);
        }

        if (ButtonEventType == FinchButtonEventType.Left || ButtonEventType == FinchButtonEventType.Any)
        {
            detectPress(FinchChirality.Left);
        }


        bool wasInvoked = false;

        if (ButtonEventType == FinchButtonEventType.BothAtOneTime)
        {
            if ((RightController.GetPress(button) && LeftController.GetPressDown(button)) ||
                (LeftController.GetPress(button) && RightController.GetPressDown(button)))
            {
                if (FinchDownEvent != null)
                {
                    FinchDownEvent.Invoke();
                    wasInvoked = true;
                }
                else if (FinchUpEvent != null)
                {
                    FinchUpEvent.Invoke();
                    wasInvoked = true;
                }

                if (wasInvoked && Vibration)
                {
                    RightController.HapticPulse(VibrationTimeMs);
                    LeftController.HapticPulse(VibrationTimeMs);
                }
            }
        }
    }
    protected override void Update()
    {
        ButtonEventType = FinchButtonEventType.Any;
        base.Update();

        bool startedTouching = !bothTouching &&
                               ((LeftController.GetPress(Button) && RightController.GetPressDown(Button)) ||
                                (RightController.GetPress(Button) && LeftController.GetPressDown(Button)));
        bool eventCanBeInvoked = !alreadyInvoked && bothTouching;
        bool stoppedTouching   = bothTouching && (LeftController.GetPressUp(Button) || RightController.GetPressUp(Button));

        if (startedTouching)
        {
            bothTouching = true;
            stopWatch    = new System.Diagnostics.Stopwatch();
            stopWatch.Start();
        }
        else if (eventCanBeInvoked)
        {
            if (stopWatch.ElapsedMilliseconds >= longTapTimeMs)
            {
                stopWatch.Stop();
                alreadyInvoked = true;
                LongTapBothTouchpads.Invoke();

                if (Vibration)
                {
                    RightController.HapticPulse(VibrationTimeMs);
                    LeftController.HapticPulse(VibrationTimeMs);
                }
            }
        }
        else if (stoppedTouching)
        {
            bothTouching   = false;
            alreadyInvoked = false;
            stopWatch.Stop();
        }
    }
Beispiel #4
0
        //EMPTY
        #region PUBLIC_METHODS
        #endregion PUBLIC_METHODS

        #region PRIVATE_METHODS
        /// <summary>
        /// Handle the Left Controller input and put them in the Events
        /// </summary>
        void CheckLeftControllerInput()
        {
            BoolVariable temp;

            #region TRIGGER
            temp = LeftVariablesDictionnary.Get("TriggerIsDown");

            if (!temp.Value && LeftController.GetHairTriggerDown())
            {
                temp.SetValue(true);
                _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftTriggerDown");
                _leftEvent.Raise();
            }
            else if (temp.Value && LeftController.GetHairTriggerUp())
            {
                temp.SetValue(false);
                _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftTriggerUp");
                _leftEvent.Raise();
            }
            #endregion TRIGGER

            #region TOUCHPAD
            temp = LeftVariablesDictionnary.Get("ThumbIsDown");

            LeftThumbOrientation.SetValue(LeftController.GetAxis());

            if (LeftController.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad))
            {
                temp.SetValue(true);
                _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftThumbDown");
                _leftEvent.Raise();
            }
            else if (temp.Value && LeftController.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad))
            {
                temp.SetValue(false);
                _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftThumbUp");
                _leftEvent.Raise();
            }

            if (LeftController.GetTouchDown(SteamVR_Controller.ButtonMask.Touchpad))
            {
                _leftEventBool = (GameEventBool)LeftEventsDictionnary.Get("LeftThumbTouching");
                _leftEventBool.Raise(true);
            }
            else if (LeftController.GetTouchUp(SteamVR_Controller.ButtonMask.Touchpad))
            {
                _leftEventBool = (GameEventBool)LeftEventsDictionnary.Get("LeftThumbTouching");
                _leftEventBool.Raise(false);
            }
            #endregion TOUCHPAD

            #region GRIP
            temp = LeftVariablesDictionnary.Get("GripIsDown");

            if (!temp.Value && LeftController.GetPressDown(SteamVR_Controller.ButtonMask.Grip))
            {
                temp.SetValue(true);
                _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftGripDown");
                _leftEvent.Raise();
            }
            else if (temp.Value && LeftController.GetPressUp(SteamVR_Controller.ButtonMask.Grip))
            {
                temp.SetValue(false);
                _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftGripUp");
                _leftEvent.Raise();
            }
            #endregion GRIP

            #region MENU
            temp = LeftVariablesDictionnary.Get("MenuIsDown");

            if (!temp.Value && LeftController.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu))
            {
                temp.SetValue(true);
                _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftMenuDown");
                _leftEvent.Raise();
            }
            else if (temp.Value && LeftController.GetPressUp(SteamVR_Controller.ButtonMask.ApplicationMenu))
            {
                temp.SetValue(false);
                _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftMenuUp");
                _leftEvent.Raise();
            }
            #endregion MENU
        }