- J -


joyGetDevCaps Function

Declare Function joyGetDevCaps Lib "winmm.dll" Alias "joyGetDevCapsA" (ByVal id As Long, ByVal lpCaps As JOYCAPS, ByVal uSize As Long) As Long

joyGetDevCaps reads various information about a joystick. This information is put into lpCaps. This is not to be confused with getting the current status of the joystick. The return value is an error code. If it is zero, the joystick is connected and in working order.
idThe ID # of the joystick to read. Windows 95 starts counting joysticks at 0, so Joystick 1's ID is 0, Joystick 2's ID is 1, etc.
lpCapsReceives the information about the joystick.
uSizeThe length in bytes of lpCaps (use the Len function).
Example:
  'Check to see if Joystick 1 is connected
  DIM cap As JOYCAPS
  x = joyGetDevCaps(0, cap, Len(cap))
  If x = 0 Then Debug.Print "Joystick 1 is in full working order."


Category: Joystick
Back to the index.


joyGetNumDevs Function

Declare Function joyGetNumDevs Lib "winmm.dll" () As Long

joyGetNumDevs returns the number of configured joysticks under the Windows 95 Control Panel. This doesn't mean that all of them are in working order, just that there are that many possible. To test if the joystick works, poll for input and check the error code.

Example:
  'Look for the number of configured joysticks
  num_joysticks = joyGetNumDevs()


Category: Joystick
Back to the index.


joyGetPos Function

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

joyGetPos reads the current position of the joystick. This information is put into pji. The value returned is an error code. If it is zero, the joystick is connected and in working order.
uJoyIDThe ID # of the joystick to read. Windows 95 starts counting joysticks at 0, so Joystick 1's ID is 0, Joystick 2's ID is 1, etc.
pjiReceives the joystick's current position.
Example:
  'Read the x and y coordinates
  Dim pos As JOYINFO
  x = joyGetPos(0, pos)
  Debug.Print pos.wXpos, pos.wYpos


Category: Joystick
Back to the index.


Home
Paul Kuliniewicz
E-mail: Borg953@aol.com
All material presented on these pages is Copyright © Paul Kuliniewicz, except for other copyrighted material.
http://members.aol.com/Borg953/api/j.html