Microsoft DirectX 8.1 (C++) |
After retrieving an IDirectInputDevice8 pointer, your application must set the device's data format, as shown in Sample Function 1: DI_Init. For keyboards, this is a very simple task. Call the IDirectInputDevice8::SetDataFormat method, specifying the data format provided by Microsoft® DirectInput® in the c_dfDIKeyboard global variable.
The following example attempts to set the data format. If this fails, it calls the DI_Term sample function to deallocate existing DirectInput objects, if any.
hr = g_lpDIDevice->SetDataFormat(&c_dfDIKeyboard); if FAILED(hr) { DI_Term(); return FALSE; }
After setting the keyboard data format, go to Step 4: Setting the Keyboard Behavior.