xboxscene.org forums

OG Xbox Forums => Software Forums => Development => Topic started by: celinedrules on April 27, 2005, 11:26:00 AM

Title: Gamepad Problems
Post by: celinedrules on April 27, 2005, 11:26:00 AM
CODE
if( myGamePad.wButtons & XINPUT_GAMEPAD_DPAD_UP )

This code works to check if up and back was pressed:
CODE
if(( myGamePad.wButtons & XINPUT_GAMEPAD_DPAD_UP )&& (myGamePad.wButtons & XINPUT_GAMEPAD_BACK ))

So in theory if I change it to check just for the back button being pressed, it should work. Wrong, it automatically executes like the button is being pressed. Here is the code for that:
CODE
if( myGamePad.wButtons & XINPUT_GAMEPAD_BACK )
How would I get it to wait until the back button was pressed?
Title: Gamepad Problems
Post by: celinedrules on April 27, 2005, 11:58:00 PM
I tried that but it still automatically executes the code.
Title: Gamepad Problems
Post by: fghjj on April 28, 2005, 09:29:00 AM
Are you sure you update the XINPUT_STATE struct correct?
Title: Gamepad Problems
Post by: celinedrules on April 28, 2005, 09:44:00 AM
CODE
#include
void ReBoot()
{
   LD_LAUNCH_DASHBOARD LaunchData = { XLD_LAUNCH_DASHBOARD_MAIN_MENU };
   XLaunchNewImage( NULL, (LAUNCH_DATA*)&LaunchData );
}

bool GamePad()
{
   XINPUT_GAMEPAD myGamePad;

DWORD dwInsertions, dwRemovals;
    XGetDeviceChanges( XDEVICE_TYPE_GAMEPAD, &dwInsertions, &dwRemovals );

   
   static HANDLE pGamePd;

if( dwInsertions & 1 )
    {
  pGamePd = XInputOpen( XDEVICE_TYPE_GAMEPAD, 0,
                                               XDEVICE_NO_SLOT, NULL );

   }

   if( pGamePd )
    {
  XINPUT_STATE myInputStates;
  XInputGetState( pGamePd, &myInputStates );

  memcpy( &myGamePad, &myInputStates.Gamepad, sizeof(XINPUT_GAMEPAD) );

    }

//   if(( myGamePad.wButtons & XINPUT_GAMEPAD_DPAD_UP )&& (myGamePad.wButtons & XINPUT_GAMEPAD_BACK ))
   //if( myGamePad.wButtons & XINPUT_GAMEPAD_BACK )   
   while( !(myGamePad.wButtons & XINPUT_GAMEPAD_BACK ) )
   {
  return true;
   }

   return false;
}

void __cdecl main()
{

   XInitDevices(0, 0);

while( true )
   {
  bool bb = GamePad();
  if( bb )
  {
     break;
  }
   }
   
   ReBoot();
}
Title: Gamepad Problems
Post by: fghjj on April 28, 2005, 08:50:00 PM
smile.gif
Title: Gamepad Problems
Post by: celinedrules on April 28, 2005, 11:23:00 PM
CODE
if( myGamePad.wButtons == XINPUT_GAMEPAD_BACK )
Title: Gamepad Problems
Post by: celinedrules on April 29, 2005, 08:50:00 AM
CODE
while( !( myGamePad.wButtons & XINPUT_GAMEPAD_BACK ) )
{
       return false;

}
       return true;

It that correct cause if so, I can't get that to work either.
Title: Gamepad Problems
Post by: g0at3r on April 29, 2005, 11:12:00 AM
CODE

// While BACK is not pressed don't go any further
while( !( myGamePad.wButtons & XINPUT_GAMEPAD_BACK ) )
{
        // Reget button state here
        XInputGetState( blah blah again! to reget what buttons are down & up! )

        // Now the code goes back to the "while()" to see if its down this time
        // if BACK is pressed it will continue!
}

// BACK FINALLY PRESSED!


Thats as simple as i can put it.
If you can't understand that then im sorry but i give up!