[585] | 1 |
|
---|
| 2 | '#require <api_mmsys.sbp>
|
---|
| 3 |
|
---|
| 4 | Namespace ActiveBasic
|
---|
| 5 | Namespace Windows
|
---|
| 6 | Namespace MM
|
---|
| 7 |
|
---|
[594] | 8 | 'ジョイスティックの構成を表す列挙体
|
---|
[585] | 9 | Enum JoyCapability
|
---|
[594] | 10 | 'ジョイスティックはZ軸情報を所有
|
---|
[585] | 11 | HasZ = &H0001
|
---|
[594] | 12 | 'ジョイスティックはR軸情報を所有
|
---|
[585] | 13 | HasR = &H0002
|
---|
[594] | 14 | 'ジョイスティックはU軸情報を所有
|
---|
[585] | 15 | HasU = &H0004
|
---|
[594] | 16 | 'ジョイスティックはV軸情報を所有
|
---|
[585] | 17 | HasV = &H0008
|
---|
[594] | 18 | 'ジョイスティックはPoint of View情報を所有
|
---|
[585] | 19 | HasPointOfView = &H0010
|
---|
[594] | 20 | 'ジョイスティックは4方向Point of Viewサポート
|
---|
[585] | 21 | PointOfView4Direction = &H0020
|
---|
[594] | 22 | 'ジョイスティックは連続した角度のPoint of Viewをサポート
|
---|
[585] | 23 | PointOfViewContinuous = &H0040
|
---|
| 24 | End Enum
|
---|
| 25 |
|
---|
[594] | 26 |
|
---|
| 27 | 'ジョイスティックの性能を取得するためのJOYCAPS構造体のラップクラス
|
---|
[585] | 28 | Class JoyCaps
|
---|
| 29 | caps As JOYCAPS
|
---|
| 30 |
|
---|
| 31 | Protected
|
---|
| 32 | Sub _Initialize ( id As DWord )
|
---|
| 33 | joyGetDevCaps(id,caps,SizeOf(JOYCAPS))
|
---|
| 34 | End Sub
|
---|
| 35 |
|
---|
[594] | 36 | Public 'Property
|
---|
| 37 | '製造業者IDの取得
|
---|
[585] | 38 | Function ManufacturerID () As Word
|
---|
| 39 | Return This.caps.wMid
|
---|
| 40 | End Function
|
---|
[594] | 41 |
|
---|
| 42 | '製品IDの取得
|
---|
[585] | 43 | Function ProductID () As Word
|
---|
| 44 | Return This.caps.wPid
|
---|
| 45 | End Function
|
---|
[594] | 46 |
|
---|
| 47 | '製品名の取得
|
---|
[585] | 48 | Function ProductName () As String
|
---|
| 49 | Return New System.String(This.caps.szPname As LPTSTR)
|
---|
| 50 | End Function
|
---|
[594] | 51 |
|
---|
| 52 | 'X軸の最小値の取得
|
---|
[585] | 53 | Function MinimumX () As DWord
|
---|
| 54 | Return This.caps.wXmin
|
---|
| 55 | End Function
|
---|
[594] | 56 |
|
---|
| 57 | 'X軸の最大値の取得
|
---|
[585] | 58 | Function MaximumX () As DWord
|
---|
| 59 | Return This.caps.wXmax
|
---|
| 60 | End Function
|
---|
[594] | 61 |
|
---|
| 62 | 'Y軸の最小値の取得
|
---|
[585] | 63 | Function MinimumY () As DWord
|
---|
| 64 | Return This.caps.wYmin
|
---|
| 65 | End Function
|
---|
[594] | 66 |
|
---|
| 67 | 'Y軸の最大値の取得
|
---|
[585] | 68 | Function MaximumY () As DWord
|
---|
| 69 | Return This.caps.wYmax
|
---|
| 70 | End Function
|
---|
[594] | 71 |
|
---|
| 72 | 'Z軸の最小値の取得
|
---|
[585] | 73 | Function MinimumZ () As DWord
|
---|
| 74 | Return This.caps.wZmin
|
---|
| 75 | End Function
|
---|
[594] | 76 |
|
---|
| 77 | 'Z軸の最大値の取得
|
---|
[585] | 78 | Function MaximumZ () As DWord
|
---|
| 79 | Return This.caps.wZmax
|
---|
| 80 | End Function
|
---|
[594] | 81 |
|
---|
| 82 | '
|
---|
[585] | 83 | Function NumberOfButtons () As DWord
|
---|
| 84 | Return This.caps.wNumButtons
|
---|
| 85 | End Function
|
---|
[594] | 86 |
|
---|
| 87 | 'キャプチャ時のメッセージ送信間隔の最小値の取得
|
---|
| 88 | Function MinimumPeriod () As DWord
|
---|
[585] | 89 | Return This.caps.wPeriodMin
|
---|
| 90 | End Function
|
---|
[594] | 91 |
|
---|
| 92 | 'キャプチャ時のメッセージ送信間隔の最大値の取得
|
---|
| 93 | Function MaximumPeriod () As DWord
|
---|
[585] | 94 | Return This.caps.wPeriodMax
|
---|
| 95 | End Function
|
---|
[594] | 96 |
|
---|
| 97 | '4軸目であるラダー(R軸)の最小値の取得
|
---|
[585] | 98 | Function MinimumR () As DWord
|
---|
| 99 | Return This.caps.wRmin
|
---|
| 100 | End Function
|
---|
[594] | 101 |
|
---|
| 102 | '4軸目であるラダー(R軸)の最大値の取得
|
---|
[585] | 103 | Function MaximumR () As DWord
|
---|
| 104 | Return This.caps.wRmax
|
---|
| 105 | End Function
|
---|
[594] | 106 |
|
---|
| 107 | '5軸目であるU軸の最小値の取得
|
---|
[585] | 108 | Function MinimumU () As DWord
|
---|
| 109 | Return This.caps.wUmin
|
---|
| 110 | End Function
|
---|
[594] | 111 |
|
---|
| 112 | '5軸目であるU軸の最大値の取得
|
---|
[585] | 113 | Function MaximumU () As DWord
|
---|
| 114 | Return This.caps.wUmax
|
---|
| 115 | End Function
|
---|
[594] | 116 |
|
---|
| 117 | '6軸目であるV軸の最小値の取得
|
---|
[585] | 118 | Function MinimumV () As DWord
|
---|
| 119 | Return This.caps.wVmin
|
---|
| 120 | End Function
|
---|
[594] | 121 |
|
---|
| 122 | '6軸目であるV軸の最大値の取得
|
---|
[585] | 123 | Function MaximumV () As DWord
|
---|
| 124 | Return This.caps.wVmax
|
---|
| 125 | End Function
|
---|
[594] | 126 |
|
---|
| 127 | 'ジョイスティックの構成を取得
|
---|
[585] | 128 | Function Capabilities () As JoyCapability
|
---|
| 129 | Return This.caps.wCaps As JoyCapability
|
---|
| 130 | End Function
|
---|
[594] | 131 |
|
---|
| 132 | 'サポートしている動きの軸の数を取得
|
---|
| 133 | Function NumberOfSupportedAxes () As DWord
|
---|
[585] | 134 | Return This.caps.wMaxAxes
|
---|
| 135 | End Function
|
---|
[594] | 136 |
|
---|
| 137 | '実際に使用している動きの軸の数を取得
|
---|
| 138 | Function NumberOfUsedAxes () As DWord
|
---|
[585] | 139 | Return This.caps.wNumAxes
|
---|
| 140 | End Function
|
---|
[594] | 141 |
|
---|
| 142 | 'サポートしているボタン数を取得
|
---|
| 143 | Function NumberOfSupportedButtons () As DWord
|
---|
[585] | 144 | Return This.caps.wMaxButtons
|
---|
| 145 | End Function
|
---|
[594] | 146 |
|
---|
| 147 | '登録キーを文字列の取得
|
---|
[585] | 148 | Function RegistryKey () As String
|
---|
| 149 | Return New System.String(This.caps.szRegKey As LPTSTR)
|
---|
| 150 | End Function
|
---|
[594] | 151 |
|
---|
| 152 | 'OEMジョイスティックドライバを特定する文字列の取得
|
---|
[585] | 153 | Function OEM_VxD () As String
|
---|
| 154 | Return New System.String(This.caps.szOEMVxD As LPTSTR)
|
---|
| 155 | End Function
|
---|
| 156 | End Class
|
---|
| 157 |
|
---|
[594] | 158 |
|
---|
| 159 | 'ジョイスティックのボタンの状態を取得するためのクラス
|
---|
[585] | 160 | Class JoyButtons
|
---|
| 161 | dwButtons As DWord
|
---|
| 162 |
|
---|
| 163 | Protected
|
---|
| 164 | Sub _Initialize ( dw As DWord )
|
---|
| 165 | This.dwButtons = dw
|
---|
| 166 | End Sub
|
---|
| 167 |
|
---|
[594] | 168 | Public 'Property
|
---|
| 169 | '各ボタンの状態を取得する
|
---|
[585] | 170 | Function Button1 () As Boolean
|
---|
| 171 | Return This.Button( 1 )
|
---|
| 172 | End Function
|
---|
| 173 | Function Button2 () As Boolean
|
---|
| 174 | Return This.Button( 2 )
|
---|
| 175 | End Function
|
---|
| 176 | Function Button3 () As Boolean
|
---|
| 177 | Return This.Button( 3 )
|
---|
| 178 | End Function
|
---|
| 179 | Function Button4 () As Boolean
|
---|
| 180 | Return This.Button( 4 )
|
---|
| 181 | End Function
|
---|
| 182 | Function Button5 () As Boolean
|
---|
| 183 | Return This.Button( 5 )
|
---|
| 184 | End Function
|
---|
| 185 | Function Button6 () As Boolean
|
---|
| 186 | Return This.Button( 6 )
|
---|
| 187 | End Function
|
---|
| 188 | Function Button7 () As Boolean
|
---|
| 189 | Return This.Button( 7 )
|
---|
| 190 | End Function
|
---|
| 191 | Function Button8 () As Boolean
|
---|
| 192 | Return This.Button( 8 )
|
---|
| 193 | End Function
|
---|
| 194 | Function Button9 () As Boolean
|
---|
| 195 | Return This.Button( 9 )
|
---|
| 196 | End Function
|
---|
| 197 | Function Button10 () As Boolean
|
---|
| 198 | Return This.Button( 10 )
|
---|
| 199 | End Function
|
---|
| 200 | Function Button11 () As Boolean
|
---|
| 201 | Return This.Button( 11 )
|
---|
| 202 | End Function
|
---|
| 203 | Function Button12 () As Boolean
|
---|
| 204 | Return This.Button( 12 )
|
---|
| 205 | End Function
|
---|
| 206 | Function Button13 () As Boolean
|
---|
| 207 | Return This.Button( 13 )
|
---|
| 208 | End Function
|
---|
| 209 | Function Button14 () As Boolean
|
---|
| 210 | Return This.Button( 14 )
|
---|
| 211 | End Function
|
---|
| 212 | Function Button15 () As Boolean
|
---|
| 213 | Return This.Button( 15 )
|
---|
| 214 | End Function
|
---|
| 215 | Function Button16 () As Boolean
|
---|
| 216 | Return This.Button( 16 )
|
---|
| 217 | End Function
|
---|
| 218 | Function Button17 () As Boolean
|
---|
| 219 | Return This.Button( 17 )
|
---|
| 220 | End Function
|
---|
| 221 | Function Button18 () As Boolean
|
---|
| 222 | Return This.Button( 18 )
|
---|
| 223 | End Function
|
---|
| 224 | Function Button19 () As Boolean
|
---|
| 225 | Return This.Button( 19 )
|
---|
| 226 | End Function
|
---|
| 227 | Function Button20 () As Boolean
|
---|
| 228 | Return This.Button( 20 )
|
---|
| 229 | End Function
|
---|
| 230 | Function Button21 () As Boolean
|
---|
| 231 | Return This.Button( 21 )
|
---|
| 232 | End Function
|
---|
| 233 | Function Button22 () As Boolean
|
---|
| 234 | Return This.Button( 22 )
|
---|
| 235 | End Function
|
---|
| 236 | Function Button23 () As Boolean
|
---|
| 237 | Return This.Button( 23 )
|
---|
| 238 | End Function
|
---|
| 239 | Function Button24 () As Boolean
|
---|
| 240 | Return This.Button( 24 )
|
---|
| 241 | End Function
|
---|
| 242 | Function Button25 () As Boolean
|
---|
| 243 | Return This.Button( 25 )
|
---|
| 244 | End Function
|
---|
| 245 | Function Button26 () As Boolean
|
---|
| 246 | Return This.Button( 26 )
|
---|
| 247 | End Function
|
---|
| 248 | Function Button27 () As Boolean
|
---|
| 249 | Return This.Button( 27 )
|
---|
| 250 | End Function
|
---|
| 251 | Function Button28 () As Boolean
|
---|
| 252 | Return This.Button( 28 )
|
---|
| 253 | End Function
|
---|
| 254 | Function Button29 () As Boolean
|
---|
| 255 | Return This.Button( 29 )
|
---|
| 256 | End Function
|
---|
| 257 | Function Button30 () As Boolean
|
---|
| 258 | Return This.Button( 30 )
|
---|
| 259 | End Function
|
---|
| 260 | Function Button31 () As Boolean
|
---|
| 261 | Return This.Button( 31 )
|
---|
| 262 | End Function
|
---|
| 263 | Function Button32 () As Boolean
|
---|
| 264 | Return This.Button( 32 )
|
---|
| 265 | End Function
|
---|
| 266 |
|
---|
[594] | 267 | Public 'Method
|
---|
| 268 | '指定した番号のボタンの状態を取得
|
---|
[585] | 269 | Function Button ( n As DWord ) As Boolean
|
---|
| 270 | Return (1<<(n-1) And This.dwButtons) <> 0
|
---|
| 271 | End Function
|
---|
| 272 |
|
---|
[594] | 273 | Public 'Operator
|
---|
| 274 | 'DWord値へ変換
|
---|
[585] | 275 | Function Operator () As DWord
|
---|
| 276 | Return This.dwButtons
|
---|
| 277 | End Function
|
---|
| 278 |
|
---|
[594] | 279 | 'DWord値と比較
|
---|
[585] | 280 | Function Operator== (dw As DWord) As Boolean
|
---|
| 281 | Return This.dwButtons = dw
|
---|
| 282 | End Function
|
---|
[594] | 283 | Function Operator<> (dw As DWord) As Boolean
|
---|
| 284 | Return This.dwButtons <> dw
|
---|
| 285 | End Function
|
---|
| 286 |
|
---|
| 287 | 'DWord値とAnd演算
|
---|
[585] | 288 | Function Operator And (dw As DWord) As Boolean
|
---|
| 289 | Return (This.dwButtons And dw) <> 0
|
---|
| 290 | End Function
|
---|
| 291 |
|
---|
| 292 | End Class
|
---|
| 293 |
|
---|
[594] | 294 |
|
---|
| 295 | 'PointOfView値を格納するクラス
|
---|
[585] | 296 | Class JoyPointOfView
|
---|
[594] | 297 | pov As DWord
|
---|
[585] | 298 |
|
---|
| 299 | Protected
|
---|
| 300 | Sub _Initialize ( dw As DWord )
|
---|
[594] | 301 | If LOWORD(dw) = &HFFFF Then dw = (-1) As DWord
|
---|
| 302 | This.pov = dw
|
---|
[585] | 303 | End Sub
|
---|
| 304 |
|
---|
[594] | 305 | Public 'Static Constant
|
---|
| 306 | '中心
|
---|
[585] | 307 | Static Const Centered = (-1) As DWord
|
---|
[594] | 308 | '前方
|
---|
[585] | 309 | Static Const Forward = 0 As DWord
|
---|
[594] | 310 | '右前方
|
---|
[585] | 311 | Static Const ForwardAndRight = 4500 As DWord
|
---|
[594] | 312 | '右
|
---|
[585] | 313 | Static Const Right = 9000 As DWord
|
---|
[594] | 314 | '右後方
|
---|
[585] | 315 | Static Const BackwardAndRight = 13500 As DWord
|
---|
[594] | 316 | '後方
|
---|
[585] | 317 | Static Const Backward = 18000 As DWord
|
---|
[594] | 318 | '左後方
|
---|
[585] | 319 | Static Const BackwardAndLeft = 22500 As DWord
|
---|
[594] | 320 | '左
|
---|
[585] | 321 | Static Const Left = 27000 As DWord
|
---|
[594] | 322 | '左前方
|
---|
[585] | 323 | Static Const ForwardAndLeft = 31500 As DWord
|
---|
| 324 |
|
---|
[594] | 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値へ変換
|
---|
[585] | 351 | Function Operator () As DWord
|
---|
[594] | 352 | Return This.pov
|
---|
[585] | 353 | End Function
|
---|
| 354 |
|
---|
[594] | 355 | 'DWord値と比較
|
---|
| 356 | Function Operator== (value As DWord ) As Boolean
|
---|
| 357 | Return This.pov = value
|
---|
[585] | 358 | End Function
|
---|
[594] | 359 | Function Operator<> ( value As DWord ) As Boolean
|
---|
| 360 | Return This.pov <> value
|
---|
[585] | 361 | End Function
|
---|
[594] | 362 | Function Operator<= ( value As DWord ) As Boolean
|
---|
| 363 | Return This.pov <= value
|
---|
[585] | 364 | End Function
|
---|
[594] | 365 | Function Operator>= ( value As DWord ) As Boolean
|
---|
| 366 | Return This.pov >= value
|
---|
[585] | 367 | End Function
|
---|
[594] | 368 | Function Operator< ( value As DWord ) As Boolean
|
---|
| 369 | Return This.pov < value
|
---|
[585] | 370 | End Function
|
---|
[594] | 371 | Function Operator> ( value As DWord ) As Boolean
|
---|
| 372 | Return This.pov > value
|
---|
[585] | 373 | End Function
|
---|
| 374 |
|
---|
[594] | 375 | 'DWord値と演算
|
---|
| 376 | Function Operator+ ( value As DWord ) As DWord
|
---|
| 377 | Return This.pov + value
|
---|
[585] | 378 | End Function
|
---|
[594] | 379 | Function Operator- ( value As DWord ) As DWord
|
---|
| 380 | Return This.pov - value
|
---|
[585] | 381 | End Function
|
---|
[594] | 382 | Function Operator* ( value As DWord ) As DWord
|
---|
| 383 | Return This.pov * value
|
---|
[585] | 384 | End Function
|
---|
[594] | 385 | Function Operator Mod ( value As DWord ) As DWord
|
---|
| 386 | Return This.pov Mod value
|
---|
[585] | 387 | End Function
|
---|
[594] | 388 | Function Operator / ( value As DWord ) As Double
|
---|
| 389 | Return This.pov / value
|
---|
[585] | 390 | End Function
|
---|
| 391 | End Class
|
---|
| 392 |
|
---|
[594] | 393 |
|
---|
| 394 | 'ジョイスティックの情報を格納するJOYINFOEX構造体のラップクラス
|
---|
[585] | 395 | Class JoyInfo
|
---|
| 396 | info As JOYINFOEX
|
---|
| 397 |
|
---|
| 398 | Protected
|
---|
| 399 | Sub _Initialize ( id As DWord )
|
---|
| 400 | This.info.dwSize = SizeOf(JOYINFOEX)
|
---|
| 401 | This.info.dwFlags = JOY_RETURNALL
|
---|
| 402 | joyGetPosEx(id,info)
|
---|
| 403 | End Sub
|
---|
| 404 |
|
---|
[594] | 405 | Public 'Property
|
---|
| 406 | 'X軸の値を取得
|
---|
[585] | 407 | Function X () As DWord
|
---|
| 408 | Return This.info.dwXpos
|
---|
| 409 | End Function
|
---|
[594] | 410 |
|
---|
| 411 | 'Y軸の値を取得
|
---|
[585] | 412 | Function Y () As DWord
|
---|
| 413 | Return This.info.dwYpos
|
---|
| 414 | End Function
|
---|
[594] | 415 |
|
---|
| 416 | 'Z軸の値を取得
|
---|
[585] | 417 | Function Z () As DWord
|
---|
| 418 | Return This.info.dwZpos
|
---|
| 419 | End Function
|
---|
[594] | 420 |
|
---|
| 421 | 'ラダー(R軸)の値を取得
|
---|
[585] | 422 | Function R () As DWord
|
---|
| 423 | Return This.info.dwRpos
|
---|
| 424 | End Function
|
---|
[594] | 425 |
|
---|
| 426 | 'U軸の値を取得
|
---|
[585] | 427 | Function U () As DWord
|
---|
| 428 | Return This.info.dwUpos
|
---|
| 429 | End Function
|
---|
[594] | 430 |
|
---|
| 431 | 'V軸の値を取得
|
---|
[585] | 432 | Function V () As DWord
|
---|
| 433 | Return This.info.dwVpos
|
---|
| 434 | End Function
|
---|
[594] | 435 |
|
---|
| 436 | 'ボタンの状態を取得
|
---|
[585] | 437 | Function Buttons () As JoyButtons
|
---|
| 438 | Return New Detail._System_JoyButtons(This.info.dwButtons)
|
---|
| 439 | End Function
|
---|
[594] | 440 |
|
---|
| 441 | 'ボタンの状態を取得
|
---|
[585] | 442 | Function ButtonNumber () As DWord
|
---|
| 443 | Return This.info.dwButtonNumber
|
---|
| 444 | End Function
|
---|
| 445 | Function PointOfView () As JoyPointOfView
|
---|
| 446 | Return New Detail._System_JoyPointOfView(This.info.dwPOV)
|
---|
| 447 | End Function
|
---|
| 448 | End Class
|
---|
| 449 |
|
---|
[594] | 450 |
|
---|
| 451 | 'ジョイスティックを扱うためのクラス
|
---|
| 452 | Class JoystickDevice
|
---|
[585] | 453 | id As DWord
|
---|
| 454 |
|
---|
| 455 | Protected
|
---|
| 456 | Sub _Initialize ( id As DWord )
|
---|
| 457 | This.id = id
|
---|
| 458 | End Sub
|
---|
| 459 |
|
---|
[594] | 460 | Public 'Property
|
---|
| 461 | 'スティックの動きの閾値を設定
|
---|
[585] | 462 | Sub Threshold ( value As DWord )
|
---|
| 463 | joySetThreshold(id,value)
|
---|
| 464 | End Sub
|
---|
[594] | 465 |
|
---|
| 466 | 'スティックの動きの閾値を取得
|
---|
[585] | 467 | Function Threshold () As DWord
|
---|
[594] | 468 | joyGetThreshold(id,Threshold)
|
---|
[585] | 469 | End Function
|
---|
| 470 |
|
---|
[594] | 471 | Public 'Method
|
---|
| 472 | 'ジョイステックの性能を取得
|
---|
[585] | 473 | Function GetCapabilities () As JoyCaps
|
---|
| 474 | Return New Detail._System_JoyCaps(This.id)
|
---|
| 475 | End Function
|
---|
[594] | 476 |
|
---|
| 477 | 'ジョイステックの現在の状態を取得
|
---|
[585] | 478 | Function GetInfo() As JoyInfo
|
---|
| 479 | Return New Detail._System_JoyInfo(This.id)
|
---|
| 480 | End Function
|
---|
| 481 |
|
---|
[594] | 482 | 'キャプチャを開始
|
---|
[585] | 483 | Sub SetCupture ( hwnd As HWND, period As DWord, changed As Boolean)
|
---|
| 484 | joySetCapture(hwnd,id,period,changed)
|
---|
| 485 | End Sub
|
---|
[594] | 486 |
|
---|
| 487 | 'キャプチャを終了
|
---|
[585] | 488 | Sub ReleaseCapture()
|
---|
| 489 | joyReleaseCapture(id)
|
---|
| 490 | End Sub
|
---|
| 491 | End Class
|
---|
| 492 |
|
---|
| 493 |
|
---|
[594] | 494 | 'ジョイスティックデバイスを取得するためのクラス
|
---|
| 495 | Class Joystick
|
---|
| 496 | Public 'Static Constant
|
---|
| 497 | Static Const Joystick1 = 0
|
---|
| 498 | Static Const Joystick2 = 1
|
---|
| 499 |
|
---|
| 500 | Public 'Static Property
|
---|
| 501 | 'ドライバによってサポートされるジョイスティック数を取得
|
---|
[585] | 502 | Static Function NumberOfDevices () As DWord
|
---|
| 503 | Return joyGetNumDevs()
|
---|
| 504 | End Function
|
---|
[594] | 505 |
|
---|
| 506 | '物理的に接続されたジョイスティック数を取得
|
---|
[585] | 507 | Static Function NumberOfConnectedDevices () As DWord
|
---|
[594] | 508 | Dim max = NumberOfDevices()
|
---|
[585] | 509 | Dim cnt=0 As DWord
|
---|
| 510 | Dim info As JOYINFO
|
---|
| 511 | While joyGetPos(cnt,info) = JOYERR_NOERROR
|
---|
| 512 | cnt++
|
---|
| 513 | If cnt >= max Then Exit While
|
---|
| 514 | Wend
|
---|
| 515 | Return cnt
|
---|
| 516 | End Function
|
---|
| 517 |
|
---|
[594] | 518 | Public 'Static Method
|
---|
| 519 | '使用可能なジョイスティックIDを列挙したIListを取得
|
---|
[619] | 520 | Static Function GetValidJoystickIDs() As System.Collections.Generic.IList<DWord>
|
---|
[594] | 521 | Dim max = NumberOfDevices()
|
---|
| 522 | GetJoystickIDs = New System.Collections.Generic.List<DWord>
|
---|
[585] | 523 | Dim cnt As DWord
|
---|
[594] | 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
|
---|
[585] | 529 | Next
|
---|
| 530 | End Function
|
---|
| 531 |
|
---|
[594] | 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
|
---|
[585] | 543 | End Function
|
---|
| 544 |
|
---|
[594] | 545 | 'ジョイスティックデバイスを取得
|
---|
| 546 | Static Function GetDeviceFromID( id As DWord ) As JoystickDevice
|
---|
| 547 | Return New Detail._System_JoystickDevice(id)
|
---|
| 548 | End Function
|
---|
| 549 |
|
---|
[585] | 550 | End Class
|
---|
| 551 |
|
---|
| 552 | Namespace Detail
|
---|
| 553 | Class _System_JoyCaps
|
---|
| 554 | Inherits JoyCaps
|
---|
| 555 | Public
|
---|
| 556 | Sub _System_JoyCaps ( id As DWord )
|
---|
| 557 | This._Initialize(id)
|
---|
| 558 | End Sub
|
---|
| 559 |
|
---|
| 560 | Override Function ToString () As String
|
---|
| 561 | Return "JoyCaps"
|
---|
| 562 | End Function
|
---|
| 563 | End Class
|
---|
| 564 |
|
---|
| 565 | Class _System_JoyButtons
|
---|
| 566 | Inherits JoyButtons
|
---|
| 567 | Public
|
---|
| 568 | Sub _System_JoyButtons ( dw As DWord )
|
---|
| 569 | This._Initialize(dw)
|
---|
| 570 | End Sub
|
---|
| 571 |
|
---|
| 572 | Override Function ToString () As String
|
---|
| 573 | Return "JoyButtons"
|
---|
| 574 | End Function
|
---|
| 575 | End Class
|
---|
| 576 |
|
---|
| 577 | Class _System_JoyPointOfView
|
---|
| 578 | Inherits JoyPointOfView
|
---|
| 579 | Public
|
---|
| 580 | Sub _System_JoyPointOfView ( dw As DWord )
|
---|
| 581 | This._Initialize(dw)
|
---|
| 582 | End Sub
|
---|
| 583 |
|
---|
| 584 | Override Function ToString () As String
|
---|
| 585 | Return "JoyPointOfView"
|
---|
| 586 | End Function
|
---|
| 587 | End Class
|
---|
| 588 |
|
---|
| 589 | Class _System_JoyInfo
|
---|
| 590 | Inherits JoyInfo
|
---|
| 591 | Public
|
---|
| 592 | Sub _System_JoyInfo ( id As DWord )
|
---|
| 593 | This._Initialize(id)
|
---|
| 594 | End Sub
|
---|
| 595 |
|
---|
| 596 | Override Function ToString () As String
|
---|
| 597 | Return "JoyInfo"
|
---|
| 598 | End Function
|
---|
| 599 | End Class
|
---|
| 600 |
|
---|
[594] | 601 | Class _System_JoystickDevice
|
---|
| 602 | Inherits JoystickDevice
|
---|
[585] | 603 | Public
|
---|
[594] | 604 | Sub _System_JoystickDevice ( id As DWord )
|
---|
[585] | 605 | This._Initialize(id)
|
---|
| 606 | End Sub
|
---|
| 607 |
|
---|
| 608 | Override Function ToString () As String
|
---|
| 609 | Return "Joystick"
|
---|
| 610 | End Function
|
---|
| 611 | End Class
|
---|
| 612 |
|
---|
| 613 | End Namespace
|
---|
| 614 |
|
---|
| 615 | End Namespace
|
---|
| 616 | End Namespace
|
---|
| 617 | End Namespace
|
---|