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()?