Jump to content

  • Log In with Google      Sign In   
  • Create Account

SetProperty() returns ERROR_BUSY


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Cosmodore   Members   -  Reputation: 108

Like
0Likes
Like

Posted 05 November 2012 - 08:52 PM

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[i].dwOfs)
  {
   case DIK_SPACE:  //Process space bar
   case DIK_ESCAPE: //Process escape key
	//etc...
  }
}

Is there any way of doing something similar with GetDeviceState()?

Sponsor:

#2 Cosmodore   Members   -  Reputation: 108

Like
0Likes
Like

Posted 06 November 2012 - 06:02 AM

Ha! Solved my own problem - changed DXGetErrorString() for DXGetErrorDescription() and discovered you can't set the buffer size while the keyboard is acquired.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS