Microsoft DirectX 8.1 (Visual Basic)

Immediate Joystick Data

To retrieve the current state of the joystick, call the DirectInputDevice8.GetDeviceStateJoystick or the DirectInputDevice8.GetDeviceStateJoystick2 method, depending on whether the data format was set with DIFORMAT_JOYSTICK or DIFORMAT_JOYSTICK2. (See Device Data Formats.) The joystick state returned in the state parameter includes the coordinates of the axes, the state of the buttons, and the state of the point-of-view controllers.

The POV member of the DIJOYSTATE or the DIJOYSTATE2 type contains the position of up to four point-of-view controllers in hundredths of a degree clockwise from north (or forward). The center position is reported as –1. For controllers that have only five positions, the position is one of the following values:

Some drivers report a value of 65,535, instead of –1, for the neutral position. You should check for a centered POV indicator as follows:

Dim POVCentered As Boolean
POVCentered = MyDijoystate.POV(0) And &HFFFF

The buttons member is an array of bytes, one for each of 32 or 128 buttons, depending on the data type. For each button, the high bit is set if the button is down, and it is clear if the button is up or not present.

The DIJOYSTATE2 type has additional members for information about the velocity, acceleration, force, and torque of the axes.

For more information, see Interpreting Joystick Axis Data.

See also

Buffered and Immediate Data