SetProperty() returns ERROR_BUSY

Started by
0 comments, last by Cosmodore 11 years, 5 months ago
Hello all, this is my first post so please excuse any glaring faux pas. I'm just starting with DirectX 11, and I've got as far as creating an input handler. I'm trying to get keyboard updates using GetDeviceData() but it's telling me the keyboard isn't buffered. Fair enough, so I try setting the buffer size with SetProperty() and the result comes back ERROR_BUSY, which MSDN doesn't even give as a possible return value. Thanks MSDN!

Here's the code:


//The definition of this structure came straight from MSDN
DIPROPDWORD dipdw;
dipdw.diph.dwSize = sizeof(DIPROPDWORD);
dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
dipdw.diph.dwObj = 0;
dipdw.diph.dwHow = DIPH_DEVICE;
dipdw.dwData = 8; // Arbitrary buffer size

HRESULT hr = mKeyboardDevice->SetProperty( DIPROP_BUFFERSIZE, &dipdw.diph );
LPCWSTR error = DXGetErrorString(hr);


When I read that string error it comes out as ERROR_BUSY. Can someone tell me why? I know the keyboard device is initialised correctly.

Alternatively...

The keyboard device works fine with GetDeviceState(), but as far as I can tell using that function means having to check the value of each key in the resulting char array with a bitwise and, therefore leading to code which is a series of IF statements. I was planning to use a SWITCH statement with the results of GetDeviceData() like so:


const int maxItems=10;
DWORD nItems=maxItems;
DIDEVICEOBJECTDATA keyData[maxItems];
for (int i=0; i<nItems; i++)
{
switch (keyData.dwOfs)
{
case DIK_SPACE: //Process space bar
case DIK_ESCAPE: //Process escape key
//etc...
}
}


Is there any way of doing something similar with GetDeviceState()?
Advertisement
Ha! Solved my own problem - changed DXGetErrorString() for DXGetErrorDescription() and discovered you can't set the buffer size while the keyboard is acquired.

This topic is closed to new replies.

Advertisement