DirectX SDK |
The information in this topic pertains only to applications written in C++. See DirectInput Visual Basic Tutorials.
After retrieving an IDirectInputDevice7 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 IDirectInputDevice7::SetDataFormat method, specifying the data format provided for your convenience by 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; }