home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / joysti1a / module1.bas < prev    next >
Encoding:
BASIC Source File  |  1998-02-17  |  7.0 KB  |  115 lines

  1. Attribute VB_Name = "Module1"
  2. Option Explicit
  3.  
  4. Public Const MAXPNAMELEN = 32
  5.  
  6. ' The JOYINFOEX user-defined type contains extended information about the joystick position,
  7. ' point-of-view position, and button state.
  8. Type JOYINFOEX
  9.    dwSize As Long                      ' size of structure
  10.    dwFlags As Long                     ' flags to indicate what to return
  11.    dwXpos As Long                      ' x position
  12.    dwYpos As Long                      ' y position
  13.    dwZpos As Long                      ' z position
  14.    dwRpos As Long                      ' rudder/4th axis position
  15.    dwUpos As Long                      ' 5th axis position
  16.    dwVpos As Long                      ' 6th axis position
  17.    dwButtons As Long                   ' button states
  18.    dwButtonNumber As Long              ' current button number pressed
  19.    dwPOV As Long                       ' point of view state
  20.    dwReserved1 As Long                 ' reserved for communication between winmm driver
  21.    dwReserved2 As Long                 ' reserved for future expansion
  22. End Type
  23.  
  24. ' The JOYCAPS user-defined type contains information about the joystick capabilities
  25. Type JOYCAPS
  26.    wMid As Integer                     ' Manufacturer identifier of the device driver for the MIDI output device
  27.                                        ' For a list of identifiers, see the Manufacturer Indentifier topic in the
  28.                                        ' Multimedia Reference of the Platform SDK.
  29.    
  30.    wPid As Integer                     ' Product Identifier Product of the MIDI output device. For a list of
  31.                                        ' product identifiers, see the Product Identifiers topic in the Multimedia
  32.                                        ' Reference of the Platform SDK.
  33.    szPname As String * MAXPNAMELEN     ' Null-terminated string containing the joystick product name
  34.    wXmin As Long                       ' Minimum X-coordinate.
  35.    wXmax As Long                       ' Maximum X-coordinate.
  36.    wYmin As Long                       ' Minimum Y-coordinate
  37.    wYmax As Long                       ' Maximum Y-coordinate
  38.    wZmin As Long                       ' Minimum Z-coordinate
  39.    wZmax As Long                       ' Maximum Z-coordinate
  40.    wNumButtons As Long                 ' Number of joystick buttons
  41.    wPeriodMin As Long                  ' Smallest polling frequency supported when captured by the joySetCapture function.
  42.    wPeriodMax As Long                  ' Largest polling frequency supported when captured by the joySetCapture function.
  43.    wRmin As Long                       ' Minimum rudder value. The rudder is a fourth axis of movement.
  44.    wRmax As Long                       ' Maximum rudder value. The rudder is a fourth axis of movement.
  45.    wUmin As Long                       ' Minimum u-coordinate (fifth axis) values.
  46.    wUmax As Long                       ' Maximum u-coordinate (fifth axis) values.
  47.    wVmin As Long                       ' Minimum v-coordinate (sixth axis) values.
  48.    wVmax As Long                       ' Maximum v-coordinate (sixth axis) values.
  49.    wCaps As Long                       ' Joystick capabilities as defined by the following flags
  50.                                        '     JOYCAPS_HASZ-     Joystick has z-coordinate information.
  51.                                        '     JOYCAPS_HASR-     Joystick has rudder (fourth axis) information.
  52.                                        '     JOYCAPS_HASU-     Joystick has u-coordinate (fifth axis) information.
  53.                                        '     JOYCAPS_HASV-     Joystick has v-coordinate (sixth axis) information.
  54.                                        '     JOYCAPS_HASPOV-   Joystick has point-of-view information.
  55.                                        '     JOYCAPS_POV4DIR-  Joystick point-of-view supports discrete values (centered, forward, backward, left, and right).
  56.                                        '     JOYCAPS_POVCTS Joystick point-of-view supports continuous degree bearings.
  57.    wMaxAxes As Long                    ' Maximum number of axes supported by the joystick.
  58.    wNumAxes As Long                    ' Number of axes currently in use by the joystick.
  59.    wMaxButtons As Long                 ' Maximum number of buttons supported by the joystick.
  60.    szRegKey As String * MAXPNAMELEN    ' String containing the registry key for the joystick.
  61. End Type
  62.  
  63. Declare Function joyGetPosEx Lib "winmm.dll" (ByVal uJoyID As Long, pji As JOYINFOEX) As Long
  64. ' This function queries a joystick for its position and button status. The function
  65. ' requires the following parameters;
  66. '     uJoyID-  integer identifying the joystick to be queried. Use the constants
  67. '              JOYSTICKID1 or JOYSTICKID2 for this value.
  68. '     pji-     user-defined type variable that stores extended position information
  69. '              and button status of the joystick. The information returned from
  70. '              this function depends on the flags you specify in dwFlags member of
  71. '              the user-defined type variable.
  72. '
  73. ' The function returns the constant JOYERR_NOERROR if successful or one of the
  74. ' following error values:
  75. '     MMSYSERR_NODRIVER-      The joystick driver is not present.
  76. '     MMSYSERR_INVALPARAM-    An invalid parameter was passed.
  77. '     MMSYSERR_BADDEVICEID-   The specified joystick identifier is invalid.
  78. '     JOYERR_UNPLUGGED-       The specified joystick is not connected to the system.
  79.  
  80. Declare Function joyGetDevCaps Lib "winmm.dll" Alias "joyGetDevCapsA" (ByVal id As Long, lpCaps As JOYCAPS, ByVal uSize As Long) As Long
  81. ' This function queries a joystick to determine its capabilities. The function requires
  82. ' the following parameters:
  83. '     uJoyID-  integer identifying the joystick to be queried. Use the contstants
  84. '              JOYSTICKID1 or JOYSTICKID2 for this value.
  85. '     pjc-     user-defined type variable that stores the capabilities of the joystick.
  86. '     cbjc-    Size, in bytes, of the pjc variable. Use the Len function for this value.
  87. ' The function returns the constant JOYERR_NOERROR if a joystick is present or one of
  88. ' the following error values:
  89. '     MMSYSERR_NODRIVER-   The joystick driver is not present.
  90. '     MMSYSERR_INVALPARAM- An invalid parameter was passed.
  91.  
  92.  
  93. Public Const JOYSTICKID1 = 0
  94. Public Const JOYSTICKID2 = 1
  95. Public Const JOY_RETURNBUTTONS = &H80&
  96. Public Const JOY_RETURNCENTERED = &H400&
  97. Public Const JOY_RETURNPOV = &H40&
  98. Public Const JOY_RETURNR = &H8&
  99. Public Const JOY_RETURNU = &H10
  100. Public Const JOY_RETURNV = &H20
  101. Public Const JOY_RETURNX = &H1&
  102. Public Const JOY_RETURNY = &H2&
  103. Public Const JOY_RETURNZ = &H4&
  104. Public Const JOY_RETURNALL = (JOY_RETURNX Or JOY_RETURNY Or JOY_RETURNZ Or JOY_RETURNR Or JOY_RETURNU Or JOY_RETURNV Or JOY_RETURNPOV Or JOY_RETURNBUTTONS)
  105. Public Const JOYCAPS_HASZ = &H1&
  106. Public Const JOYCAPS_HASR = &H2&
  107. Public Const JOYCAPS_HASU = &H4&
  108. Public Const JOYCAPS_HASV = &H8&
  109. Public Const JOYCAPS_HASPOV = &H10&
  110. Public Const JOYCAPS_POV4DIR = &H20&
  111. Public Const JOYCAPS_POVCTS = &H40&
  112. Public Const JOYERR_BASE = 160
  113. Public Const JOYERR_UNPLUGGED = (JOYERR_BASE + 7)
  114.  
  115.