I am trying to work with DirectInput keyboard, and my code is throwing a weird error. I can go through the creation, and setting of everything and they all return S_OK, but when I try to run
HRESULT hr;
hr = m_pDIKeyboard->GetDeviceState( sizeof(keyBuffer), (LPVOID)&keyBuffer );
hr comes back as (hex address) "access code is invalid", and when I do a check for
if(FAILED(hr))
it comes back as E_ACCESSDENIED there are no errors (or warnings for that matter) on the keyBuffer, or any part of the line.
any thoughts on this
The documentation for
IDirectInputDevice8::GetDeviceState
give the following possible return values:You should check that none of the
DIERR_*
macros overlap withE_ACCESSDENIED
.Further, some code I've seen handles
E_ACCESSDENIED
the same way asDIERR_INPUTLOST
. You might want to try to re-Acquire
the input and have another go.