Changeset 594
- Timestamp:
- Aug 16, 2008, 2:15:42 AM (16 years ago)
- Location:
- trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/MM
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/MM/Joystick.ab
r585 r594 6 6 Namespace MM 7 7 8 8 'ジョイスティックの構成を表す列挙体 9 9 Enum JoyCapability 10 'ジョイスティックはZ軸情報を所有 10 11 HasZ = &H0001 12 'ジョイスティックはR軸情報を所有 11 13 HasR = &H0002 14 'ジョイスティックはU軸情報を所有 12 15 HasU = &H0004 16 'ジョイスティックはV軸情報を所有 13 17 HasV = &H0008 18 'ジョイスティックはPoint of View情報を所有 14 19 HasPointOfView = &H0010 20 'ジョイスティックは4方向Point of Viewサポート 15 21 PointOfView4Direction = &H0020 22 'ジョイスティックは連続した角度のPoint of Viewをサポート 16 23 PointOfViewContinuous = &H0040 17 24 End Enum 18 25 26 27 'ジョイスティックの性能を取得するためのJOYCAPS構造体のラップクラス 19 28 Class JoyCaps 20 29 caps As JOYCAPS … … 25 34 End Sub 26 35 27 Public 36 Public 'Property 37 '製造業者IDの取得 28 38 Function ManufacturerID () As Word 29 39 Return This.caps.wMid 30 40 End Function 41 42 '製品IDの取得 31 43 Function ProductID () As Word 32 44 Return This.caps.wPid 33 45 End Function 46 47 '製品名の取得 34 48 Function ProductName () As String 35 49 Return New System.String(This.caps.szPname As LPTSTR) 36 50 End Function 51 52 'X軸の最小値の取得 37 53 Function MinimumX () As DWord 38 54 Return This.caps.wXmin 39 55 End Function 56 57 'X軸の最大値の取得 40 58 Function MaximumX () As DWord 41 59 Return This.caps.wXmax 42 60 End Function 61 62 'Y軸の最小値の取得 43 63 Function MinimumY () As DWord 44 64 Return This.caps.wYmin 45 65 End Function 66 67 'Y軸の最大値の取得 46 68 Function MaximumY () As DWord 47 69 Return This.caps.wYmax 48 70 End Function 71 72 'Z軸の最小値の取得 49 73 Function MinimumZ () As DWord 50 74 Return This.caps.wZmin 51 75 End Function 76 77 'Z軸の最大値の取得 52 78 Function MaximumZ () As DWord 53 79 Return This.caps.wZmax 54 80 End Function 81 82 ' 55 83 Function NumberOfButtons () As DWord 56 84 Return This.caps.wNumButtons 57 85 End Function 58 Function MinimumMessagePeriod () As DWord 86 87 'キャプチャ時のメッセージ送信間隔の最小値の取得 88 Function MinimumPeriod () As DWord 59 89 Return This.caps.wPeriodMin 60 90 End Function 61 Function MaximumMessagePeriod () As DWord 91 92 'キャプチャ時のメッセージ送信間隔の最大値の取得 93 Function MaximumPeriod () As DWord 62 94 Return This.caps.wPeriodMax 63 95 End Function 96 97 '4軸目であるラダー(R軸)の最小値の取得 64 98 Function MinimumR () As DWord 65 99 Return This.caps.wRmin 66 100 End Function 101 102 '4軸目であるラダー(R軸)の最大値の取得 67 103 Function MaximumR () As DWord 68 104 Return This.caps.wRmax 69 105 End Function 106 107 '5軸目であるU軸の最小値の取得 70 108 Function MinimumU () As DWord 71 109 Return This.caps.wUmin 72 110 End Function 111 112 '5軸目であるU軸の最大値の取得 73 113 Function MaximumU () As DWord 74 114 Return This.caps.wUmax 75 115 End Function 116 117 '6軸目であるV軸の最小値の取得 76 118 Function MinimumV () As DWord 77 119 Return This.caps.wVmin 78 120 End Function 121 122 '6軸目であるV軸の最大値の取得 79 123 Function MaximumV () As DWord 80 124 Return This.caps.wVmax 81 125 End Function 126 127 'ジョイスティックの構成を取得 82 128 Function Capabilities () As JoyCapability 83 129 Return This.caps.wCaps As JoyCapability 84 130 End Function 85 Function NumberOfAxesSupported () As DWord 131 132 'サポートしている動きの軸の数を取得 133 Function NumberOfSupportedAxes () As DWord 86 134 Return This.caps.wMaxAxes 87 135 End Function 88 Function NumberOfAxesUsed () As DWord 136 137 '実際に使用している動きの軸の数を取得 138 Function NumberOfUsedAxes () As DWord 89 139 Return This.caps.wNumAxes 90 140 End Function 91 Function NumberOfButtonsSupported () As DWord 141 142 'サポートしているボタン数を取得 143 Function NumberOfSupportedButtons () As DWord 92 144 Return This.caps.wMaxButtons 93 145 End Function 146 147 '登録キーを文字列の取得 94 148 Function RegistryKey () As String 95 149 Return New System.String(This.caps.szRegKey As LPTSTR) 96 150 End Function 151 152 'OEMジョイスティックドライバを特定する文字列の取得 97 153 Function OEM_VxD () As String 98 154 Return New System.String(This.caps.szOEMVxD As LPTSTR) … … 100 156 End Class 101 157 158 159 'ジョイスティックのボタンの状態を取得するためのクラス 102 160 Class JoyButtons 103 161 dwButtons As DWord … … 108 166 End Sub 109 167 110 Public 168 Public 'Property 169 '各ボタンの状態を取得する 111 170 Function Button1 () As Boolean 112 171 Return This.Button( 1 ) … … 206 265 End Function 207 266 208 Public 267 Public 'Method 268 '指定した番号のボタンの状態を取得 209 269 Function Button ( n As DWord ) As Boolean 210 270 Return (1<<(n-1) And This.dwButtons) <> 0 211 271 End Function 212 272 213 Public 273 Public 'Operator 274 'DWord値へ変換 214 275 Function Operator () As DWord 215 276 Return This.dwButtons 216 277 End Function 217 278 279 'DWord値と比較 218 280 Function Operator== (dw As DWord) As Boolean 219 281 Return This.dwButtons = dw 220 282 End Function 283 Function Operator<> (dw As DWord) As Boolean 284 Return This.dwButtons <> dw 285 End Function 286 287 'DWord値とAnd演算 221 288 Function Operator And (dw As DWord) As Boolean 222 289 Return (This.dwButtons And dw) <> 0 … … 225 292 End Class 226 293 294 295 'PointOfView値を格納するクラス 227 296 Class JoyPointOfView 228 dwPOVAs DWord297 pov As DWord 229 298 230 299 Protected 231 300 Sub _Initialize ( dw As DWord ) 232 If LOWORD(dw) = &HFFFF Then dw = -1 233 This.dwPOV = dw 234 End Sub 235 236 Public 301 If LOWORD(dw) = &HFFFF Then dw = (-1) As DWord 302 This.pov = dw 303 End Sub 304 305 Public 'Static Constant 306 '中心 237 307 Static Const Centered = (-1) As DWord 308 '前方 238 309 Static Const Forward = 0 As DWord 310 '右前方 239 311 Static Const ForwardAndRight = 4500 As DWord 312 '右 240 313 Static Const Right = 9000 As DWord 314 '右後方 241 315 Static Const BackwardAndRight = 13500 As DWord 316 '後方 242 317 Static Const Backward = 18000 As DWord 318 '左後方 243 319 Static Const BackwardAndLeft = 22500 As DWord 320 '左 244 321 Static Const Left = 27000 As DWord 322 '左前方 245 323 Static Const ForwardAndLeft = 31500 As DWord 246 324 247 Public 325 Public 'Proparty 326 Function IsCentered() As Boolean 327 Return This.pov <> Centered 328 End Function 329 Function IsForward() As Boolean 330 Return This.pov <> Forward 331 End Function 332 Function IsRight() As Boolean 333 Return This.pov <> Right 334 End Function 335 Function IsBackward() As Boolean 336 Return This.pov <> Backward 337 End Function 338 Function IsLeft() As Boolean 339 Return This.pov <> Left 340 End Function 341 342 Public 'Method 343 '角度に変換 344 Function ToDegrees() As Double 345 Return (This.pov / 100) 346 End Function 347 348 349 Public 'Operator 350 'DWord値へ変換 248 351 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 352 Return This.pov 353 End Function 354 355 'DWord値と比較 356 Function Operator== (value As DWord ) As Boolean 357 Return This.pov = value 358 End Function 359 Function Operator<> ( value As DWord ) As Boolean 360 Return This.pov <> value 361 End Function 362 Function Operator<= ( value As DWord ) As Boolean 363 Return This.pov <= value 364 End Function 365 Function Operator>= ( value As DWord ) As Boolean 366 Return This.pov >= value 367 End Function 368 Function Operator< ( value As DWord ) As Boolean 369 Return This.pov < value 370 End Function 371 Function Operator> ( value As DWord ) As Boolean 372 Return This.pov > value 373 End Function 374 375 'DWord値と演算 376 Function Operator+ ( value As DWord ) As DWord 377 Return This.pov + value 378 End Function 379 Function Operator- ( value As DWord ) As DWord 380 Return This.pov - value 381 End Function 382 Function Operator* ( value As DWord ) As DWord 383 Return This.pov * value 384 End Function 385 Function Operator Mod ( value As DWord ) As DWord 386 Return This.pov Mod value 387 End Function 388 Function Operator / ( value As DWord ) As Double 389 Return This.pov / value 390 End Function 391 End Class 392 393 394 'ジョイスティックの情報を格納するJOYINFOEX構造体のラップクラス 291 395 Class JoyInfo 292 396 info As JOYINFOEX … … 299 403 End Sub 300 404 301 Public 405 Public 'Property 406 'X軸の値を取得 302 407 Function X () As DWord 303 408 Return This.info.dwXpos 304 409 End Function 410 411 'Y軸の値を取得 305 412 Function Y () As DWord 306 413 Return This.info.dwYpos 307 414 End Function 415 416 'Z軸の値を取得 308 417 Function Z () As DWord 309 418 Return This.info.dwZpos 310 419 End Function 420 421 'ラダー(R軸)の値を取得 311 422 Function R () As DWord 312 423 Return This.info.dwRpos 313 424 End Function 425 426 'U軸の値を取得 314 427 Function U () As DWord 315 428 Return This.info.dwUpos 316 429 End Function 430 431 'V軸の値を取得 317 432 Function V () As DWord 318 433 Return This.info.dwVpos 319 434 End Function 435 436 'ボタンの状態を取得 320 437 Function Buttons () As JoyButtons 321 438 Return New Detail._System_JoyButtons(This.info.dwButtons) 322 439 End Function 440 441 'ボタンの状態を取得 323 442 Function ButtonNumber () As DWord 324 443 Return This.info.dwButtonNumber … … 329 448 End Class 330 449 331 Class Joystick 450 451 'ジョイスティックを扱うためのクラス 452 Class JoystickDevice 332 453 id As DWord 333 454 … … 337 458 End Sub 338 459 339 Public 460 Public 'Property 461 'スティックの動きの閾値を設定 340 462 Sub Threshold ( value As DWord ) 341 463 joySetThreshold(id,value) 342 464 End Sub 465 466 'スティックの動きの閾値を取得 343 467 Function Threshold () As DWord 344 joyGetThreshold(id,VarPtr(Threshold)) 345 End Function 346 347 Public 468 joyGetThreshold(id,Threshold) 469 End Function 470 471 Public 'Method 472 'ジョイステックの性能を取得 348 473 Function GetCapabilities () As JoyCaps 349 474 Return New Detail._System_JoyCaps(This.id) 350 475 End Function 476 477 'ジョイステックの現在の状態を取得 351 478 Function GetInfo() As JoyInfo 352 479 Return New Detail._System_JoyInfo(This.id) 353 480 End Function 354 481 355 Public 482 'キャプチャを開始 356 483 Sub SetCupture ( hwnd As HWND, period As DWord, changed As Boolean) 357 484 joySetCapture(hwnd,id,period,changed) 358 485 End Sub 486 487 'キャプチャを終了 359 488 Sub ReleaseCapture() 360 489 joyReleaseCapture(id) … … 362 491 End Class 363 492 364 Class Joysticks 365 366 Public 493 494 'ジョイスティックデバイスを取得するためのクラス 495 Class Joystick 496 Public 'Static Constant 497 Static Const Joystick1 = 0 498 Static Const Joystick2 = 1 499 500 Public 'Static Property 501 'ドライバによってサポートされるジョイスティック数を取得 367 502 Static Function NumberOfDevices () As DWord 368 503 Return joyGetNumDevs() 369 504 End Function 505 506 '物理的に接続されたジョイスティック数を取得 370 507 Static Function NumberOfConnectedDevices () As DWord 371 Dim max = Joysticks.NumberOfDevices()508 Dim max = NumberOfDevices() 372 509 Dim cnt=0 As DWord 373 510 Dim info As JOYINFO … … 379 516 End Function 380 517 381 Static Function GetJoysticks() As System.Collections.Generic.List<Joystick> 382 Dim list As System.Collections.Generic.List<Joystick> 518 Public 'Static Method 519 '使用可能なジョイスティックIDを列挙したIListを取得 520 Static Function GetJoystickIDs() As System.Collections.Generic.IList<DWord> 521 Dim max = NumberOfDevices() 522 GetJoystickIDs = New System.Collections.Generic.List<DWord> 383 523 Dim cnt As DWord 384 For cnt=0 To NumberOfConnectedDevices() - 1 385 list.Add(Joysticks.GetJoystick(cnt)) 524 Dim info As JOYINFO 525 For cnt=0 To max-1 526 If joyGetPos(cnt,info) = JOYERR_NOERROR Then 527 GetJoystickIDs.Add(cnt) 528 End If 386 529 Next 387 Return list 388 End Function 389 390 Static Function GetJoystick( id As DWord ) As Joystick 391 Return New Detail._System_Joystick(id) 530 End Function 531 532 '使用可能なジョイスティックデバイスを列挙したIListを取得 533 Static Function GetDevices() As System.Collections.Generic.IList<JoystickDevice> 534 Dim max = NumberOfDevices() 535 GetDevices = New System.Collections.Generic.List<JoystickDevice> 536 Dim cnt As DWord 537 Dim info As JOYINFO 538 For cnt=0 To max-1 539 If joyGetPos(cnt,info) = JOYERR_NOERROR Then 540 GetDevices.Add(GetDeviceFromID(cnt)) 541 End If 542 Next 543 End Function 544 545 'ジョイスティックデバイスを取得 546 Static Function GetDeviceFromID( id As DWord ) As JoystickDevice 547 Return New Detail._System_JoystickDevice(id) 392 548 End Function 393 549 … … 443 599 End Class 444 600 445 Class _System_Joystick 446 Inherits Joystick 601 Class _System_JoystickDevice 602 Inherits JoystickDevice 447 603 Public 448 Sub _System_Joystick ( id As DWord )604 Sub _System_JoystickDevice ( id As DWord ) 449 605 This._Initialize(id) 450 606 End Sub
Note:
See TracChangeset
for help on using the changeset viewer.