Microsoft DirectX 8.1 (C++) |
Finding Matching Devices
After you define the application actions and the virtual controls or device objects to which these actions are to be mapped, the next step is to enumerate devices on the system to find those that best support the desired virtual controls.
To do so, pass the DIACTIONFORMAT structure to IDirectInput8::EnumDevicesBySemantics. This method works in much the same way as IDirectInput8::EnumDevices and takes a similar callback function.
Devices that have been configured by the user to match certain controls are always enumerated first. For example, if a user has configured a wheel as the primary steering device for driving games, then the wheel is enumerated first whenever devices that support DIAXIS_DRIVINGR_STEER are requested, taking precedence over other capable devices such as joysticks that have not been configured by the user. Otherwise, the order in which available devices are enumerated is determined by the degree to which they match the requested controls. However, the order in which devices are enumerated by Microsoft® DirectInput® is not guaranteed.
In the enumeration callback, you can retrieve the default action mapping for each device, change any mappings you don't like, give the user an opportunity to reconfigure the device, and apply the action map. These steps are covered in Configuring the Action Map. Flags returned in the DIEnumDevicesBySemanticsCallback will provide information about why a particular device was enumerated. These flags will indicate whether a device has been used recently, is newly installed, or will accept mappings of priority 1 or priority 2 controls.