|
Tipp 0230
|
Einlesen aller verfügbaren Eingabegeräte
|
|
|
Autor/Einsender: Datum: |
|
Alexander Csadek 05.05.2002 |
|
Entwicklungsumgebung:
DirectX-Version: |
|
VB 6
DirectX 7 |
|
|
Das DirectInput-Objekt ist das Herzstück von DirectInput und es können hierüber alle DI-Geräte aufgelistet und verwendet werden. Jedes Eingabegerät wird von einem DirectInputDevice-Objekt repräsentiert, egal wie viele Eingabegeräte in einem Spiel verwendet werden.
|
Mit dem Objekt DirectInputEnumDevices kann die Anzahl der Eingabegeräte festgestellt werden. Weiterhin sind auch Informationen über das jeweilige Geräte verfügbar.
|
Zu diesem Tipp finden Sie eine ausführliche Beschreibung in unserer
DirectX-Rubrik zu DirectInput.
|
|
|
Option Explicit
Dim DX As New DirectX7
Dim DI As DirectInput
Dim DIED As DirectInputEnumDevices
Private Sub Form_Load()
On Error GoTo ErrOut
Set DI = DX.DirectInputCreate()
GetIOListe True
DisplayInfos lst_DID.ListIndex + 1
Exit Sub
ErrOut:
MsgBox "Zugriff auf DirectInput nicht möglich." & vbCr & _
Err.Number & "/" & Err.Description, vbInformation
End
End Sub
Private Sub GetIOListe(Alle As Boolean)
Dim i As Single
On Error GoTo ErrOut
Set DIED = Nothing
If Alle Then
Set DIED = DI.GetDIEnumDevices(0, DIEDFL_INCLUDEPHANTOMS)
Else
Set DIED = DI.GetDIEnumDevices(0, DIEDFL_ATTACHEDONLY)
End If
With lst_DID
.Clear
For i = 1 To DIED.GetCount
.AddItem DIED.GetItem(i).GetProductName
Next
.ListIndex = 0
End With
Exit Sub
ErrOut:
MsgBox "Zugriff auf DirectInput-Auflistung nicht möglich." & _
vbCr & Err.Number & "/" & Err.Description, vbInformation
End
End Sub
Private Sub DisplayInfos(DeviceNummer As Single)
On Error GoTo ErrOut
txt_DeviceInfos.Text = _
"ProductName: " & _
DIED.GetItem(DeviceNummer).GetProductName & vbCrLf & _
"InstanceName: " & _
DIED.GetItem(DeviceNummer).GetInstanceName & vbCrLf & _
"GuidInstance: " & _
DIED.GetItem(DeviceNummer).GetGuidInstance & vbCrLf & _
"GuidProduct: " & DIED.GetItem(DeviceNummer).GetGuidProduct
Exit Sub
ErrOut:
MsgBox "Zugriff auf DirectInput-Device-Infos nicht möglich." & _
vbCr & Err.Number & "/" & Err.Description, vbInformation
End Sub
Private Sub lst_DID_Click()
DisplayInfos lst_DID.ListIndex + 1
End Sub
Private Sub chk_attachedonly_Click()
If chk_attachedonly.Value = 0 Then
GetIOListe True
Else
GetIOListe False
End If
DisplayInfos lst_DID.ListIndex + 1
End Sub
Private Sub cmd_System_Click()
DI.RunControlPanel Me.hWnd
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, _
UnloadMode As Integer)
cmd_Close_Click
End Sub
Private Sub cmd_Close_Click()
Set DIED = Nothing
Set DI = Nothing
Set DX = Nothing
Unload Me
End
End Sub
|
|
|
|
|
|
Um dieses Beispiel ausführen zu können, wird die DirectX 7
for Visual Basic Type Library
benötigt (siehe dazu die Erläuterungen in der DirectX-Rubrik).
|
|
Windows-Version |
95 |
|
|
98/SE |
|
|
ME |
|
|
NT |
|
|
2000 |
|
|
XP |
|
|
Vista |
|
|
Win
7 |
|
|
|
VB-Version |
VBA 5 |
|
|
VBA 6 |
|
|
VB 4/16 |
|
|
VB 4/32 |
|
|
VB 5 |
|
|
VB 6 |
|
|
|
|
Download (2,8
kB)
|
Downloads bisher: [ 1978 ]
|
|
|