Microsoft DirectX 8.1 (C++) |
Describes a device object's data format for use with the IDirectInputDevice8::SetDataFormat method.
typedef struct DIOBJECTDATAFORMAT { const GUID * pguid; DWORD dwOfs; DWORD dwType; DWORD dwFlags; } DIOBJECTDATAFORMAT, *LPDIOBJECTDATAFORMAT; typedef const DIOBJECTDATAFORMAT *LPCDIOBJECTDATAFORMAT;
A data format is made up of several DIOBJECTDATAFORMAT structures, one for each object (axis, button, and so on). An array of these structures is contained in the DIDATAFORMAT structure that is passed to IDirectInputDevice8::SetDataFormat. An application typically does not need to create an array of DIOBJECTDATAFORMAT structures; rather, it can use one of the predefined data formats, c_dfDIMouse, c_dfDIMouse2, c_dfDIKeyboard, c_dfDIJoystick, or c_dfDIJoystick2, which have predefined settings for DIOBJECTDATAFORMAT.
The following object data format specifies that Microsoft® DirectInput® should choose the first available axis and report its value in the DWORD at offset 4 in the device data.
DIOBJECTDATAFORMAT dfAnyAxis = { 0, // Wildcard 4, // Offset DIDFT_AXIS | DIDFT_ANYINSTANCE, // Any axis is okay. 0, // Ignore aspect };
The following object data format specifies that the x-axis of the device should be stored in the DWORD at offset 12 in the device data. If the device has more than one x-axis, the first available one should be selected.
DIOBJECTDATAFORMAT dfAnyXAxis = { &GUID_XAxis, // Must be an X axis 12, // Offset DIDFT_AXIS | DIDFT_ANYINSTANCE, // Any X axis is okay. 0, // Ignore aspect };
The following object data format specifies that DirectInput should choose the first available button and report its value in the high bit of the byte at offset 16 in the device data.
DIOBJECTDATAFORMAT dfAnyButton = { 0, // Wildcard 16, // Offset DIDFT_BUTTON | DIDFT_ANYINSTANCE, // Any button is okay. 0, // Ignore aspect };
The following object data format specifies that button 0 of the device should be reported as the high bit of the byte stored at offset 18 in the device data.
If the device does not have a button 0, the attempt to set this data format fails.
DIOBJECTDATAFORMAT dfButton0 = { 0, // Wildcard 18, // Offset DIDFT_BUTTON | DIDFT_MAKEINSTANCE(0), // Button zero 0, // Ignore aspect };
Windows NT/2000/XP: Requires Windows 2000.
Windows 98/Me: Requires Windows 98 or later. Available as a redistributable for Windows 98.
Header: Declared in Dinput.h.