I'm using XInput for a project and I'm having a problem using the xbox controller. When I use the B button to return to a previous state, its registering the button press so fast that it continues to push back multiple states that use the B button to exit.
if( ( player1.GetState().Gamepad.wButtons & XINPUT_GAMEPAD_B ) || ( player2.GetState().Gamepad.wButtons & XINPUT_GAMEPAD_B ) ) {
return ESC_BUTTON;
}
I've tried resetting the buffer by adding an & 1
but than the input never registers. Is there an easy way to fix this problem?
UPDATE:
current = (DWORD)( ( start - GetTickCount() ) / 1000.f );
if( current > 0.005f )
{
if( ( player1.GetState().Gamepad.wButtons & XINPUT_GAMEPAD_B ) || ( player2.GetState().Gamepad.wButtons & XINPUT_GAMEPAD_B ) )
{
start = GetTickCount();
return ESC_BUTTON;
}
}
Still having issues with resetting. Sometimes it works, sometimes it doesn't...thoughts?