Exemple #1
0
    /// <summary>
    /// Checks the button state of a given Oculus button.
    /// </summary>
    /// <param name="state">Whether to check if the button/action is just pressed, just released, or is being held down.</param>
    public bool CheckOculusButtonState(OVRInput.Button button, ControllerButtonState state)
    {
        if (!ovrUpdateCalledThisFrame)
        {
            OVRInput.Update();
            ovrUpdateCalledThisFrame = true;
        }

        bool result = false;

        switch (state)
        {
        case ControllerButtonState.Down:
            result = OVRInput.GetDown(button, GetOculusController());
            break;

        case ControllerButtonState.Held:
            result = OVRInput.Get(button, GetOculusController());
            break;

        case ControllerButtonState.Up:
            result = OVRInput.GetUp(button, GetOculusController());
            break;
        }
        return(result);
    }
Exemple #2
0
    /// <summary>
    /// Returns if the Grab button/action matched the provided state.
    /// </summary>
    /// <param name="state">Whether to check if the button/action is just pressed, just released, or is being held down.</param>
    public bool CheckGrabButton(ControllerButtonState state)
    {
#if ZED_SVR_2_0_INPUT
        return(CheckSteamVRBoolActionState(grabBinding, state));
#elif ZED_STEAM_VR
        return(CheckSteamVRButtonState_Legacy(grabBinding_Legacy, state));
#endif
#if ZED_OCULUS
        return(CheckOculusButtonState(grabButton, state));
#endif
        return(false);
    }
Exemple #3
0
    public bool CheckSteamVRButtonState_Legacy(EVRButtonId button, ControllerButtonState state)
    {
        switch (state)
        {
        case ControllerButtonState.Down:
            return(GetVRButtonDown_Legacy(button));

        case ControllerButtonState.Held:
        default:
            return(GetVRButtonHeld_Legacy(button));

        case ControllerButtonState.Up:
            return(GetVRButtonReleased_Legacy(button));
        }
    }
Exemple #4
0
    //#if ZED_STEAM_VR
#if ZED_SVR_2_0_INPUT
    /// <summary>
    /// Checks the button state of a given SteamVR boolean action.
    /// </summary>
    /// <param name="state">Whether to check if the button/action is just pressed, just released, or is being held down.</param>
    protected bool CheckSteamVRBoolActionState(SteamVR_Action_Boolean action, ControllerButtonState buttonstate)
    {
        switch (buttonstate)
        {
        case ControllerButtonState.Down:
            return(action.GetLastStateDown(GetSteamVRInputSource()));

        case ControllerButtonState.Held:
            return(action.GetLastState(GetSteamVRInputSource()));

        case ControllerButtonState.Up:
            return(action.GetLastStateUp(GetSteamVRInputSource()));

        default:
            return(false);
        }
    }
Exemple #5
0
 private void AddButtonMouseBinding(Buttons buttons, System.Windows.Forms.MouseButtons mouseButtons, InputMode bindingMode = InputMode.All, CommandTarget commandTarget = CommandTarget.None, ControllerButtonState cbState = ControllerButtonState.WhileDown)
 {
     bindings.AddRange(ControllerInputBinding.createMouseButtonBindings(buttons, mouseButtons, bindingMode, commandTarget, cbState));
 }
Exemple #6
0
    /// <summary>
    /// Update this buttons state as a function of time
    /// </summary>
    /// <param name="a_fDeltaTime"></param>
    public virtual void UpdateButton(float a_fDeltaTime)
    {
        // update previous state
        m_ePreviousState = m_eButtonState;

        // Get the current down state of the button
        //bool bState = Input.GetButton(m_InputName);


        bool bState;

        if (useMouse)
        {
            bState = Input.GetMouseButton(mouseButton);
        }
        else
        {
            bState = Input.GetKey(keyboardInputButton) || XCI.GetButton(xboxButton, fps_inputManager.xboxController);
        }



        // Update the current state based on the button press
        switch (m_eButtonState)
        {
        case ControllerButtonState.None:
        {
            if (bState)
            {
                m_fHeldTime    = a_fDeltaTime;
                m_eButtonState = ControllerButtonState.Down;
            }
            break;
        }

        case ControllerButtonState.Down:
        {
            if (bState)
            {
                m_fHeldTime   += a_fDeltaTime;
                m_eButtonState = ControllerButtonState.Held;
            }
            else
            {
                m_eButtonState = ControllerButtonState.Released;
            }
            break;
        }

        case ControllerButtonState.Held:
        {
            if (bState)
            {
                m_fHeldTime += a_fDeltaTime;
                if (m_fHeldTime >= HELD_TIME)
                {
                    m_eButtonState = ControllerButtonState.Long_Hold;
                }
            }
            else
            {
                m_eButtonState = ControllerButtonState.Released;
            }
            break;
        }

        case ControllerButtonState.Long_Hold:
        {
            if (bState)
            {
                m_fHeldTime += a_fDeltaTime;
            }
            else
            {
                m_eButtonState = ControllerButtonState.Released;
            }
            break;
        }

        case ControllerButtonState.Released:
        {
            if (bState)
            {
                m_fHeldTime    = a_fDeltaTime;
                m_eButtonState = ControllerButtonState.Down;
            }
            else
            {
                m_eButtonState = ControllerButtonState.None;
                m_fHeldTime    = 0.0f;
            }
            break;
        }

        default:
        {
            m_eButtonState = ControllerButtonState.None;
            m_fHeldTime    = 0.0f;
            break;
        }
        }
    }
        /// <summary>
        /// createButtonKeyBindings creates two new binding and command sets, which directly maps a controller button to a mouse button.
        /// Given mouse button is signalled as down when the button is down, and up when the button is up.
        /// </summary>
        /// <param name="buttons">Controller button to bind</param>
        /// <param name="mouseButtons">Mouse button to bind</param>
        /// <param name="applicableMode">Which input mode in which this binding is active - all modes by default.</param>
        /// <param name="target">Indicates if the mouse button should be pressed with the mouse cursor at a particular location (cursorPosition, reticulePosition, or none)</param>
        /// <returns></returns>
        internal static ControllerInputBinding[] createMouseButtonBindings(Buttons button, System.Windows.Forms.MouseButtons mouseButton, InputMode applicableMode = InputMode.All, CommandTarget target = CommandTarget.None, ControllerButtonState cbState = ControllerButtonState.WhileDown)
        {
            ControllerInputBinding downResult = new ControllerInputBinding();

            downResult.button      = button;
            downResult.buttonState = cbState;
            MouseButtonCommand newCommand = new MouseButtonCommand();

            newCommand.mouseButton    = mouseButton;
            newCommand.commandState   = ButtonState.Down;
            newCommand.applicableMode = applicableMode;
            newCommand.target         = target;
            downResult.commands.Add(newCommand);


            ControllerInputBinding upResult = new ControllerInputBinding();

            upResult                  = new ControllerInputBinding();
            upResult.button           = button;
            upResult.buttonState      = ControllerButtonState.OnUp;
            newCommand                = new MouseButtonCommand();
            newCommand.mouseButton    = mouseButton;
            newCommand.commandState   = ButtonState.Up;
            newCommand.applicableMode = applicableMode;
            newCommand.target         = target;
            upResult.commands.Add(newCommand);

            return(new ControllerInputBinding[2] {
                downResult, upResult
            });
        }