DirectInput SetProperty()

Started by
3 comments, last by eckbw 20 years, 11 months ago
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?
Advertisement
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?
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.
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.
Ah great, fixed the GetDeviceData error too. Everything´s working fine now!

This topic is closed to new replies.

Advertisement