Original Post
I have xinput working fine unbuffered...obviously...it's a peice of cake. I figured buffered input would be equally easy, but for some reason I can't get it to work. I have 2 variables for states. XINPUT_STATE m_xState and m_xBufferedState first I have the following two variables:
private:
XINPUT_STATE m_xState;
XINPUT_STATE m_xBufferedState;
Every single frame I'm doing this code:
bool PollXInput(void){
DWORD result;
ZeroMemory(&m_xState, sizeof(XINPUT_STATE));
result = XInputGetState(0, &m_xState);
if(result != ERROR_SUCCESS)
return false;
return true;
}
And then I have the function GetXButton(unsigned char _xButton):
bool GetXButton(unsigned char _xButton){
return (m_xState.Gamepad.wButtons & _xButton);
}
this all works fine and dandy...but here's what i'm attempting to do for buffered input:
bool GetBufferedXButton(unsigned char _xButton){
bool bTemp = GetXButton(_xButton);
if(bTemp) return false;
// at this point we know _xButton wasn't down already.
DWORD result;
ZeroMemory(&m_xBufferedState, sizeof(XINPUT_STATE));
result = XInputGetState(0, &m_xBufferedState);
if (result == ERROR_SUCCESS){
return (m_xBufferedState.Gamepad.wButtons & _xButton);
}
return false;
}
When I debug through, it manages to go as far as result = XInputGetState(0, &m_xBufferedState); inside of GetBufferedXButton(uchar) but regardless of what is pressed down, it returns a state that has nothing pressed down. Even when the normal m_xState shows the correct button(s) being pressed, m_xBufferedState shows nothing. Is there something I'm missing? Or something I'm unaware of that XInputGetState() does? [edit]: I did this all by heart (the code isn't really that complicated..) so I may have made some typos or something. :) Thanks for the help! Hopefully I provided enough information. And yeah, I'm passing 0 into all of the functions because it's for a single player game. :) Thanks everyone. [Edited by - Holland on April 3, 2009 4:39:20 PM]