#### Archived

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

# DirectInput SetProperty()

This topic is 5507 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have a problem with IDirectInputDevice8::SetProperty. It just fails everytime. Here´s the code:

DIPROPDWORD prop;
prop.diph.dwSize = sizeof(DIPROPDWORD);
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 on other sites
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 on other sites
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 on other sites
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 on other sites
Ah great, fixed the GetDeviceData error too. Everything´s working fine now!

• 10
• 17
• 9
• 14
• 41