directX directInput Keyboard throws E_accessdenied

落花浮王杯 提交于 2019-12-11 12:04: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:


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.



来源:https://stackoverflow.com/questions/9425575/directx-directinput-keyboard-throws-e-accessdenied

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!