Exemple #1
0
    private void OnDisable()
    {
        tap_g.Tapped -= tappedHandler;

        touchPositionRaw.SetValue(Vector2.zero);
        touchPosition.SetValue(Vector2.zero);
    }
Exemple #2
0
        private void Update()
        {
            bool        isDown       = Input.GetMouseButton(0);
            EInputPhase currentPhase = (EInputPhase)Phase.GetValue();
            EInputPhase newPhase     = EInputPhase.None;

            if (isDown)
            {
                switch (currentPhase)
                {
                case EInputPhase.None:
                    newPhase = EInputPhase.Begin;
                    break;

                case EInputPhase.Begin:
                    newPhase = EInputPhase.Hold;
                    break;

                case EInputPhase.Hold:
                    newPhase = EInputPhase.Hold;
                    break;
                }

                Vector2 oldPosition = Position.GetValue();
                Vector2 newPosition = Input.mousePosition;
                newPosition.y = m_Camera.pixelHeight;

                if (oldPosition != newPosition)
                {
                    Position.SetValue(newPosition);
                }
            }
            else
            {
                switch (currentPhase)
                {
                case EInputPhase.Hold:
                    newPhase = EInputPhase.End;
                    break;

                case EInputPhase.End:
                    newPhase = EInputPhase.None;
                    break;
                }
            }

            if (currentPhase != newPhase)
            {
                Phase.SetValue((int)newPhase);
                Debug.Log($"Input phase: {newPhase}");
            }
        }
Exemple #3
0
    void GatherInput()
    {
        movementInput.SetValue(new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")).normalized);
        mouseInput.SetValue(new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y")));
        fire1Down.SetValue(Input.GetButton("Fire1"));
        fire1Pressed.SetValue(Input.GetButtonDown("Fire1"));

        jumpButtonDown.SetValue(Input.GetButtonDown("Jump"));

        if (Input.GetButtonDown("Fire2"))
        {
            rightMouseDownEvent.Raise();
        }

        if (Input.GetButtonDown("Jump"))
        {
            jumpButtonDownEvent.Raise();
        }
    }
Exemple #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>
        public void CheckControllerInput(VRInputsEvents clickEvents, VRInputsEvents touchEvents, VRInputsBoolean clickBools, VRInputsBoolean touchBools, SteamVR_Controller.Device controller, Vector2Variable thumbOrientation)
        {
            BoolVariable tempClick;
            BoolVariable tempTouch;

            #region TRIGGER
            tempClick = clickBools.Get("TriggerIsDown");
            tempTouch = touchBools.Get("TriggerIsTouching");

            // Check Click Events
            if (!tempClick.Value && controller.GetHairTriggerDown())
            {
                tempClick.SetValue(true);
                tempTouch.SetValue(false);
                _tempEvent = (GameEvent)clickEvents.Get("TriggerDown");
                _tempEvent.Raise();
            }
            else if (tempClick.Value && controller.GetHairTriggerUp())
            {
                tempClick.SetValue(false);
                _tempEvent = (GameEvent)clickEvents.Get("TriggerUp");
                _tempEvent.Raise();
            }
            // Check Touch Events if user is not clicking
            else if (!tempClick.Value && !tempTouch.Value && controller.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
            {
                tempTouch.SetValue(true);
                _tempEvent = (GameEvent)touchEvents.Get("TriggerStartTouching");
                _tempEvent.Raise();
            }
            else if (tempTouch.Value && controller.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
            {
                tempTouch.SetValue(false);
                _tempEvent = (GameEvent)touchEvents.Get("TriggerStopTouching");
                _tempEvent.Raise();
            }
            #endregion TRIGGER

            #region TOUCHPAD
            thumbOrientation.SetValue(controller.GetAxis());

            tempClick = clickBools.Get("ThumbIsDown");
            tempTouch = touchBools.Get("ThumbIsTouching");

            // Check Click Events
            if (!tempClick.Value && controller.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad))
            {
                tempClick.SetValue(true);
                tempTouch.SetValue(false);
                _tempEvent = (GameEvent)clickEvents.Get("ThumbDown");
                _tempEvent.Raise();
            }
            else if (tempClick.Value && controller.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad))
            {
                tempClick.SetValue(false);
                _tempEvent = (GameEvent)clickEvents.Get("ThumbUp");
                _tempEvent.Raise();
            }
            // Check Touch Events if user is not clicking
            else if (!tempClick.Value && !tempTouch.Value && controller.GetTouchDown(SteamVR_Controller.ButtonMask.Touchpad))
            {
                tempTouch.SetValue(true);
                _tempEvent = (GameEvent)touchEvents.Get("ThumbStartTouching");
                _tempEvent.Raise();
            }
            else if (tempTouch.Value && controller.GetTouchUp(SteamVR_Controller.ButtonMask.Touchpad))
            {
                tempTouch.SetValue(false);
                _tempEvent = (GameEvent)touchEvents.Get("ThumbStopTouching");
                _tempEvent.Raise();
            }
            #endregion TOUCHPAD

            #region GRIP
            tempClick = clickBools.Get("GripIsDown");

            // Check Click Events
            if (!tempClick.Value && controller.GetPressDown(SteamVR_Controller.ButtonMask.Grip))
            {
                tempClick.SetValue(true);
                _tempEvent = (GameEvent)clickEvents.Get("GripDown");
                _tempEvent.Raise();
            }
            else if (tempClick.Value && controller.GetPressUp(SteamVR_Controller.ButtonMask.Grip))
            {
                tempClick.SetValue(false);
                _tempEvent = (GameEvent)clickEvents.Get("GripUp");
                _tempEvent.Raise();
            }
            #endregion GRIP

            #region MENU
            tempClick = clickBools.Get("MenuIsDown");

            // Check Click Events
            if (!tempClick.Value && controller.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu))
            {
                tempClick.SetValue(true);
                _tempEvent = (GameEvent)clickEvents.Get("MenuDown");
                _tempEvent.Raise();
            }
            else if (tempClick.Value && controller.GetPressUp(SteamVR_Controller.ButtonMask.ApplicationMenu))
            {
                tempClick.SetValue(false);
                _tempEvent = (GameEvent)clickEvents.Get("MenuUp");
                _tempEvent.Raise();
            }
            #endregion MENU
        }