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;

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 McDonald Apr 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.

  • \$\begingroup\$ 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. \$\endgroup\$ – Florian Reisinger Mar 23 '13 at 18:16
  • \$\begingroup\$ We aren't talking about an XBox controller then? If it is an XBox controller then just check for a button being pressed. \$\endgroup\$ – Dialock Mar 23 '13 at 18:46
  • \$\begingroup\$ 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. \$\endgroup\$ – Florian Reisinger Mar 24 '13 at 7:06
  • \$\begingroup\$ 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. \$\endgroup\$ – Dialock Mar 24 '13 at 16:57
  • \$\begingroup\$ Well, I want to check if the framework works. Anyway I am going to update my code to satisfy you.... \$\endgroup\$ – Florian Reisinger Mar 25 '13 at 6:39

Well, found out, that is indeed not supported, but found the following: http://nuclexframework.codeplex.com/releases/view/62687 <-- Only Nuclex.Input.dll is needed to Reference...

How to use:

  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();

Because I am only developing for Desktop, I have no idea how you are able to use it on a XBox or Windows Phone 7 (well, of course there are .dlls included....) and why you should...

For testing the joystick I can recommend: http://sandbox.yoyogames.com/games/155175-joystick-input-tester-v100


Not the answer you're looking for? Browse other questions tagged or ask your own question.