directX directInput Keyboard throws E_accessdenied

2019-07-26 05:31发布

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

1条回答
叼着烟拽天下
2楼-- · 2019-07-26 06:12

The documentation for IDirectInputDevice8::GetDeviceState give the following possible return values:

Return Value
If the method succeeds, the return value is DI_OK. If the method fails, the return value can be one of the following error values: DIERR_INPUTLOST, DIERR_INVALIDPARAM, DIERR_NOTACQUIRED, DIERR_NOTINITIALIZED, E_PENDING.

You should check that none of the DIERR_* macros overlap with E_ACCESSDENIED.

Further, some code I've seen handles E_ACCESSDENIED the same way as DIERR_INPUTLOST. You might want to try to re-Acquire the input and have another go.

查看更多
登录 后发表回答