Platform SDK: DirectX

IDirectInput7::EnumDevices

The IDirectInput7::EnumDevice method enumerates devices that are either currently attached or could be attached to the computer.

HRESULT EnumDevices(
  DWORD dwDevType,              
  LPDIENUMCALLBACK lpCallback,  
  LPVOID pvRef,                 
  DWORD dwFlags                 
);

Parameters

dwDevType
Device type filter. If this parameter is 0, all device types are enumerated. Otherwise, it is a DIDEVTYPE_* value (see DIDEVICEINSTANCE), indicating the device type that should be enumerated.
lpCallback
Address of a callback function to be called with a description of each DirectInput device.
pvRef
Application-defined 32-bit value to be passed to the enumeration callback each time it is called.
dwFlags
Flag value that specifies the scope of the enumeration. This parameter can be one or more of the following values:
DIEDFL_ALLDEVICES
All installed devices are enumerated. This is the default behavior.
DIEDFL_ATTACHEDONLY
Only attached and installed devices.
DIEDFL_FORCEFEEDBACK
Only devices that support force feedback.
DIEDFL_INCLUDEALIASES
Include devices that are aliases for other devices.
DIEDFL_INCLUDEPHANTOMS
Include phantom (placeholder) devices.

Return Values

If the method succeeds, the return value is DI_OK.

If the method fails, the return value can be one of the following error values:

DIERR_INVALIDPARAM
DIERR_NOTINITIALIZED

Remarks

All installed devices can be enumerated, even if they are not present. For example, a flight stick might be installed on the system, but not currently plugged into the computer. Set the dwFlags parameter to indicate whether only attached or all installed devices should be enumerated. If the DIEDFL_ATTACHEDONLY flag is not present, all installed devices are enumerated.

A preferred device type can be passed as a dwDevType filter so that only the devices of that type are enumerated.

The lpCallback parameter specifies the address of a callback function of the type documented as DIEnumDevicesCallback. DirectInput calls this function for every device that is enumerated. In the callback, the device type and friendly name, and the product GUID and friendly name, are given for each device. If a single input device can function as more than one DirectInput device type, it is returned for each device type that it supports. For example, a keyboard with a built-in mouse is enumerated as a keyboard and as a mouse. The product GUID would be the same for each device, however.

Requirements

  Windows NT/2000: Requires Windows 2000.
  Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
  Header: Declared in dinput.h.
  Import Library: Use dinput.lib.