Archived

This topic is now archived and is closed to further replies.

eckbw

DirectInput SetProperty()

Recommended Posts

eckbw    122
I have a problem with IDirectInputDevice8::SetProperty. It just fails everytime. Here´s the code:
  
DIPROPDWORD prop;
prop.diph.dwSize = sizeof(DIPROPDWORD);
prop.diph.dwHeaderSize = sizeof(DIPROPHEADER);
prop.diph.dwObj = 0;
prop.diph.dwHow = DIPH_DEVICE;
prop.dwData = INPUTBUFFERSIZE;   
HRESULT error = lpKeyboard->SetProperty(DIPROP_BUFFERSIZE, &prop.diph);
if ((error != DI_OK) || (error != DI_PROPNOEFFECT))
  //error code here

  
In the DirectX documentation it says error can be one of the following if the function fails: DIERR_INVALIDPARAM, DIERR_NOTINITIALIZED, DIERR_OBJECTNOTFOUND, DIERR_UNSUPPORTED. I´ve checked this to but that´s not the case. It´s not DI_OK and it´s not one of the others. It just plain fails for some reason. And if I let the program run, it crashes when it reaches the call to IDirectInputDevice8::GetDeviceData. Probably because SetProperty failed earlier. Anyone know what could be wrong?

Share this post


Link to post
Share on other sites
Dave Hunt    4872
Your error checking has gone pear-shaped. You used OR when you meant AND. So, if you get DI_OK, then it won''t equal DI_PROPNOEFFECT, and it will go into your error code.

If you checked the error code and it wasn''t one of the "official" codes, then what was it?

Share this post


Link to post
Share on other sites
eckbw    122
Thanks for the reply. I edited the code slightly when I posted it to make it easier to read and overlooked that ||. The actual error code looks like:

  
if (error != DI_OK)
if (error != DI_DIPROPNOEFFECT)
// error handling



Anyway, it´s still failing but it´s not one of the DIERR_ codes that´s in the DX documentation. I saw now you can set the bufferpropertys with SetActionMap too, I´ll try that instead later.

Share this post


Link to post
Share on other sites
eckbw    122
I think I found it now! I noticed I did the SetProperty() after the lpKeyboard->Acquire(). So I changed that and now SetProperty seem to succeed. It´s always something simple! But GetDeviceData still fails. Well, that´s one problem out of the way.

Share this post


Link to post
Share on other sites