Jump to content

  • Log In with Google      Sign In   
  • Create Account

GamePad input not working


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 ch1mera   Members   -  Reputation: 176

Like
0Likes
Like

Posted 23 February 2013 - 08:49 PM

Hi, long time lurker, first time poster. I have a bit of experience with Python and C#, however I'm new to the xna framework. I have a wired xbox 360 controller connected, drivers are up to date. The controller works just fine in other applications, however I can't get the input to work, at all in the programs i write. 

 

Keyboard input works just fine, it's just the gamepad that is giving me problems.

 

 

 

In case anyone is curious:

GamePadState gamePad1 = GamePad.GetState(PlayerIndex.One);
if (gamePad1.Buttons.B == ButtonState.Pressed) exit();
 

 

I'm sure the solution will turn out to be an obvious one... 

 

Thanks,



Sponsor:

#2 Inuyashakagome16   Members   -  Reputation: 835

Like
0Likes
Like

Posted 23 February 2013 - 10:05 PM

I've used XNA for a while so lets see if I can help. Are you using XNA or Monogame? (most people seem to be moving to monogame hence me asking)

Also, your input code looks correct. Question: Have you used "exit();" with normal keyboard input? Like same code, only used for the keyboard and does it work there? Because to me, the only place I MIGHT see a problem is "exit();" (not sure if exit(); would actually close out or if It's just been a while since I've seen some code)

 

Edit:

 

            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
                Exit();

 

That's a line of code from a normal template XNA game I found. That one doesn't seem to declare the GamePadState ahead of time. Try using that and see if it works. It SHOULD in theory work both ways but try that.


Edited by Inuyashakagome16, 23 February 2013 - 10:07 PM.


#3 ch1mera   Members   -  Reputation: 176

Like
0Likes
Like

Posted 23 February 2013 - 11:45 PM

Thanks for the reply. I am using Monogame. Also, using exit(); with keyboard input works just fine. 

 

Even when running the template, which includes the block of code you mentioned, keyboard works fine but the controller does not.



#4 Inuyashakagome16   Members   -  Reputation: 835

Like
0Likes
Like

Posted 24 February 2013 - 09:46 AM

After some research I found this > http://monogame.codeplex.com/discussions/357129 It's from earlier last year but talks about some issues with the gamepad controls. I would research it a bit and see what you can find. It's possible you just need to edit a few lines in one of the source files to fix it but I would look it up to double check. That's all I could find real quick. :( I'll play with it a bit and see what I can do. :) 

 

(Also it seems like it may only work with a real xbox controller? That's what the thread seemed to say unless I missed something)






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS