?? basjoystick.bas
字號:
Attribute VB_Name = "basJoyStick"
'****************************************
'漢化: 小聰明 coolzm@sohu.com
'小聰明的主頁VB版: http://coolzm.533.net
'****************************************
Option Explicit
Public Const JOY_BUTTON1 = &H1
Public Const JOY_BUTTON2 = &H2
Public Const JOY_BUTTON3 = &H4
Public Const JOY_BUTTON4 = &H8
Public Type JOYINFO
x As Long
Y As Long
Z As Long
Buttons As Long
End Type
Private Const JOYERR_BASE = 160
Private Const JOYERR_NOERROR = (0)
Private Const JOYERR_NOCANDO = (JOYERR_BASE + 6)
Private Const JOYERR_PARMS = (JOYERR_BASE + 5)
Private Const JOYERR_UNPLUGGED = (JOYERR_BASE + 7)
Private Const MAXPNAMELEN = 32
Private Type JOYCAPS
wMid As Integer
wPid As Integer
szPname As String * MAXPNAMELEN
wXmin As Long
wXmax As Long
wYmin As Long
wYmax As Long
wZmin As Long
wZmax As Long
wNumButtons As Long
wPeriodMin As Long
wPeriodMax As Long
End Type
Private Declare Function joyGetDevCaps Lib "winmm.dll" _
Alias "joyGetDevCapsA" (ByVal id As Long, _
lpCaps As JOYCAPS, ByVal uSize As Long) As Long
Private Declare Function joyGetNumDevs Lib "winmm.dll" _
() As Long
Private Declare Function joyGetPos Lib "winmm.dll" _
(ByVal uJoyID As Long, pji As JOYINFO) As Long
Public Function GetJoyMin(ByVal joy As Integer, ji As JOYINFO) As Boolean
Dim jc As JOYCAPS
If joyGetDevCaps(joy, jc, Len(jc)) <> JOYERR_NOERROR Then
GetJoyMin = False
Else
ji.x = jc.wXmin
ji.Y = jc.wYmin
ji.Z = jc.wZmin
ji.Buttons = jc.wNumButtons
GetJoyMin = True
End If
End Function
Public Function GetJoyMax(ByVal joy As Integer, ji As JOYINFO) As Boolean
Dim jc As JOYCAPS
If joyGetDevCaps(joy, jc, Len(jc)) <> JOYERR_NOERROR Then
GetJoyMax = False
Else
ji.x = jc.wXmax
ji.Y = jc.wYmax
ji.Z = jc.wZmax
ji.Buttons = jc.wNumButtons
GetJoyMax = True
End If
End Function
Public Function GetJoystick(ByVal joy As Integer, ji As JOYINFO) As Boolean
If joyGetPos(joy, ji) <> JOYERR_NOERROR Then
GetJoystick = False
Else
GetJoystick = True
End If
End Function
' 如果參數IsConnected為False,此函數返回系統所支持的游戲手柄的個數
' 如果參數IsConnected為True,此函數返回已經連接的手柄的個數
' 參數IsConnected的默認值為True
Public Function IsJoyPresent(Optional IsConnected As Variant) As Long
Dim ic As Boolean
Dim i As Long
Dim j As Long
Dim ret As Long
Dim ji As JOYINFO
ic = IIf(IsMissing(IsConnected), True, CBool(IsConnected))
i = joyGetNumDevs
If ic Then
j = 0
Do While i > 0
i = i - 1
If joyGetPos(i, ji) = JOYERR_NOERROR Then
j = j + 1
End If
Loop
IsJoyPresent = j
Else
IsJoyPresent = i
End If
End Function
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -