public static bool GetButtonDown(int controllerIndex, ControllerButtonCode keyCode)
        {
            if (!m_IsInitialized)
                Initialize();

            return m_XboxControllers[controllerIndex].GetButtonDown(keyCode);
        }
Exemple #2
0
        /// <summary>
        /// Constructs a new <see cref="ControllerButton"/> using the given code.
        /// </summary>
        /// <param name="controller">The controller's device ID.</param>
        /// <param name="code">The code for the button represented by this <see cref="ControllerButton"/>.</param>
        public ControllerButton(int controller, ControllerButtonCode code)
        {
            Assert.Index(controller, Core.Input.ControllersMax);

            this.controller = controller;
            this.code       = code;
        }
 public ButtonInputCommand(int controllerIndex, KeyCode keyCode, ControllerButtonCode buttonCode, ButtonState buttonState)
 {
     this.ControllerIndex = controllerIndex;
     this.KeyCode         = keyCode;
     this.ButtonCode      = buttonCode;
     this.ButtonState     = buttonState;
 }
 public static bool GetButtonUp(int controllerIndex, ControllerButtonCode keyCode)
 {
     if (!m_IsInitialized)
     {
         Initialize();
     }
     return(m_XboxControllers[controllerIndex].GetButtonUp(keyCode));
 }
    public bool GetButton(ControllerButtonCode keyCode)
    {
        switch (keyCode)
        {
        case ControllerButtonCode.A:
            return(m_CurrentState.Buttons.A == ButtonState.Pressed);

        case ControllerButtonCode.B:
            return(m_CurrentState.Buttons.B == ButtonState.Pressed);

        case ControllerButtonCode.X:
            return(m_CurrentState.Buttons.X == ButtonState.Pressed);

        case ControllerButtonCode.Y:
            return(m_CurrentState.Buttons.Y == ButtonState.Pressed);

        case ControllerButtonCode.LeftShoulder:
            return(m_CurrentState.Buttons.LeftShoulder == ButtonState.Pressed);

        case ControllerButtonCode.RightShoulder:
            return(m_CurrentState.Buttons.RightShoulder == ButtonState.Pressed);

        case ControllerButtonCode.LeftStick:
            return(m_CurrentState.Buttons.LeftStick == ButtonState.Pressed);

        case ControllerButtonCode.RightStick:
            return(m_CurrentState.Buttons.RightStick == ButtonState.Pressed);

        //Central buttons
        case ControllerButtonCode.Start:
            return(m_CurrentState.Buttons.Start == ButtonState.Pressed);

        case ControllerButtonCode.Back:
            return(m_CurrentState.Buttons.Back == ButtonState.Pressed);

        case ControllerButtonCode.Guide:
            return(m_CurrentState.Buttons.Guide == ButtonState.Pressed);

        //D pad
        case ControllerButtonCode.Up:
            return(m_CurrentState.DPad.Up == ButtonState.Pressed);

        case ControllerButtonCode.Down:
            return(m_CurrentState.DPad.Down == ButtonState.Pressed);

        case ControllerButtonCode.Left:
            return(m_CurrentState.DPad.Left == ButtonState.Pressed);

        case ControllerButtonCode.Right:
            return(m_CurrentState.DPad.Right == ButtonState.Pressed);

        default:
            return(false);
        }
    }
        public bool IsUsed(ControllerButtonCode buttonCode)
        {
            foreach (KeyValuePair <string, ButtonInputCommand> valuePair in m_ButtonInputCommands)
            {
                if (valuePair.Value.ButtonCode == buttonCode)
                {
                    return(true);
                }
            }

            return(false);
        }
        public void BindAxis(string name, int controllerIndex, ControllerButtonCode positiveButtonCode, ControllerButtonCode negativeButtonCode)
        {
            if (m_AxisInputCommands.ContainsKey(name))
            {
                AxisInputCommand inputCommand = m_AxisInputCommands[name];
                inputCommand.ControllerIndex    = controllerIndex;
                inputCommand.PositiveButtonCode = positiveButtonCode;
                inputCommand.NegativeButtonCode = negativeButtonCode;
                return;
            }

            m_AxisInputCommands.Add(name, new AxisInputCommand(controllerIndex, KeyCode.None, KeyCode.None, ControllerAxisCode.None, positiveButtonCode, negativeButtonCode));
        }
        public void BindButton(string name, int controllerIndex, ControllerButtonCode buttonCode, ButtonState buttonState)
        {
            if (m_ButtonInputCommands.ContainsKey(name))
            {
                ButtonInputCommand inputCommand = m_ButtonInputCommands[name];
                inputCommand.ControllerIndex = controllerIndex;
                inputCommand.ButtonCode      = buttonCode;
                inputCommand.ButtonState     = buttonState;
                return;
            }

            m_ButtonInputCommands.Add(name, new ButtonInputCommand(controllerIndex, KeyCode.None, buttonCode, buttonState));
        }
    public static bool GetButton(int controllerIndex, ControllerButtonCode keyCode)
    {
        if (!m_IsInitialized)
        {
            Initialize();
        }

        if (!CheckControllerIndex(controllerIndex))
        {
            return(false);
        }

        return(m_XboxControllers[controllerIndex].GetButton(keyCode));
    }
        public bool GetButtonUp(ControllerButtonCode keyCode)
        {
            switch (keyCode)
            {
                case ControllerButtonCode.A:
                    return (m_CurrentState.Buttons.A != XInputDotNetPure.ButtonState.Pressed &&
                            m_PreviousState.Buttons.A == XInputDotNetPure.ButtonState.Pressed);

                case ControllerButtonCode.B:
                    return (m_CurrentState.Buttons.B != XInputDotNetPure.ButtonState.Pressed &&
                            m_PreviousState.Buttons.B == XInputDotNetPure.ButtonState.Pressed);

                case ControllerButtonCode.X:
                    return (m_CurrentState.Buttons.X != XInputDotNetPure.ButtonState.Pressed &&
                            m_PreviousState.Buttons.X == XInputDotNetPure.ButtonState.Pressed);

                case ControllerButtonCode.Y:
                    return (m_CurrentState.Buttons.Y != XInputDotNetPure.ButtonState.Pressed &&
                            m_PreviousState.Buttons.Y == XInputDotNetPure.ButtonState.Pressed);

                case ControllerButtonCode.LeftShoulder:
                    return (m_CurrentState.Buttons.LeftShoulder != XInputDotNetPure.ButtonState.Pressed &&
                            m_PreviousState.Buttons.LeftShoulder == XInputDotNetPure.ButtonState.Pressed);

                case ControllerButtonCode.RightShoulder:
                    return (m_CurrentState.Buttons.RightShoulder != XInputDotNetPure.ButtonState.Pressed &&
                            m_PreviousState.Buttons.RightShoulder == XInputDotNetPure.ButtonState.Pressed);

                case ControllerButtonCode.LeftStick:
                    return (m_CurrentState.Buttons.LeftStick != XInputDotNetPure.ButtonState.Pressed &&
                            m_PreviousState.Buttons.LeftStick == XInputDotNetPure.ButtonState.Pressed);

                case ControllerButtonCode.RightStick:
                    return (m_CurrentState.Buttons.RightStick != XInputDotNetPure.ButtonState.Pressed &&
                            m_PreviousState.Buttons.RightStick == XInputDotNetPure.ButtonState.Pressed);

                //Central buttons
                case ControllerButtonCode.Start:
                    return (m_CurrentState.Buttons.Start != XInputDotNetPure.ButtonState.Pressed &&
                            m_PreviousState.Buttons.Start == XInputDotNetPure.ButtonState.Pressed);

                case ControllerButtonCode.Back:
                    return (m_CurrentState.Buttons.Back != XInputDotNetPure.ButtonState.Pressed &&
                            m_PreviousState.Buttons.Back == XInputDotNetPure.ButtonState.Pressed);

                case ControllerButtonCode.Guide:
                    return (m_CurrentState.Buttons.Guide != XInputDotNetPure.ButtonState.Pressed &&
                            m_PreviousState.Buttons.Guide == XInputDotNetPure.ButtonState.Pressed);

                //D pad
                case ControllerButtonCode.Up:
                    return (m_CurrentState.DPad.Up != XInputDotNetPure.ButtonState.Pressed &&
                            m_PreviousState.DPad.Up == XInputDotNetPure.ButtonState.Pressed);

                case ControllerButtonCode.Down:
                    return (m_CurrentState.DPad.Down != XInputDotNetPure.ButtonState.Pressed &&
                            m_PreviousState.DPad.Down == XInputDotNetPure.ButtonState.Pressed);

                case ControllerButtonCode.Left:
                    return (m_CurrentState.DPad.Left != XInputDotNetPure.ButtonState.Pressed &&
                            m_PreviousState.DPad.Left == XInputDotNetPure.ButtonState.Pressed);

                case ControllerButtonCode.Right:
                    return (m_CurrentState.DPad.Right != XInputDotNetPure.ButtonState.Pressed &&
                            m_PreviousState.DPad.Right == XInputDotNetPure.ButtonState.Pressed);

                default:
                    return false;
            }
        }
    public bool GetButton(ControllerButtonCode keyCode)
    {
        switch (keyCode)
        {
            case ControllerButtonCode.A:
                return (m_CurrentState.Buttons.A == ButtonState.Pressed);

            case ControllerButtonCode.B:
                return (m_CurrentState.Buttons.B == ButtonState.Pressed);

            case ControllerButtonCode.X:
                return (m_CurrentState.Buttons.X == ButtonState.Pressed);

            case ControllerButtonCode.Y:
                return (m_CurrentState.Buttons.Y == ButtonState.Pressed);

            case ControllerButtonCode.LeftShoulder:
                return (m_CurrentState.Buttons.LeftShoulder == ButtonState.Pressed);

            case ControllerButtonCode.RightShoulder:
                return (m_CurrentState.Buttons.RightShoulder == ButtonState.Pressed);

            case ControllerButtonCode.LeftStick:
                return (m_CurrentState.Buttons.LeftStick == ButtonState.Pressed);

            case ControllerButtonCode.RightStick:
                return (m_CurrentState.Buttons.RightStick == ButtonState.Pressed);

            //Central buttons
            case ControllerButtonCode.Start:
                return (m_CurrentState.Buttons.Start == ButtonState.Pressed);

            case ControllerButtonCode.Back:
                return (m_CurrentState.Buttons.Back == ButtonState.Pressed);

            case ControllerButtonCode.Guide:
                return (m_CurrentState.Buttons.Guide == ButtonState.Pressed);

            //D pad
            case ControllerButtonCode.Up:
                return (m_CurrentState.DPad.Up == ButtonState.Pressed);

            case ControllerButtonCode.Down:
                return (m_CurrentState.DPad.Down == ButtonState.Pressed);

            case ControllerButtonCode.Left:
                return (m_CurrentState.DPad.Left == ButtonState.Pressed);

            case ControllerButtonCode.Right:
                return (m_CurrentState.DPad.Right == ButtonState.Pressed);

            default:
                return false;
        }
    }
 public AxisInputCommand(int controllerIndex, KeyCode positiveKeyCode, KeyCode negativeKeyCode, ControllerAxisCode axisCode, ControllerButtonCode positiveButtonCode, ControllerButtonCode negativeButtonCode)
 {
     this.ControllerIndex    = controllerIndex;
     this.PositiveKeyCode    = positiveKeyCode;
     this.NegativeKeyCode    = negativeKeyCode;
     this.AxisCode           = axisCode;
     this.PositiveButtonCode = positiveButtonCode;
     this.NegativeButtonCode = negativeButtonCode;
 }
