XNA Creators Club Online
Page 1 of 1 (3 items)
Sort Posts: Previous Next

PC Gamepad D-Pad problem

Last post 11/20/2009 5:16 PM by skyrider. 2 replies.
  • 11/20/2009 4:54 PM

    PC Gamepad D-Pad problem


    Hi guys, I'm using the Soopah.Xna dll for making PC gamepads work. So far everything
    works great except for the directional pad. I keep getting errors

    Line 19 is where I'm getting the error and it says
      - Cannot implicitly convert type 'Microsoft.Xna.Framework.Input.ButtonState' to 'bool'

    Any thoughts on how to fix this?

    1 #region GAMEPAD 
    2             // PC Gamepad Controls Logic added here 
    3              
    4             lastGamePadState = currentGamePadState; 
    5             currentGamePadState = TestingGrounds.PCGamePad.GetState(PlayerIndex.One); 
    6              
    7             // Allows the game to exit 
    8             if (TestingGrounds.PCGamePad.GetState(PlayerIndex.One).Buttons.Start == ButtonState.Pressed) 
    9                 this.Exit(); 
    10              
    11             // Allows the game to exit 
    12             if (lastGamePadState.Buttons.Select == ButtonState.Released && 
    13                 currentGamePadState.Buttons.Select == ButtonState.Pressed) 
    14             { 
    15                 this.Exit(); 
    16             } 
    17  
    18             // Change the sprite 2 position using the D-Pad 
    19             if (TestingGrounds.PCGamePad.GetState(PlayerIndex.One).DPad.Up) 
    20                 Smiley2.position += new Vector2(0, -5); 
    21              
    22             // Change the sprite 2 position using the left thumbstick 
    23             Vector2 LeftThumb = TestingGrounds.PCGamePad.GetState(PlayerIndex.One).Thumbsticks.Left; 
    24             Smiley2.position += new Vector2(LeftThumb.X, LeftThumb.Y) * 10;   // # represents the speed of movement 
    25
    26           #endregion 



  • 11/20/2009 4:59 PM In reply to

    Re: PC Gamepad D-Pad problem

    You want:

      TestingGrounds.PCGamePad.GetState(PlayerIndex.One).DPad.Up.Pressed


    DPad.Up is a ButtonState and needs to be treated the same as the way you handle the other buttons above.


  • 11/20/2009 5:16 PM In reply to

    Re: PC Gamepad D-Pad problem

    got it ^^ gave me a great hint :) thx

    if (TestingGrounds.PCGamePad.GetState(PlayerIndex.One).DPad.Up == ButtonState.Pressed)
                    Smiley2.position += new Vector2(0, -5);
Page 1 of 1 (3 items) Previous Next