GamePad input not working

Started by
2 comments, last by Inuyashakagome16 11 years, 1 month ago

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,

Advertisement

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.

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.

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)

This topic is closed to new replies.

Advertisement