Sure (sorry about the missing details)
The app is a simple form with direct3d, using a loop.
Do While bRunning
Render.
DoEvents
Calculate_FrameRate
Loop
bRunning is a boolean flag
The event is a DirectX 8 event implementation. As global variables I define the 2 event handles
Global hEvent_Keyboard As Long
Global hEvent_Mouse As Long
In the form code I implement the DirectX 8 events with
Implements DirectXEvent8
The directX events are as follows
Private Sub DirectXEvent8_DXCallback(ByVal eventid As Long)
Dim I As Long
Dim pBuffer(0 To BufferSize) As DIDEVICEOBJECTDATA
Dim nEvents As Long On Error Resume Next
Select Case eventid
Case hEvent_Mouse
Debug.Print "Mouse Event"
nEvents = DI_Mouse.GetDeviceData(pBuffer, DIGDD_DEFAULT)
For I = 0 To nEvents
Select Case pBuffer(I).lOfs
Case DIMOFS_X
mPosition.X = mPosition.X + (pBuffer(I).lData * mSpeed)
If mPosition.X < 0 Then mPosition.X = 0
If mPosition.X > DirectX_Form.ScaleWidth Then mPosition.X = DirectX_Form.ScaleWidth
Cx = mPosition.X
Cy = mPosition.Y
Me.Caption = "[" & Cx & "," & Cy & "]"
Case DIMOFS_Y
mPosition.Y = mPosition.Y + (pBuffer(I).lData * mSpeed)
If mPosition.Y < 0 Then mPosition.Y = 0
If mPosition.Y > DirectX_Form.ScaleHeight Then mPosition.Y = DirectX_Form.ScaleHeight
Cx = mPosition.X
Cy = mPosition.Y
Me.Caption = "[" & Cx & "," & Cy & "]"
Case DIMOFS_Z
Case DIMOFS_BUTTON0
Me.Caption = "Button 0 State: " & IIf(pBuffer(I).lData = 0, "Up", "Down")
Case DIMOFS_BUTTON1
Me.Caption = "Button 1 State: " & IIf(pBuffer(I).lData = 0, "Up", "Down")
Case DIMOFS_BUTTON2
Me.Caption = "Button 2 State: " & IIf(pBuffer(I).lData = 0, "Up", "Down")
Case DIMOFS_BUTTON3
Me.Caption = "Button 3 State: " & IIf(pBuffer(I).lData = 0, "Up", "Down")
Case DIMOFS_BUTTON4
Me.Caption = "Button 4 State: " & IIf(pBuffer(I).lData = 0, "Up", "Down")
Case DIMOFS_BUTTON5
Me.Caption = "Button 5 State: " & IIf(pBuffer(I).lData = 0, "Up", "Down")
Case DIMOFS_BUTTON6
Me.Caption = "Button 6 State: " & IIf(pBuffer(I).lData = 0, "Up", "Down")
Case DIMOFS_BUTTON7
Me.Caption = "Button 7 State: " & IIf(pBuffer(I).lData = 0, "Up", "Down")
End Select
Next I
Case hEvent_Keyboard
Debug.Print "Keyboard Event"
If DI_Keyboard Is Nothing Then Exit Sub
DI_Keyboard.GetDeviceStateKeyboard DIState
DI_Keyboard.GetDeviceData pBuffer, DIGDD_DEFAULT
If DIState.Key(48) = 128 Then Show_Bruiser = Not Show_Bruiser
If DIState.Key(1) = 128 Then bRunning = False
Else
For I = 0 To 255
If DIState.Key(I) = 128 Then
If pBuffer(0).lData = 128 Then
TextToDraw = KeyNames(CInt(I)) & " --> " & CInt(I)
End If
End If
Next I
End If
Case Else
End Select
End Sub