The DIDATAFORMAT structure carries information describing a device's data format. This structure is used with the IDirectInputDevice::SetDataFormat method.
typedef struct {
DWORD dwSize;
DWORD dwObjSize;
DWORD dwFlags;
DWORD dwDataSize;
DWORD dwNumObjs;
LPDIOBJECTDATAFORMAT rgodf;
} DIDATAFORMAT, *LPDIDATAFORMAT;
typedef const DIDATAFORMAT *LPCDIDATAFORMAT;
DIDF_ABSAXIS | |
The axes are in absolute mode. Setting this flag in the data format is equivalent to manually setting the axis mode property using the IDirectInputDevice::SetProperty method. This may not be combined with DIDF_RELAXIS flag. | |
DIDF_RELAXIS | |
The axes are in relative mode. Setting this flag in the data format is equivalent to manually setting the axis mode property using the IDirectInputDevice::SetProperty method. This may not be combined with the DIDF_ABSAXIS flag. |
Applications do not typically need to create a DIDATAFORMAT structure. An application can use one of the predefined global data format variables, c_dfDIMouse, c_dfDIKeyboard, c_dfDIJoystick, or c_dfDIJoystick2.
The following declarations set a data format that can be used by applications that need two axes (reported in absolute coordinates) and two buttons.
// Suppose an application uses the following
// structure to read device data.
typedef struct MYDATA {
LONG lX; // x-axis goes here
LONG lY; // y-axis goes here
BYTE bButtonA; // One button goes here
BYTE bButtonB; // Another button goes here
BYTE bPadding[2]; // Must be dword multiple in size
} MYDATA;
// Then it can use the following data format.
DIOBJECTDATAFORMAT rgodf[ ] = {
{ &GUID_XAxis, FIELD_OFFSET(MYDATA, lX),
DIDFT_AXIS | DIDFT_ANYINSTANCE, 0, },
{ &GUID_YAxis, FIELD_OFFSET(MYDATA, lY),
DIDFT_AXIS | DIDFT_ANYINSTANCE, 0, },
{ &GUID_Button, FIELD_OFFSET(MYDATA, bButtonA),
DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0, },
{ &GUID_Button, FIELD_OFFSET(MYDATA, bButtonB),
DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0, },
};
#define numObjects (sizeof(rgodf) / sizeof(rgodf[0]))
DIDATAFORMAT df = {
sizeof(DIDATAFORMAT), // this structure
sizeof(DIOBJECTDATAFORMAT), // size of object data format
DIDF_ABSAXIS, // absolute axis coordinates
sizeof(MYDATA), // device data size
numObjects, // number of objects
rgodf, // and here they are
};
Windows NT: Use version 5.0 or later.
Windows: Use Windows 95 or later. Available as a redistributable for Windows 95.
Windows CE: Unsupported.
Header: Declared in dinput.h.