コード例 #1
0
ファイル: GuiNav.cs プロジェクト: tommojphillips/Mo_Controls
        private float hasInputFromAxisOrButton(XboxAxisEnum xboxAxis, XboxButtonEnum xboxButton)
        {
            // Written, 09.10.2020

            float valueF = 0.0f;

            if (xboxAxis != XboxAxisEnum.NULL) //  is an axis.
            {
                switch (xboxAxis)
                {
                case XboxAxisEnum.leftTrigger:
                    valueF = xboxController.getLeftTrigger();
                    break;

                case XboxAxisEnum.rightTrigger:
                    valueF = xboxController.getRightTrigger();
                    break;
                }
            }
            else if (xboxButton != XboxButtonEnum.NULL) // is a button.
            {
                valueF = xboxController.getButtonDown(xboxButton) ? 1f : 0.0f;
            }
            return(valueF);
        }
コード例 #2
0
        /// <summary>
        /// Returns true if the provided <see cref="XboxButtonEnum"/> has been pressed.
        /// </summary>
        /// <param name="inXboxButton">The button to check</param>
        /// <returns></returns>
        internal bool getButtonPressed(XboxButtonEnum inXboxButton)
        {
            // Written, 16.07.2018

            if ((inputMap[inXboxButton.toString()] as XboxBoolState).state == ButtonState.Pressed)
            {
                return(true);
            }
            return(false);
        }
コード例 #3
0
        /// <summary>
        /// Returns true if the provided <see cref="XboxButtonEnum"/> has been pressed and released.
        /// </summary>
        /// <param name="inXboxButton">The button to check.</param>
        internal bool getButtonUp(XboxButtonEnum inXboxButton)
        {
            // Written, 20.12.2018

            XboxBoolState button = inputMap[inXboxButton.toString()] as XboxBoolState;

            if (button.previousState == ButtonState.Pressed && button.state == ButtonState.Released)
            {
                return(true);
            }
            return(false);
        }
コード例 #4
0
        /// <summary>
        /// Sets and initializes hold input mono
        /// </summary>
        /// <param name="inName">The name to set the hold input</param>
        /// <param name="inKeyName">The Xbox Button to assign the hold</param>
        /// <param name="inHoldTime">How long the xbox button needs to be held down for before action execution.</param>
        /// <param name="inAction">The action to perform.</param>
        internal void setData(string inName, XboxButtonEnum inKeyName, float inHoldTime, Action inAction)
        {
            // Written, 19.12.2018

            holdTime = inHoldTime;
            keyName  = inKeyName;
            action   = inAction;
            hiName   = inName;
            id       = ("hld_inpt_" + hiName.ToLower().Replace(" ", "") + "_K" + inKeyName).ToLower().Trim();

            MoControlsMod.print("hld_inpt: " + hiName + " initiliazed as '" + id + "'.", Debugging.DebugTypeEnum.full);
        }
コード例 #5
0
ファイル: GuiNav.cs プロジェクト: tommojphillips/Mo_Controls
        /// <summary>
        /// Sets all xbox controls. NOTE: only set either 'A' (axis) OR 'B' (button) variants of each control type, eg, scrollUpA & scrollUpB. otherwise will
        /// only detect axis input variant.
        /// </summary>
        internal void setControls(XboxAxisEnum scrollUpA   = XboxAxisEnum.NULL, XboxButtonEnum scrollUpB   = XboxButtonEnum.NULL,
                                  XboxAxisEnum scrollDownA = XboxAxisEnum.NULL, XboxButtonEnum scrollDownB = XboxButtonEnum.NULL,
                                  XboxAxisEnum menuUpA     = XboxAxisEnum.NULL, XboxButtonEnum menuUpB     = XboxButtonEnum.NULL,
                                  XboxAxisEnum menuDownA   = XboxAxisEnum.NULL, XboxButtonEnum menuDownB   = XboxButtonEnum.NULL)
        {
            // Written, 09.10.2020

            // Scroll Down
            if (scrollDownA != XboxAxisEnum.NULL)
            {
                this.scrollDownA = scrollDownA;
                this.scrollDownB = XboxButtonEnum.NULL;
            }
            if (scrollDownB != XboxButtonEnum.NULL)
            {
                this.scrollDownB = scrollDownB;
                this.scrollDownA = XboxAxisEnum.NULL;
            }
            // Scroll Up
            if (scrollUpA != XboxAxisEnum.NULL)
            {
                this.scrollUpA = scrollUpA;
                this.scrollUpB = XboxButtonEnum.NULL;
            }
            if (scrollUpB != XboxButtonEnum.NULL)
            {
                this.scrollUpB = scrollUpB;
                this.scrollUpA = XboxAxisEnum.NULL;
            }
            // Menu Down
            if (menuDownA != XboxAxisEnum.NULL)
            {
                this.menuDownA = menuDownA;
                this.menuDownB = XboxButtonEnum.NULL;
            }
            if (menuDownB != XboxButtonEnum.NULL)
            {
                this.menuDownB = menuDownB;
                this.menuDownA = XboxAxisEnum.NULL;
            }
            // Menu Up
            if (menuUpA != XboxAxisEnum.NULL)
            {
                this.menuUpA = menuUpA;
                this.menuUpB = XboxButtonEnum.NULL;
            }
            if (menuUpB != XboxButtonEnum.NULL)
            {
                this.menuUpB = menuUpB;
                this.menuUpA = XboxAxisEnum.NULL;
            }
        }
コード例 #6
0
        // Written, 09.10.2018

        /// <summary>
        /// Returns the string representation of the provided <see cref="XboxButtonEnum"/>.
        /// </summary>
        /// <param name="inXboxButtonEnum">The xbox button to convert to string.</param>
        public static string toString(this XboxButtonEnum inXboxButtonEnum)
        {
            // Written, 17.07.2018

            string value = null;

            switch (inXboxButtonEnum)
            {
            case XboxButtonEnum.A:
                value = "A";
                break;

            case XboxButtonEnum.B:
                value = "B";
                break;

            case XboxButtonEnum.X:
                value = "X";
                break;

            case XboxButtonEnum.Y:
                value = "Y";
                break;

            case XboxButtonEnum.Back:
                value = "Back";
                break;

            case XboxButtonEnum.Start:
                value = "Start";
                break;

            case XboxButtonEnum.DPad_Up:
                value = "D-Pad Up";
                break;

            case XboxButtonEnum.DPad_Down:
                value = "D-Pad Down";
                break;

            case XboxButtonEnum.DPad_Left:
                value = "D-Pad Left";
                break;

            case XboxButtonEnum.DPad_Right:
                value = "D-Pad Right";
                break;

            case XboxButtonEnum.LS:
                value = "LS";
                break;

            case XboxButtonEnum.RS:
                value = "RS";
                break;

            case XboxButtonEnum.LB:
                value = "LB";
                break;

            case XboxButtonEnum.RB:
                value = "RB";
                break;

            case XboxButtonEnum.NULL:
                value = null;
                break;
            }
            return(value);
        }