Microsoft DirectX 8.1 (C++) |
Now that the application has a pointer to a Microsoft® DirectInput® device, it can call the IDirectInputDevice8 methods to manipulate that device. The first step, which is essential, is to set the data format for the joystick. This step tells DirectInput how to format the input data.
if (FAILED(hr = g_pJoystick->SetDataFormat(&c_dfDIJoystick2))) return hr;
The IDirectInputDevice8::SetDataFormat method takes one parameter, a pointer to a DIDATAFORMAT structure containing information about how the data for the device is to be formatted. For the joystick, you can use the predefined global variable c_dfDIJoystick2, which signifies use of the DIJOYSTATE2 structure to retrieve data.
After setting the joystick data format, go to Step 4: Setting the Joystick Behavior.