My team and I are currently developing a 2D platformer with SDL/OpenGL and we want to add support to the Xbox360 Gamepad with the XInput library from Microsoft, but we are currently having a problem.
First of all, the method for reading the key states it's this one:
bool InputMapping::Gamepad::checkKeyState(WORD button)
{
DWORD dwResult;
DWORD idPlayer = playerID - 1;
XINPUT_STATE state;
ZeroMemory( &state, sizeof(XINPUT_STATE) );
dwResult = XInputGetState( idPlayer, &state );
if ( state.Gamepad.wButtons & button)
{
return true;
}
return false;
}
This method returns true or false if the selected key it's pressed or not.
But it seems that the polling of the keys it's ocurring really fast, in the menus, moving through the buttons it's really fast and I can't controlled.
There is a way to limit the time between polling inside of the XInput or I should do it by myself? or what you recommend me?
If I didn't explain me clearly don't hesitate in say that.
Thanks a lot.