Click to Rate and Give Feedback
MSDN
MSDN Library
DirectX
SDK Documentation
DirectX Input
DirectInput
Tutorials
 Step 1: Enumerating the Joysticks

  Switch on low bandwidth view
Step 1: Enumerating the Joysticks
Bb206128.XDK_CHM_BANNER_left(en-us,VS.85).jpgBb206128.XDK_CHM_BANNER_right(en-us,VS.85).jpg

Step 1: Enumerating the Joysticks

After creating the DirectInput system, call the IDirectInput8::EnumDevices method to enumerate the joysticks, as in the following sample code.

//g_pDI is an initialized pointer to IDirectInput8
g_pDI->EnumDevices(DI8DEVCLASS_GAMECTRL, EnumJoysticksCallback,
                       NULL, DIEDFL_ATTACHEDONLY)

The DI8DEVCLASS_GAMECTRL constant, passed as the first parameter, specifies the class of device to be enumerated.

EnumJoysticksCallback is the address of a callback function to be called each time a joystick is found. This is where the individual devices are created in Step 2: Creating the DirectInput Joystick Device.

The third parameter can be any 32-bit value that you want to make available to the callback function. In this case, nothing is being sent.

The last parameter, DIEDFL_ATTACHEDONLY, is a flag that restricts enumeration to devices that are attached to the computer.

When your application can enumerate the joysticks, go to Step 2: Creating the DirectInput Joystick Device.

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker