Example #1
0
    public static InputDirection.Direction GetDirection(XBOX_DIRECTION direction, GamePadState pad)
    {
        InputDirection.Direction d = new InputDirection.Direction(0, 0);

        if (!pad.IsConnected)
        {
            return d;
        }

        switch (direction)
        {
            case XBOX_DIRECTION.Pad:
                if (pad.DPad.Down == ButtonState.Pressed)
                    d.y--;
                if (pad.DPad.Up == ButtonState.Pressed)
                    d.y++;
                if (pad.DPad.Right == ButtonState.Pressed)
                    d.x++;
                if (pad.DPad.Left == ButtonState.Pressed)
                    d.x--;
                break;
            case XBOX_DIRECTION.StickLeft:
                d.x = pad.ThumbSticks.Left.X;
                d.y = pad.ThumbSticks.Left.Y;
                break;
            case XBOX_DIRECTION.StickRight:
                d.x = pad.ThumbSticks.Right.X;
                d.y = pad.ThumbSticks.Right.Y;
                break;
        }

        return d;
    }
Example #2
0
    public static InputDirection.Direction GetDirection(XBOX_DIRECTION direction, GamePadState pad)
    {
        InputDirection.Direction d = new InputDirection.Direction(0, 0);

        if (!pad.IsConnected)
        {
            return(d);
        }

        switch (direction)
        {
        case XBOX_DIRECTION.Pad:
            if (pad.DPad.Down == ButtonState.Pressed)
            {
                d.y--;
            }
            if (pad.DPad.Up == ButtonState.Pressed)
            {
                d.y++;
            }
            if (pad.DPad.Right == ButtonState.Pressed)
            {
                d.x++;
            }
            if (pad.DPad.Left == ButtonState.Pressed)
            {
                d.x--;
            }
            break;

        case XBOX_DIRECTION.StickLeft:
            d.x = pad.ThumbSticks.Left.X;
            d.y = pad.ThumbSticks.Left.Y;
            break;

        case XBOX_DIRECTION.StickRight:
            d.x = pad.ThumbSticks.Right.X;
            d.y = pad.ThumbSticks.Right.Y;
            break;
        }

        return(d);
    }
Example #3
0
 public InputDirection.Direction GetDirection(XBOX_DIRECTION dir)
 {
     return XboxInputs.GetDirection(dir, pad);
 }
Example #4
0
 public InputDirection.Direction GetDirection(XBOX_DIRECTION dir)
 {
     return(XboxInputs.GetDirection(dir, pad));
 }