xboxscene.org forums

Author Topic: Gamepad Problems  (Read 94 times)

celinedrules

  • Archived User
  • Hero Member
  • *
  • Posts: 640
Gamepad Problems
« 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?
Logged

celinedrules

  • Archived User
  • Hero Member
  • *
  • Posts: 640
Gamepad Problems
« Reply #1 on: April 27, 2005, 11:58:00 PM »

I tried that but it still automatically executes the code.
Logged

fghjj

  • Archived User
  • Sr. Member
  • *
  • Posts: 288
Gamepad Problems
« Reply #2 on: April 28, 2005, 09:29:00 AM »

Are you sure you update the XINPUT_STATE struct correct?
Logged

celinedrules

  • Archived User
  • Hero Member
  • *
  • Posts: 640
Gamepad Problems
« Reply #3 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();
}
Logged

fghjj

  • Archived User
  • Sr. Member
  • *
  • Posts: 288
Gamepad Problems
« Reply #4 on: April 28, 2005, 08:50:00 PM »

smile.gif
Logged

celinedrules

  • Archived User
  • Hero Member
  • *
  • Posts: 640
Gamepad Problems
« Reply #5 on: April 28, 2005, 11:23:00 PM »

CODE
if( myGamePad.wButtons == XINPUT_GAMEPAD_BACK )
Logged

celinedrules

  • Archived User
  • Hero Member
  • *
  • Posts: 640
Gamepad Problems
« Reply #6 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.
Logged

g0at3r

  • Archived User
  • Newbie
  • *
  • Posts: 14
Gamepad Problems
« Reply #7 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!
Logged