Решил поковырятся с джойстиком, но что то пошло не так)
joyGetpos - работает нормально, а вот joyGetPosEx при первом опросе вылетает ВБ.
данные получает и потом молча сворачивает весь бейсик.
- Код: Выделить всё
Private Declare Function joyGetpos Lib "winmm.dll" Alias "joyGetPos" (ByVal uJoyID As Long, pji As JOYINFO) As Long
Private Type JOYINFO
wXpos As Long
wYpos As Long
wZpos As Long
wButtons As Long
End Type
Private Declare Function joyGetPosEx Lib "winmm.dll" (ByVal uJoyID As Integer, ByRef pji As JOYINFOEX) As Integer
Private Type JOYINFOEX
dwSize As Integer
dwFlags As Integer
dwXpos As Integer
dwYpos As Integer
dwZpos As Integer
dwRpos As Integer
dwUpos As Integer
dwVpos As Integer
dwButtons As Integer
dwButtonNumber As Integer
dwPOV As Integer
dwReserved1 As Integer
dwReserved2 As Integer
End Type
Dim JOYPOSex As JOYINFOEX
Private Const JOY_RETURNBUTTONS As Long = &H80&
Private Const JOY_RETURNCENTERED As Long = &H400&
Private Const JOY_RETURNPOV As Long = &H40&
Private Const JOY_RETURNPOVCTS As Long = &H200&
Private Const JOY_RETURNR As Long = &H8&
Private Const JOY_RETURNRAWDATA As Long = &H100&
Private Const JOY_RETURNU As Long = &H10
Private Const JOY_RETURNV As Long = &H20
Private Const JOY_RETURNX As Long = &H1&
Private Const JOY_RETURNY As Long = &H2&
Private Const JOY_RETURNZ As Long = &H4&
Private Const JOY_RETURNALL As Long = (JOY_RETURNX Or JOY_RETURNY Or JOY_RETURNZ Or JOY_RETURNR Or JOY_RETURNU Or JOY_RETURNV Or JOY_RETURNPOV Or JOY_RETURNBUTTONS)
Private Sub Form_Load()
For a = 0 To 5
useIDJoy = -1
Dim JOYPOS As JOYINFO
joyGetpos a, JOYPOS
If JOYPOS.wXpos = 0 And JOYPOS.wYpos = 0 And JOYPOS.wZpos = 0 Then
List2.AddItem "Joy #" & a & "is not found"
Else
useIDJoy = a
List2.AddItem "Use joy #" & a
GoTo 10
End If
Next
10
If useIDJoy = -1 Then List2.AddItem "Use keybord"
JOYPOSex.dwSize = Len(JOYPOSex)
JOYPOSex.dwFlags = JOY_RETURNALL
End Sub
Private Sub Timer1_Timer()
joy
End Sub
Private Sub joy()
'Dim JOYPOS As JOYINFO
' joyGetpos useIDJoy, JOYPOS
Dim rc As Integer
List1.Clear
'List1.AddItem JOYPOS.wXpos
'List1.AddItem JOYPOS.wYpos
'List1.AddItem JOYPOS.wZpos
'List1.AddItem JOYPOS.wButtons
rc = joyGetPosEx(0, JOYPOSex)
'List1.AddItem JOYPOSex.dwXpos
'List1.AddItem JOYPOSex.dwYpos
'List1.AddItem JOYPOSex.dwZpos
'List1.AddItem JOYPOSex.dwButtons
End Sub
Майкл, помню ты на геймдеве что то скидывал по тесту геймпада, можешь кинуть исходник? Посмотрю, что я опять начудил)