示例#1
0
        // dpad up functions
        public void DPadButton(DPadDirection dir, bool state)
        {
            // if up is pressed
            if (state)
            {
                switch (dir)
                {
                case DPadDirection.Left:
                {
                    if (slider.Value - .1 > Min)
                    {
                        slider.Value -= .1;
                    }
                    else
                    {
                        slider.Value = Min;
                    }
                }
                break;

                case DPadDirection.Right:
                {
                    if (slider.Value + .1 < Max)
                    {
                        slider.Value += .1;
                    }
                    else
                    {
                        slider.Value = Max;
                    }
                }
                break;
                }
            }
        }
示例#2
0
        // dpad up functions
        public void DPadButton(DPadDirection dir, bool state)
        {
            // if up is pressed
            if (state)
            {
                switch (dir)
                {
                case DPadDirection.Up:
                case DPadDirection.Down:
                {
                    // call the function
                    rockIncrement((dir == DPadDirection.Up ? 1 : -1));
                }
                break;

                case DPadDirection.Left:
                case DPadDirection.Right:
                {
                    rockRing += (dir == DPadDirection.Right ? 1 : -1);

                    rockRing = rockRing % 6;
                    if (rockRing < 0)
                    {
                        rockRing = 5;
                    }

                    ringSwitch();
                }
                break;
                }
            }
        }
示例#3
0
        public static bool GetKeyUp(DPadDirection dPadDirection)
        {
            if (dPadDirection == DPadDirection.Left && lastFrame_left != left && lastFrame_left)
            {
                lastFrame_left = false;
                return(true);
            }

            if (dPadDirection == DPadDirection.Right && lastFrame_right != right && lastFrame_right)
            {
                lastFrame_right = false;
                return(true);
            }

            if (dPadDirection == DPadDirection.Up && lastFrame_up != up && lastFrame_up)
            {
                lastFrame_up = false;
                return(true);
            }

            if (dPadDirection == DPadDirection.Down && lastFrame_down != down && lastFrame_down)
            {
                lastFrame_down = false;
                return(true);
            }

            return(false);
        }
示例#4
0
        // dpad up functions
        public void DPadButton(DPadDirection dir, bool state)
        {
            // if up is pressed
            if (state)
            {
                switch(dir)
                {
                    case DPadDirection.Up:
                    case DPadDirection.Down:
                        {
                            // call the function
                            rockIncrement((dir == DPadDirection.Up ? 1 : -1));
                        }
                        break;
                    case DPadDirection.Left:
                    case DPadDirection.Right:
                        {
                            rockRing += (dir == DPadDirection.Right ? 1 : -1);

                            rockRing = rockRing % 6;
                            if (rockRing < 0)
                                rockRing = 5;

                            ringSwitch();
                        }
                        break;
                }
            }
        }
示例#5
0
        private static double?HasDirection(Dictionary <Usage, DataValue> changes, DPadDirection directionCheck)
        {
            var direction = GetDirection(changes);

            if (direction.HasValue)
            {
                return(direction.Value.HasFlag(directionCheck) ? 1 : 0);
            }
            return(null);
        }
示例#6
0
        /// <summary>
        /// Sets new DPad values.
        /// </summary>
        /// <param name="newDPads">new values</param>
        /// <returns>changed DPad indices</returns>
        public bool SetDPad(int i, DPadDirection newValue)
        {
            var oldValue = dPads[i];

            if (newValue != oldValue)
            {
                dPads[i] = newValue;
                changedDpad.Add(i);
                return(true);
            }
            return(false);
        }
示例#7
0
        public static bool DPadDirectionClicked(DPadDirection direciton)
        {
            switch (direciton)
            {
            case Input.DPadDirection.Up:
                return(_currentState.DPad.Up == ButtonState.Pressed && _oldState.DPad.Up == ButtonState.Released);

            case Input.DPadDirection.Down:
                return(_currentState.DPad.Down == ButtonState.Pressed && _oldState.DPad.Down == ButtonState.Released);

            case Input.DPadDirection.Left:
                return(_currentState.DPad.Left == ButtonState.Pressed && _oldState.DPad.Left == ButtonState.Released);

            case Input.DPadDirection.Right:
                return(_currentState.DPad.Right == ButtonState.Pressed && _oldState.DPad.Right == ButtonState.Released);
            }
            return(false);
        }
