I have a menu that you can navigate with the keyboard, but I also want it so you can navigate it with the controller thumb sticks. But my problem is that if you push down or up on the thumb sticks it will just fly through the menu. To fix problem if it was a keyboard you would just do: prevKeyState.IsKeyUp(Keys.Down). So I was wondering if there anything like this for the controller thumb sticks?

I'm not sure if I'm doing something wrong but it still flies through the menu.

 private enum GamePadStates
{
None,
GoingDown,
GoingUp
}

public void Update(GameTime gameTime)
{
keyState = Keyboard.GetState();

else

if (keyState.IsKeyDown(Keys.Down) && prevKeyState.IsKeyUp(Keys.Down) ||
{
if (selected < (buttonList.Count - 1))
{
selected++;
}
}

if (keyState.IsKeyDown(Keys.Up) && prevKeyState.IsKeyUp(Keys.Up) ||
{
if (selected > 0)
{
selected--;
}
}

• I've edited the code to manage the keyboard – Blau Aug 31 '13 at 19:36

You can do it in a similar way to keyboard, storing the state by yourself:

   enum States {None, GoingDown, GoingUp }

States Current, Previous;

void Update()
{
Previous = Current;

if (thumbStiscks.Y>0.5 || keyState.IsKeyDown(Keys.Up))
State = States.GoingUp;
else if (thumbSticks.Y<-0.5f || keyState.IskeyDown(Keys.Down))
State = States.GoingDown;
else State = States.None;

if ( Current == States.GoingDown  && Previous != States.GoingDown)
&& selected < (buttonList.Count - 1)) {
selected++;
}
else if ( Current == States.GoingUp && Previous != States.GoingUp)
&& selected >0) {
selected--;
}
}