Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

share|improve this 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. –  Reisi007 Mar 23 '13 at 18:16
    
Thanks 4 the down-vote... –  Reisi007 Mar 23 '13 at 18:18
    
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. –  Reisi007 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
show 1 more comment

closed as too localized by bummzack, Sean Middleditch, Josh Petrie, Byte56, 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.

1 Answer

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

share|improve this answer
add comment

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