[585] | 1 |
|
---|
| 2 | '#require <api_mmsys.sbp>
|
---|
| 3 |
|
---|
| 4 | Namespace ActiveBasic
|
---|
| 5 | Namespace Windows
|
---|
| 6 | Namespace MM
|
---|
| 7 |
|
---|
| 8 |
|
---|
| 9 | Enum JoyCapability
|
---|
| 10 | HasZ = &H0001
|
---|
| 11 | HasR = &H0002
|
---|
| 12 | HasU = &H0004
|
---|
| 13 | HasV = &H0008
|
---|
| 14 | HasPointOfView = &H0010
|
---|
| 15 | PointOfView4Direction = &H0020
|
---|
| 16 | PointOfViewContinuous = &H0040
|
---|
| 17 | End Enum
|
---|
| 18 |
|
---|
| 19 | Class JoyCaps
|
---|
| 20 | caps As JOYCAPS
|
---|
| 21 |
|
---|
| 22 | Protected
|
---|
| 23 | Sub _Initialize ( id As DWord )
|
---|
| 24 | joyGetDevCaps(id,caps,SizeOf(JOYCAPS))
|
---|
| 25 | End Sub
|
---|
| 26 |
|
---|
| 27 | Public
|
---|
| 28 | Function ManufacturerID () As Word
|
---|
| 29 | Return This.caps.wMid
|
---|
| 30 | End Function
|
---|
| 31 | Function ProductID () As Word
|
---|
| 32 | Return This.caps.wPid
|
---|
| 33 | End Function
|
---|
| 34 | Function ProductName () As String
|
---|
| 35 | Return New System.String(This.caps.szPname As LPTSTR)
|
---|
| 36 | End Function
|
---|
| 37 | Function MinimumX () As DWord
|
---|
| 38 | Return This.caps.wXmin
|
---|
| 39 | End Function
|
---|
| 40 | Function MaximumX () As DWord
|
---|
| 41 | Return This.caps.wXmax
|
---|
| 42 | End Function
|
---|
| 43 | Function MinimumY () As DWord
|
---|
| 44 | Return This.caps.wYmin
|
---|
| 45 | End Function
|
---|
| 46 | Function MaximumY () As DWord
|
---|
| 47 | Return This.caps.wYmax
|
---|
| 48 | End Function
|
---|
| 49 | Function MinimumZ () As DWord
|
---|
| 50 | Return This.caps.wZmin
|
---|
| 51 | End Function
|
---|
| 52 | Function MaximumZ () As DWord
|
---|
| 53 | Return This.caps.wZmax
|
---|
| 54 | End Function
|
---|
| 55 | Function NumberOfButtons () As DWord
|
---|
| 56 | Return This.caps.wNumButtons
|
---|
| 57 | End Function
|
---|
| 58 | Function MinimumMessagePeriod () As DWord
|
---|
| 59 | Return This.caps.wPeriodMin
|
---|
| 60 | End Function
|
---|
| 61 | Function MaximumMessagePeriod () As DWord
|
---|
| 62 | Return This.caps.wPeriodMax
|
---|
| 63 | End Function
|
---|
| 64 | Function MinimumR () As DWord
|
---|
| 65 | Return This.caps.wRmin
|
---|
| 66 | End Function
|
---|
| 67 | Function MaximumR () As DWord
|
---|
| 68 | Return This.caps.wRmax
|
---|
| 69 | End Function
|
---|
| 70 | Function MinimumU () As DWord
|
---|
| 71 | Return This.caps.wUmin
|
---|
| 72 | End Function
|
---|
| 73 | Function MaximumU () As DWord
|
---|
| 74 | Return This.caps.wUmax
|
---|
| 75 | End Function
|
---|
| 76 | Function MinimumV () As DWord
|
---|
| 77 | Return This.caps.wVmin
|
---|
| 78 | End Function
|
---|
| 79 | Function MaximumV () As DWord
|
---|
| 80 | Return This.caps.wVmax
|
---|
| 81 | End Function
|
---|
| 82 | Function Capabilities () As JoyCapability
|
---|
| 83 | Return This.caps.wCaps As JoyCapability
|
---|
| 84 | End Function
|
---|
| 85 | Function NumberOfAxesSupported () As DWord
|
---|
| 86 | Return This.caps.wMaxAxes
|
---|
| 87 | End Function
|
---|
| 88 | Function NumberOfAxesUsed () As DWord
|
---|
| 89 | Return This.caps.wNumAxes
|
---|
| 90 | End Function
|
---|
| 91 | Function NumberOfButtonsSupported () As DWord
|
---|
| 92 | Return This.caps.wMaxButtons
|
---|
| 93 | End Function
|
---|
| 94 | Function RegistryKey () As String
|
---|
| 95 | Return New System.String(This.caps.szRegKey As LPTSTR)
|
---|
| 96 | End Function
|
---|
| 97 | Function OEM_VxD () As String
|
---|
| 98 | Return New System.String(This.caps.szOEMVxD As LPTSTR)
|
---|
| 99 | End Function
|
---|
| 100 | End Class
|
---|
| 101 |
|
---|
| 102 | Class JoyButtons
|
---|
| 103 | dwButtons As DWord
|
---|
| 104 |
|
---|
| 105 | Protected
|
---|
| 106 | Sub _Initialize ( dw As DWord )
|
---|
| 107 | This.dwButtons = dw
|
---|
| 108 | End Sub
|
---|
| 109 |
|
---|
| 110 | Public
|
---|
| 111 | Function Button1 () As Boolean
|
---|
| 112 | Return This.Button( 1 )
|
---|
| 113 | End Function
|
---|
| 114 | Function Button2 () As Boolean
|
---|
| 115 | Return This.Button( 2 )
|
---|
| 116 | End Function
|
---|
| 117 | Function Button3 () As Boolean
|
---|
| 118 | Return This.Button( 3 )
|
---|
| 119 | End Function
|
---|
| 120 | Function Button4 () As Boolean
|
---|
| 121 | Return This.Button( 4 )
|
---|
| 122 | End Function
|
---|
| 123 | Function Button5 () As Boolean
|
---|
| 124 | Return This.Button( 5 )
|
---|
| 125 | End Function
|
---|
| 126 | Function Button6 () As Boolean
|
---|
| 127 | Return This.Button( 6 )
|
---|
| 128 | End Function
|
---|
| 129 | Function Button7 () As Boolean
|
---|
| 130 | Return This.Button( 7 )
|
---|
| 131 | End Function
|
---|
| 132 | Function Button8 () As Boolean
|
---|
| 133 | Return This.Button( 8 )
|
---|
| 134 | End Function
|
---|
| 135 | Function Button9 () As Boolean
|
---|
| 136 | Return This.Button( 9 )
|
---|
| 137 | End Function
|
---|
| 138 | Function Button10 () As Boolean
|
---|
| 139 | Return This.Button( 10 )
|
---|
| 140 | End Function
|
---|
| 141 | Function Button11 () As Boolean
|
---|
| 142 | Return This.Button( 11 )
|
---|
| 143 | End Function
|
---|
| 144 | Function Button12 () As Boolean
|
---|
| 145 | Return This.Button( 12 )
|
---|
| 146 | End Function
|
---|
| 147 | Function Button13 () As Boolean
|
---|
| 148 | Return This.Button( 13 )
|
---|
| 149 | End Function
|
---|
| 150 | Function Button14 () As Boolean
|
---|
| 151 | Return This.Button( 14 )
|
---|
| 152 | End Function
|
---|
| 153 | Function Button15 () As Boolean
|
---|
| 154 | Return This.Button( 15 )
|
---|
| 155 | End Function
|
---|
| 156 | Function Button16 () As Boolean
|
---|
| 157 | Return This.Button( 16 )
|
---|
| 158 | End Function
|
---|
| 159 | Function Button17 () As Boolean
|
---|
| 160 | Return This.Button( 17 )
|
---|
| 161 | End Function
|
---|
| 162 | Function Button18 () As Boolean
|
---|
| 163 | Return This.Button( 18 )
|
---|
| 164 | End Function
|
---|
| 165 | Function Button19 () As Boolean
|
---|
| 166 | Return This.Button( 19 )
|
---|
| 167 | End Function
|
---|
| 168 | Function Button20 () As Boolean
|
---|
| 169 | Return This.Button( 20 )
|
---|
| 170 | End Function
|
---|
| 171 | Function Button21 () As Boolean
|
---|
| 172 | Return This.Button( 21 )
|
---|
| 173 | End Function
|
---|
| 174 | Function Button22 () As Boolean
|
---|
| 175 | Return This.Button( 22 )
|
---|
| 176 | End Function
|
---|
| 177 | Function Button23 () As Boolean
|
---|
| 178 | Return This.Button( 23 )
|
---|
| 179 | End Function
|
---|
| 180 | Function Button24 () As Boolean
|
---|
| 181 | Return This.Button( 24 )
|
---|
| 182 | End Function
|
---|
| 183 | Function Button25 () As Boolean
|
---|
| 184 | Return This.Button( 25 )
|
---|
| 185 | End Function
|
---|
| 186 | Function Button26 () As Boolean
|
---|
| 187 | Return This.Button( 26 )
|
---|
| 188 | End Function
|
---|
| 189 | Function Button27 () As Boolean
|
---|
| 190 | Return This.Button( 27 )
|
---|
| 191 | End Function
|
---|
| 192 | Function Button28 () As Boolean
|
---|
| 193 | Return This.Button( 28 )
|
---|
| 194 | End Function
|
---|
| 195 | Function Button29 () As Boolean
|
---|
| 196 | Return This.Button( 29 )
|
---|
| 197 | End Function
|
---|
| 198 | Function Button30 () As Boolean
|
---|
| 199 | Return This.Button( 30 )
|
---|
| 200 | End Function
|
---|
| 201 | Function Button31 () As Boolean
|
---|
| 202 | Return This.Button( 31 )
|
---|
| 203 | End Function
|
---|
| 204 | Function Button32 () As Boolean
|
---|
| 205 | Return This.Button( 32 )
|
---|
| 206 | End Function
|
---|
| 207 |
|
---|
| 208 | Public
|
---|
| 209 | Function Button ( n As DWord ) As Boolean
|
---|
| 210 | Return (1<<(n-1) And This.dwButtons) <> 0
|
---|
| 211 | End Function
|
---|
| 212 |
|
---|
| 213 | Public
|
---|
| 214 | Function Operator () As DWord
|
---|
| 215 | Return This.dwButtons
|
---|
| 216 | End Function
|
---|
| 217 |
|
---|
| 218 | Function Operator== (dw As DWord) As Boolean
|
---|
| 219 | Return This.dwButtons = dw
|
---|
| 220 | End Function
|
---|
| 221 | Function Operator And (dw As DWord) As Boolean
|
---|
| 222 | Return (This.dwButtons And dw) <> 0
|
---|
| 223 | End Function
|
---|
| 224 |
|
---|
| 225 | End Class
|
---|
| 226 |
|
---|
| 227 | Class JoyPointOfView
|
---|
| 228 | dwPOV As DWord
|
---|
| 229 |
|
---|
| 230 | Protected
|
---|
| 231 | Sub _Initialize ( dw As DWord )
|
---|
| 232 | If LOWORD(dw) = &HFFFF Then dw = -1
|
---|
| 233 | This.dwPOV = dw
|
---|
| 234 | End Sub
|
---|
| 235 |
|
---|
| 236 | Public
|
---|
| 237 | Static Const Centered = (-1) As DWord
|
---|
| 238 | Static Const Forward = 0 As DWord
|
---|
| 239 | Static Const ForwardAndRight = 4500 As DWord
|
---|
| 240 | Static Const Right = 9000 As DWord
|
---|
| 241 | Static Const BackwardAndRight = 13500 As DWord
|
---|
| 242 | Static Const Backward = 18000 As DWord
|
---|
| 243 | Static Const BackwardAndLeft = 22500 As DWord
|
---|
| 244 | Static Const Left = 27000 As DWord
|
---|
| 245 | Static Const ForwardAndLeft = 31500 As DWord
|
---|
| 246 |
|
---|
| 247 | Public
|
---|
| 248 | Function Operator () As DWord
|
---|
| 249 | Return This.dwPOV
|
---|
| 250 | End Function
|
---|
| 251 |
|
---|
| 252 | Function Operator== (value As DWord) As Boolean
|
---|
| 253 | Return This.dwPOV = value
|
---|
| 254 | End Function
|
---|
| 255 | Function Operator<> ( value As DWord) As Boolean
|
---|
| 256 | Return This.dwPOV <> value
|
---|
| 257 | End Function
|
---|
| 258 | Function Operator<= ( value As DWord) As Boolean
|
---|
| 259 | Return This.dwPOV <= value
|
---|
| 260 | End Function
|
---|
| 261 | Function Operator>= ( value As DWord) As Boolean
|
---|
| 262 | Return This.dwPOV >= value
|
---|
| 263 | End Function
|
---|
| 264 | Function Operator< ( value As DWord) As Boolean
|
---|
| 265 | Return This.dwPOV < value
|
---|
| 266 | End Function
|
---|
| 267 | Function Operator> ( value As DWord) As Boolean
|
---|
| 268 | Return This.dwPOV > value
|
---|
| 269 | End Function
|
---|
| 270 |
|
---|
| 271 | Function Operator== ( value As JoyPointOfView ) As Boolean
|
---|
| 272 | Return This = value As DWord
|
---|
| 273 | End Function
|
---|
| 274 | Function Operator<> ( value As JoyPointOfView ) As Boolean
|
---|
| 275 | Return This <> value As DWord
|
---|
| 276 | End Function
|
---|
| 277 | Function Operator<= ( value As JoyPointOfView ) As Boolean
|
---|
| 278 | Return This <= value As DWord
|
---|
| 279 | End Function
|
---|
| 280 | Function Operator>= ( value As JoyPointOfView ) As Boolean
|
---|
| 281 | Return This >= value As DWord
|
---|
| 282 | End Function
|
---|
| 283 | Function Operator< ( value As JoyPointOfView ) As Boolean
|
---|
| 284 | Return This < value As DWord
|
---|
| 285 | End Function
|
---|
| 286 | Function Operator> ( value As JoyPointOfView ) As Boolean
|
---|
| 287 | Return This > value As DWord
|
---|
| 288 | End Function
|
---|
| 289 | End Class
|
---|
| 290 |
|
---|
| 291 | Class JoyInfo
|
---|
| 292 | info As JOYINFOEX
|
---|
| 293 |
|
---|
| 294 | Protected
|
---|
| 295 | Sub _Initialize ( id As DWord )
|
---|
| 296 | This.info.dwSize = SizeOf(JOYINFOEX)
|
---|
| 297 | This.info.dwFlags = JOY_RETURNALL
|
---|
| 298 | joyGetPosEx(id,info)
|
---|
| 299 | End Sub
|
---|
| 300 |
|
---|
| 301 | Public
|
---|
| 302 | Function X () As DWord
|
---|
| 303 | Return This.info.dwXpos
|
---|
| 304 | End Function
|
---|
| 305 | Function Y () As DWord
|
---|
| 306 | Return This.info.dwYpos
|
---|
| 307 | End Function
|
---|
| 308 | Function Z () As DWord
|
---|
| 309 | Return This.info.dwZpos
|
---|
| 310 | End Function
|
---|
| 311 | Function R () As DWord
|
---|
| 312 | Return This.info.dwRpos
|
---|
| 313 | End Function
|
---|
| 314 | Function U () As DWord
|
---|
| 315 | Return This.info.dwUpos
|
---|
| 316 | End Function
|
---|
| 317 | Function V () As DWord
|
---|
| 318 | Return This.info.dwVpos
|
---|
| 319 | End Function
|
---|
| 320 | Function Buttons () As JoyButtons
|
---|
| 321 | Return New Detail._System_JoyButtons(This.info.dwButtons)
|
---|
| 322 | End Function
|
---|
| 323 | Function ButtonNumber () As DWord
|
---|
| 324 | Return This.info.dwButtonNumber
|
---|
| 325 | End Function
|
---|
| 326 | Function PointOfView () As JoyPointOfView
|
---|
| 327 | Return New Detail._System_JoyPointOfView(This.info.dwPOV)
|
---|
| 328 | End Function
|
---|
| 329 | End Class
|
---|
| 330 |
|
---|
| 331 | Class Joystick
|
---|
| 332 | id As DWord
|
---|
| 333 |
|
---|
| 334 | Protected
|
---|
| 335 | Sub _Initialize ( id As DWord )
|
---|
| 336 | This.id = id
|
---|
| 337 | End Sub
|
---|
| 338 |
|
---|
| 339 | Public
|
---|
| 340 | Sub Threshold ( value As DWord )
|
---|
| 341 | joySetThreshold(id,value)
|
---|
| 342 | End Sub
|
---|
| 343 | Function Threshold () As DWord
|
---|
| 344 | joyGetThreshold(id,VarPtr(Threshold))
|
---|
| 345 | End Function
|
---|
| 346 |
|
---|
| 347 | Public
|
---|
| 348 | Function GetCapabilities () As JoyCaps
|
---|
| 349 | Return New Detail._System_JoyCaps(This.id)
|
---|
| 350 | End Function
|
---|
| 351 | Function GetInfo() As JoyInfo
|
---|
| 352 | Return New Detail._System_JoyInfo(This.id)
|
---|
| 353 | End Function
|
---|
| 354 |
|
---|
| 355 | Public
|
---|
| 356 | Sub SetCupture ( hwnd As HWND, period As DWord, changed As Boolean)
|
---|
| 357 | joySetCapture(hwnd,id,period,changed)
|
---|
| 358 | End Sub
|
---|
| 359 | Sub ReleaseCapture()
|
---|
| 360 | joyReleaseCapture(id)
|
---|
| 361 | End Sub
|
---|
| 362 | End Class
|
---|
| 363 |
|
---|
| 364 | Class Joysticks
|
---|
| 365 |
|
---|
| 366 | Public
|
---|
| 367 | Static Function NumberOfDevices () As DWord
|
---|
| 368 | Return joyGetNumDevs()
|
---|
| 369 | End Function
|
---|
| 370 | Static Function NumberOfConnectedDevices () As DWord
|
---|
| 371 | Dim max = Joysticks.NumberOfDevices()
|
---|
| 372 | Dim cnt=0 As DWord
|
---|
| 373 | Dim info As JOYINFO
|
---|
| 374 | While joyGetPos(cnt,info) = JOYERR_NOERROR
|
---|
| 375 | cnt++
|
---|
| 376 | If cnt >= max Then Exit While
|
---|
| 377 | Wend
|
---|
| 378 | Return cnt
|
---|
| 379 | End Function
|
---|
| 380 |
|
---|
| 381 | Static Function GetJoysticks() As System.Collections.Generic.List<Joystick>
|
---|
| 382 | Dim list As System.Collections.Generic.List<Joystick>
|
---|
| 383 | Dim cnt As DWord
|
---|
| 384 | For cnt=0 To NumberOfConnectedDevices() - 1
|
---|
| 385 | list.Add(Joysticks.GetJoystick(cnt))
|
---|
| 386 | Next
|
---|
| 387 | Return list
|
---|
| 388 | End Function
|
---|
| 389 |
|
---|
| 390 | Static Function GetJoystick( id As DWord ) As Joystick
|
---|
| 391 | Return New Detail._System_Joystick(id)
|
---|
| 392 | End Function
|
---|
| 393 |
|
---|
| 394 | End Class
|
---|
| 395 |
|
---|
| 396 | Namespace Detail
|
---|
| 397 | Class _System_JoyCaps
|
---|
| 398 | Inherits JoyCaps
|
---|
| 399 | Public
|
---|
| 400 | Sub _System_JoyCaps ( id As DWord )
|
---|
| 401 | This._Initialize(id)
|
---|
| 402 | End Sub
|
---|
| 403 |
|
---|
| 404 | Override Function ToString () As String
|
---|
| 405 | Return "JoyCaps"
|
---|
| 406 | End Function
|
---|
| 407 | End Class
|
---|
| 408 |
|
---|
| 409 | Class _System_JoyButtons
|
---|
| 410 | Inherits JoyButtons
|
---|
| 411 | Public
|
---|
| 412 | Sub _System_JoyButtons ( dw As DWord )
|
---|
| 413 | This._Initialize(dw)
|
---|
| 414 | End Sub
|
---|
| 415 |
|
---|
| 416 | Override Function ToString () As String
|
---|
| 417 | Return "JoyButtons"
|
---|
| 418 | End Function
|
---|
| 419 | End Class
|
---|
| 420 |
|
---|
| 421 | Class _System_JoyPointOfView
|
---|
| 422 | Inherits JoyPointOfView
|
---|
| 423 | Public
|
---|
| 424 | Sub _System_JoyPointOfView ( dw As DWord )
|
---|
| 425 | This._Initialize(dw)
|
---|
| 426 | End Sub
|
---|
| 427 |
|
---|
| 428 | Override Function ToString () As String
|
---|
| 429 | Return "JoyPointOfView"
|
---|
| 430 | End Function
|
---|
| 431 | End Class
|
---|
| 432 |
|
---|
| 433 | Class _System_JoyInfo
|
---|
| 434 | Inherits JoyInfo
|
---|
| 435 | Public
|
---|
| 436 | Sub _System_JoyInfo ( id As DWord )
|
---|
| 437 | This._Initialize(id)
|
---|
| 438 | End Sub
|
---|
| 439 |
|
---|
| 440 | Override Function ToString () As String
|
---|
| 441 | Return "JoyInfo"
|
---|
| 442 | End Function
|
---|
| 443 | End Class
|
---|
| 444 |
|
---|
| 445 | Class _System_Joystick
|
---|
| 446 | Inherits Joystick
|
---|
| 447 | Public
|
---|
| 448 | Sub _System_Joystick ( id As DWord )
|
---|
| 449 | This._Initialize(id)
|
---|
| 450 | End Sub
|
---|
| 451 |
|
---|
| 452 | Override Function ToString () As String
|
---|
| 453 | Return "Joystick"
|
---|
| 454 | End Function
|
---|
| 455 | End Class
|
---|
| 456 |
|
---|
| 457 | End Namespace
|
---|
| 458 |
|
---|
| 459 | End Namespace
|
---|
| 460 | End Namespace
|
---|
| 461 | End Namespace
|
---|