示例#8
0
            protected bool Up(Func <GamePadState> mapping, DPadDirection direction)
            {
                switch (direction)
                {
                case DPadDirection.DOWN:
                    return(mapping().DPad.Down == ButtonState.Released);

                case DPadDirection.LEFT:
                    return(mapping().DPad.Left == ButtonState.Released);

                case DPadDirection.RIGHT:
                    return(mapping().DPad.Right == ButtonState.Released);

                case DPadDirection.UP:
                    return(mapping().DPad.Up == ButtonState.Released);

                default:
                    return(false);
                }
            }
示例#9
0
    public DPadDirection GetDPadDirection()
    {
        if (inputVector == Vector2.zero)
        {
            return(DPadDirection.NEUTRAL);
        }

        DPadDirection curDPadDirection = (DPadDirection)1;
        float         maxDot           = Vector2.Dot(dPadDirections[0], this.inputVector);

        for (int i = 1; i < dPadDirections.Count; i++)
        {
            float dot = Vector2.Dot(dPadDirections[i], this.inputVector);
            if (dot > maxDot)
            {
                curDPadDirection = (DPadDirection)i + 1;
                maxDot           = dot;
            }
        }
        return(curDPadDirection);
    }
示例#10
0
 /// <summary>
 /// Refreshes the current state.
 /// </summary>
 /// <returns></returns>
 public bool RefreshInput()
 {
     foreach (var type in (XInputTypes[])Enum.GetValues(typeof(XInputTypes)))
     {
         var mapping = mapper.GetMapping(type);
         if (mapping != null)
         {
             double value = 0;
             if (mapping.InputType != null)
             {
                 value = source.Get(mapping.InputType);
             }
             values[type] = mapping.GetValue(value);
         }
         else
         {
         }
     }
     dPad = source.DPad;
     InputChanged?.Invoke();
     return(true);
 }
示例#11
0
        protected virtual void ChangeKeypadColor(DPadDirection direction, bool press)
        {
            var buttonColor = press ? ButtonPressedColor : ButtonColor;

            switch (direction)
            {
            case DPadDirection.Up:
                _upButton.Colour = buttonColor;
                break;

            case DPadDirection.Down:
                _downButton.Colour = buttonColor;
                break;

            case DPadDirection.Left:
                _leftButton.Colour = buttonColor;
                break;

            case DPadDirection.Right:
                _rightButton.Colour = buttonColor;
                break;
            }
        }
示例#12
0
        /// <summary>
        /// Converts 4 bool values to DPadDirection.
        /// </summary>
        /// <param name="up">Up value</param>
        /// <param name="down">Down value</param>
        /// <param name="left">Left value</param>
        /// <param name="right">Right value</param>
        /// <returns>constructed DPadDirection</returns>
        public static DPadDirection GetDirection(bool up, bool down, bool left, bool right)
        {
            DPadDirection value = DPadDirection.None;

            if (up)
            {
                value |= DPadDirection.Up;
            }
            else if (down)
            {
                value |= DPadDirection.Down;
            }

            if (right)
            {
                value |= DPadDirection.Right;
            }
            else if (left)
            {
                value |= DPadDirection.Left;
            }

            return(value);
        }
示例#13
0
        public void GetDirectionTest(bool up, bool down, bool left, bool right, DPadDirection direction)
        {
            DPadDirection dPad = DPadHelper.GetDirection(up, down, left, right);

            Assert.AreEqual(direction, dPad);
        }
示例#14
0
 public static bool isNeutral(DPadDirection dir)
 {
     return(dir == DPadDirection.NEUTRAL);
 }
示例#15
0
 public static bool isLeft(DPadDirection direction)
 {
     return(direction == DPadDirection.LEFT || direction == DPadDirection.TOP_LEFT || direction == DPadDirection.BOTTOM_LEFT);
 }
