Microsoft DirectX 8.1 (Visual Basic)

Step 5: Displaying the Action Map

In addition to the advantage of action mapping in enabling the developer to define game actions independently of specific controller hardware, action mapping also benefits the user by providing a user interface (UI) for easy reconfiguration.

The UI can be displayed in two forms, text-only or graphics. In addition, each of those two options can be viewed in two modes: view-only or edit.

To display the UI, some preliminary setup is involved. A DICONFIGUREDEVICESPARAMS type is used to hold the property sheet information. DICONFIGUREDEVICESPARAMS contains an array of DIACTIONFORMAT types used for any mappings that have been defined, an array of user names to match to those action maps, and counts for both of the arrays. For this example, only one mapping and one user have been defined above. The initialization of the DICONFIGUREDEVICESPARAMS type is shown in the following sample code.

Dim m_cdParams As DICONFIGUREDEVICESPARAMS

    m_cdParams.ActionFormats(0) = m_diaf
    m_cdParams.FormatCount = 1
    m_cdParams.UserNames(0) = m_strUserName
    m_cdParams.UserCount = 1

Once that structure is initialized, call DirectInput8.ConfigureDevices to display the UI as shown in the following sample code.

    m_DI.ConfigureDevices 0, m_cdParams, DICD_EDIT

All that the sample is passing to ConfigureDevices is the DICONFIGUREDEVICESPARAMS type and a flag indicating that the UI allows user configuration. This is discussed in Step 6: User Configuration of the Action Map.