?/TD>
Microsoft DirectX 9.0

IDirectInputDevice8::GetDeviceState Method


Retrieves immediate data from the device.

Syntax

HRESULT GetDeviceState(      

    DWORD cbData,     LPVOID lpvData );

Parameters

cbData
Size of the buffer in the lpvData parameter, in bytes.
lpvData
Address of a structure that receives the current state of the device. The format of the data is established by a prior call to the IDirectInputDevice8::SetDataFormat method.

Return Value

If the method succeeds, the return value is DI_OK.

If the method fails, the return value can be one of the following error values:

DIERR_INPUTLOSTAccess to the input device has been lost. It must be reacquired.
DIERR_INVALIDPARAMAn invalid parameter was passed to the returning function, or the object was not in a state that permitted the function to be called. This value is equal to the E_INVALIDARG standard Component Object Model (COM) return value.
DIERR_NOTACQUIREDThe operation cannot be performed unless the device is acquired.
DIERR_NOTINITIALIZEDThe object has not been initialized.
E_PENDINGData is not yet available.


Remarks

Before device data can be obtained, set the cooperative level by using the IDirectInputDevice8::SetCooperativeLevel method, then set the data format by using IDirectInputDevice8::SetDataFormat, and acquire the device by using the IDirectInputDevice8::Acquire method.

The five predefined data formats require corresponding device state structures according to the following table:

Data formatState structure
c_dfDIMouseDIMOUSESTATE
c_dfDIMouse2DIMOUSESTATE2
c_dfDIKeyboardarray of 256 bytes
c_dfDIJoystickDIJOYSTATE
c_dfDIJoystick2DIJOYSTATE2

For example, if you passed the c_dfDIMouse format to the IDirectInputDevice8::SetDataFormat method, you must pass a DIMOUSESTATE structure to the IDirectInputDevice8::GetDeviceState method.

See Also

IDirectInputDevice8::Poll, Polling and Event Notification, Buffered and Immediate Data


© 2002 Microsoft Corporation. All rights reserved.