DirectX SDK

Step 2: Set the Mouse Data Format

[Visual Basic]

The information in this topic pertains only to applications written in C++. See DirectInput Visual Basic Tutorials.

[C++]

After retrieving an IDirectInputDevice7 pointer, your application must set the device's data format. For mouse devices, this is a very simple task. Call the IDirectInputDevice7::SetDataFormat method, specifying the data format provided for your convenience by DirectInput in the c_dfDIMouse global variable.

The following code attempts to set the device's data format. If the call fails, FALSE is returned.

hr = g_pMouse->SetDataFormat(&c_dfDIMouse);
 
if (FAILED(hr)) {
    return FALSE;
}

Next: Step 3: Set the Mouse Behavior