Condividi tramite


Effect Object Enumeration

When you need to examine or manipulate all the effects you have created, you can use the IDirectInputDevice8::EnumCreatedEffectObjects method. As no flags are currently defined for this method, you cannot restrict the enumeration to particular kinds of effects; all effects will be enumerated.

Note

This method enumerates created effects, not effects supported by a device. For more information about the distinction between the two, see Effect Enumeration.

Like other DirectInput enumerations, the IDirectInputDevice8::EnumCreatedEffectObjects method requires a callback function. This standard callback is documented with the placeholder name DIEnumCreatedEffectObjectsCallback, but you can use a different name. The function is called for each effect enumerated. Within the function, you can perform any processing you want. However, it is not safe to create a new effect while enumeration is going on.

The following is a skeletal example of the callback function. The pvRef parameter of the callback can be any 32-bit value; in this case, it is a pointer to the IDirectInputDevice8 Interface interface that is performing the enumeration.

HRESULT  hr;

BOOL CALLBACK DIEnumCreatedEffectObjectsCallback(
                             LPDIRECTINPUTEFFECT peff, LPVOID pvRef);
{
    LPDIRECTINPUTDEVICE pdid = (IDirectInputDevice*)pvRef;  
                                        // Pointer to calling device
    DIEFFECT            diEffect;      // Params for created effect

    diEffect.dwSize = sizeof(DIEffectInfo);
    peff->GetParameters(&diEffect, DIEP_ALLPARAMS);
    // Check or set parameters, or do anything else.
    .
    .
    .
    }  // End of callback

Here's the call that sets the enumeration in motion, passing in the DirectInputDevice pointer lpdid:

hr = lpdid->EnumCreatedEffectObjects(           
         &DIEnumCreatedEffectObjectsCallback,
         &lpdid, 0);