![]() |
Tipp 0471
|
Einlesen aller verfügbaren Eingabegeräte
|
 |
|
Autor/Einsender: Datum: |
|
Alexander Csadek 21.11.2005 |
|
Entwicklungsumgebung:
DirectX-Version: |
|
VB 6
DirectX 8 |
|
|
Das DirectInput8-Objekt ist das Herzstück von DirectInput.
Hierüber können alle Eingabe-Geräte (Maus, Tastatur usw.) aufgelistet und
auch verwendet werden. Jedes Eingabegerät wird von einem DirectInputDevice8-Objekt
repräsentiert, egal wie viele Eingabegeräte in einem Spiel verwendet werden.
|
Mit dem DirectInputEnumDevices8-Objekt
kann nicht nur die Anzahl der Eingabegeräte festgestellt, sondern auch Informationen über das jeweilige Geräte
ausgelesen werden.
|
|
|
Option Explicit
Dim DX8 As DirectX8
Dim DI8 As DirectInput8
Dim DIED As DirectInputEnumDevices8
Private Sub Form_Load()
On Error GoTo ErrOut
Set DX8 = New DirectX8
Set DI8 = DX8.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 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 GetIOListe(Alle As Boolean)
Dim i As Single
On Error GoTo ErrOut
Set DIED = Nothing
If Alle Then
Set DIED = DI8.GetDIDevices(0, DIEDFL_INCLUDEPHANTOMS)
Else
Set DIED = DI8.GetDIDevices(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 lst_DID_Click()
DisplayInfos lst_DID.ListIndex + 1
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 cmd_Close_Click()
Set DIED = Nothing
Set DI8 = Nothing
Set DX8 = Nothing
End
End Sub
|
|
|
|
Um dieses Beispiel ausführen zu können, wird die DirectX 8 for Visual Basic Type Library
benötigt (siehe dazu die Erläuterungen in der DirectX-Rubrik).
|
|
Windows-Version |
95 |
 |
|
98 |
 |
|
ME |
 |
|
NT |
 |
|
2000 |
 |
|
XP |
 |
|
Vista |
 |
|
Win
7 |
 |
|
|
VB-Version |
VBA 5 |
 |
|
VBA 6 |
 |
|
VB 4/16 |
 |
|
VB 4/32 |
 |
|
VB 5 |
 |
|
VB 6 |
 |
|
|
|
Download (3,7
kB)
|
Downloads bisher: [ 363 ]
|
|
|