# XNA Framework doesn't recognise controller [closed]

So just a little bit of XNA code:

if (this.IsActive && (Keyboard.GetState().GetPressedKeys().Length > 0 || Mouse.GetState().LeftButton == ButtonState.Pressed || Mouse.GetState().RightButton == ButtonState.Pressed || Mouse.GetState().MiddleButton == ButtonState.Pressed) || GP_state.GetButton(8) == ButtonState.Pressed)
{
Current_GameState = GameStates.Game;
bg_music.Play();
}


If something is done --> Switch to a different game state. Works with: Keyboard and Mouse, but not with the gamepad (which is new and it works with other games) So why does XNA not recognise it correctly??

EDIT: I do have a working solution and mark my own answer as soon as possible as right...

## closed as too localized by bummzack, Sean Middleditch, Josh♦, MichaelHouse♦, John McDonaldApr 5 '13 at 17:12

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.

• Found out how it works... It is indeed not supported: Tutorial: miszalok.de/C_3D_XNA/C4_Controller/XNAC4_GamePad_e.htm Needed .dll: sourceforge.net/projects/xnadirectinput Sorry, unable to answer my question within 7 hours. – Florian Reisinger Mar 23 '13 at 18:16
• We aren't talking about an XBox controller then? If it is an XBox controller then just check for a button being pressed. – Dialock Mar 23 '13 at 18:46
• Yes "controler" is a very general term... Please see this part of the code: "GamePad.GetState(PlayerIndex.One).IsConnected" The program does something, if a Gamepad (which has to be a XBox controller) is connected. – Florian Reisinger Mar 24 '13 at 7:06
• I see your code and it makes no sense. 1: It's Microsoft, so no out of box support for controllers except their own. 2: design wise you should be checking if a button was pressed, not if the controller is/was connected. Logic is similar to your checks on the keyboard and mouse. – Dialock Mar 24 '13 at 16:57
• Well, I want to check if the framework works. Anyway I am going to update my code to satisfy you.... – Florian Reisinger Mar 25 '13 at 6:39

1. Class level variable: InputManager ManageI;
2. List item On Initialize() or in the Game Constructor:ManageI = new InputManager();
3. 2 Using needed: using Nuclex.Input; using Nuclex.Input.Devices;
4. Before trying to get a gamestate, don't forget to call ManageI.Update();