# joyGetPos Function

`Declare Function joyGetPos Lib "winmm.dll" (ByVal uJoyID As Long, pji As JOYINFO) As Long`

joyGetPos reads the current position and status of a joystick. This information is put into the variable passed as pji. The function returns 0 if the joystick is connected and working, or a non-zero value if it is not.

uJoyID
  The ID number of the joystick to read, starting at 0.
pji
  Variable that receives the joystick's current position and status.

Example:

    ' Read the joystick's x and y coordinates
    Dim pos As JOYINFO
    x = joyGetPos(0, pos)
    Debug.Print "Coordinates:" pos.wXpos; pos.wYpos

Category: Joysticks
Back to the index.