示例#16
0
 // dpad up functions
 public void DPadButton(DPadDirection dir, bool state)
 {
     // if up is pressed
     if (state)
     {
         switch (dir)
         {
             case DPadDirection.Left:
                 {
                     if (slider.Value - .1 > Min)
                         slider.Value -= .1;
                     else
                         slider.Value = Min;
                 }
                 break;
             case DPadDirection.Right:
                 {
                     if (slider.Value + .1 < Max)
                         slider.Value += .1;
                     else
                         slider.Value = Max;
                 }
                 break;
         }
     }
 }
示例#17
0
 public static bool isRight(DPadDirection direction)
 {
     return(direction == DPadDirection.RIGHT || direction == DPadDirection.TOP_RIGHT || direction == DPadDirection.BOTTOM_RIGHT);
 }
示例#18
0
 public static bool isUp(DPadDirection direction)
 {
     return(direction == DPadDirection.UP || direction == DPadDirection.TOP_LEFT || direction == DPadDirection.TOP_RIGHT);
 }
示例#19
0
        private void processReport(HidInputReport report)
        {
            if (this.lastReport != null)
            {
                if (this.SetupMode)
                {
                    foreach (var boolControl in report.ActivatedBooleanControls)
                    {
                        var lastControl = this.lastReport.GetBooleanControl(boolControl.UsagePage, boolControl.UsageId);
                        if (boolControl.IsActive && !lastControl.IsActive)
                        {
                            HIDMapping mapping = new HIDMapping()
                            {
                                DisplayName = String.Format(this.resources.GetString("hidButtonDescription"), boolControl.Id),
                                UsagePage   = boolControl.UsagePage,
                                UsageId     = boolControl.UsageId,
                                IsNumeric   = false
                            };

                            this.ControlChanged(mapping);
                        }
                    }

                    foreach (var numControlDesc in this.numControlDescs)
                    {
                        var numControl     = report.GetNumericControlByDescription(numControlDesc);
                        var lastNumControl = this.lastReport.GetNumericControlByDescription(numControlDesc);
                        if (numControl != null && lastNumControl != null && numControl.Value != lastNumControl.Value)
                        {
                            if (CheckDeadzone(numControlDesc, numControl) &&
                                !CheckDeadzone(lastNumControl.ControlDescription, lastNumControl))
                            {
                                ushort center   = NumericCenters[numControl.UsagePage];
                                short  axisSign = (short)Math.Sign((short)numControl.Value - (short)center);
                                String sign     = string.Empty;
                                if (center != 0)
                                {
                                    sign = axisSign < 0 ? "-" : "+";
                                }
                                String displayName = String.Format(this.axisString, sign, numControl.Id);

                                DPadDirection direction = default(DPadDirection);
                                if (numControlDesc.UsagePage == 0x01 && numControlDesc.UsageId == 0x39)
                                {
                                    switch (numControl.Value)
                                    {
                                    case 0:
                                        direction   = DPadDirection.Up;
                                        displayName = this.hidDPadUp;
                                        break;

                                    case 2:
                                        direction   = DPadDirection.Right;
                                        displayName = this.hidDPadRight;
                                        break;

                                    case 4:
                                        direction   = DPadDirection.Down;
                                        displayName = this.hidDPadDown;
                                        break;

                                    case 6:
                                        direction   = DPadDirection.Left;
                                        displayName = this.hidDPadLeft;
                                        break;
                                    }
                                }
                                HIDMapping mapping = new HIDMapping()
                                {
                                    DisplayName = displayName,
                                    UsagePage   = numControl.UsagePage,
                                    UsageId     = numControl.UsageId,
                                    Sign        = axisSign,
                                    Direction   = direction,
                                    IsNumeric   = true
                                };

                                this.ControlChanged(mapping);
                            }
                        }
                    }
                }
                else
                {
                    //ButtonStates newState = new ButtonStates();
                    //ProcessInputForMap(report, this.mapping, ref newState);
                    //ProcessInputForMap(report, this.mappingAlternative, ref newState);
                    //this.state.buttons = newState;
                }
            }
            this.lastReport = report;
        }
示例#20
0
 public static bool isDown(DPadDirection direction)
 {
     return(direction == DPadDirection.DOWN || direction == DPadDirection.BOTTOM_LEFT || direction == DPadDirection.BOTTOM_RIGHT);
 }