Exemple #13
0
        /// <summary>
        /// Checks if the given controller button is currently down.
        /// </summary>
        /// <param name="id">The device ID of the controller to check.</param>
        /// <param name="code">The <see cref="ControllerButtonCode"/> representing the button to check.</param>
        /// <returns>True if the controller button is currently down; false if not.</returns>
        public bool GetControllerButtonDown(int id, ControllerButtonCode code)
        {
            Assert.Index(id, Core.Input.ControllersMax);

            return(coreState.Controllers[id].Buttons[(int)(code)]);
        }
        public bool GetButtonUp(ControllerButtonCode keyCode)
        {
            switch (keyCode)
            {
            case ControllerButtonCode.A:
                return(m_CurrentState.Buttons.A != XInputDotNetPure.ButtonState.Pressed &&
                       m_PreviousState.Buttons.A == XInputDotNetPure.ButtonState.Pressed);

            case ControllerButtonCode.B:
                return(m_CurrentState.Buttons.B != XInputDotNetPure.ButtonState.Pressed &&
                       m_PreviousState.Buttons.B == XInputDotNetPure.ButtonState.Pressed);

            case ControllerButtonCode.X:
                return(m_CurrentState.Buttons.X != XInputDotNetPure.ButtonState.Pressed &&
                       m_PreviousState.Buttons.X == XInputDotNetPure.ButtonState.Pressed);

            case ControllerButtonCode.Y:
                return(m_CurrentState.Buttons.Y != XInputDotNetPure.ButtonState.Pressed &&
                       m_PreviousState.Buttons.Y == XInputDotNetPure.ButtonState.Pressed);

            case ControllerButtonCode.LeftShoulder:
                return(m_CurrentState.Buttons.LeftShoulder != XInputDotNetPure.ButtonState.Pressed &&
                       m_PreviousState.Buttons.LeftShoulder == XInputDotNetPure.ButtonState.Pressed);

            case ControllerButtonCode.RightShoulder:
                return(m_CurrentState.Buttons.RightShoulder != XInputDotNetPure.ButtonState.Pressed &&
                       m_PreviousState.Buttons.RightShoulder == XInputDotNetPure.ButtonState.Pressed);

            case ControllerButtonCode.LeftStick:
                return(m_CurrentState.Buttons.LeftStick != XInputDotNetPure.ButtonState.Pressed &&
                       m_PreviousState.Buttons.LeftStick == XInputDotNetPure.ButtonState.Pressed);

            case ControllerButtonCode.RightStick:
                return(m_CurrentState.Buttons.RightStick != XInputDotNetPure.ButtonState.Pressed &&
                       m_PreviousState.Buttons.RightStick == XInputDotNetPure.ButtonState.Pressed);

            //Central buttons
            case ControllerButtonCode.Start:
                return(m_CurrentState.Buttons.Start != XInputDotNetPure.ButtonState.Pressed &&
                       m_PreviousState.Buttons.Start == XInputDotNetPure.ButtonState.Pressed);

            case ControllerButtonCode.Back:
                return(m_CurrentState.Buttons.Back != XInputDotNetPure.ButtonState.Pressed &&
                       m_PreviousState.Buttons.Back == XInputDotNetPure.ButtonState.Pressed);

            case ControllerButtonCode.Guide:
                return(m_CurrentState.Buttons.Guide != XInputDotNetPure.ButtonState.Pressed &&
                       m_PreviousState.Buttons.Guide == XInputDotNetPure.ButtonState.Pressed);

            //D pad
            case ControllerButtonCode.Up:
                return(m_CurrentState.DPad.Up != XInputDotNetPure.ButtonState.Pressed &&
                       m_PreviousState.DPad.Up == XInputDotNetPure.ButtonState.Pressed);

            case ControllerButtonCode.Down:
                return(m_CurrentState.DPad.Down != XInputDotNetPure.ButtonState.Pressed &&
                       m_PreviousState.DPad.Down == XInputDotNetPure.ButtonState.Pressed);

            case ControllerButtonCode.Left:
                return(m_CurrentState.DPad.Left != XInputDotNetPure.ButtonState.Pressed &&
                       m_PreviousState.DPad.Left == XInputDotNetPure.ButtonState.Pressed);

            case ControllerButtonCode.Right:
                return(m_CurrentState.DPad.Right != XInputDotNetPure.ButtonState.Pressed &&
                       m_PreviousState.DPad.Right == XInputDotNetPure.ButtonState.Pressed);

            default:
                return(false);
            }
        }