Chris Voce

Chris Voce

  • NA
  • 10
  • 9.9k

Using DirectX to get Joystick buttons - but don't get initial state of buttons until one is pressed

Jun 1 2011 7:02 PM
Hi,

I am using C# and DirectX to query a Joystick connected to a Game Port, to see which buttons are pressed.  Calling Device.CurrentJoystickState.GetButtons() is giving me the data that I need, but only once a button is pressed.  Until then the array is all 0's.

For example, if button 1 is held on then the app is started, all 4 buttons show as off.  If I turn, say, button 3 on, then buttons 1 AND 3 instantly show as being on.  So turning any button on refreshes the state of all buttons.

So does anyone know why I am not getting the initial state of the buttons, and/or how I can?

My code is based loosely (well actually quite tightly!) around the example at http://www.codeproject.com/KB/directx/joystick.aspx.  The example there, if you download it, has exactly the same results.

Finally, does anyone know what the 4 differnent "modes" on a game port are?  (it is a switch on the USB to Game Port adapter that I have).  It doesn't seem to make any difference to my issue anyway.

Thanks in advance.

Chris

Answers (2)