Post

 Resources 

Console

Home | Profile | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 VBGamer
 VBGamer
 DirectInput problems

Note: You must be registered in order to post a reply.

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List Spell Checker
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

   Insert an File
Check here to include your profile signature.
Check here to subscribe to this topic.
    

T O P I C    R E V I E W
Fistandanbitus Posted - Jun 21 2005 : 9:23:52 PM
Hi.

I'm having a little problem with the mouse as a DirectInput Device.

I read in the DirectX4VB site some DirectX 8 tutorials. So I have programmed a DirectX window, put some very simple polys (2 boxes, one of them is the mouse cursor) and at this point, everything worked fine and the app reports 70 fps.

Later, I decied to implement a DirectInput keyboard and mouse (in that order). I read in the tutorial that i could handle the DirectInput devices by a polling method or a event method. So I choosed to hanlde them via the event method. Also I assumed the keyboard event and the mouse event need a different handle.

I wrote the setup for the keyboard setup and I put a unique handle for it's event. Still, everything worked fine so far and the app reports 70 fps.

Then I wrote the setup for the mouse setup and I used a different hanlde for this even. Not everything workd fine after I implemented this event.

The app still reports 70 fps, but when I move the mouse, the fps drops drastically, the lowest i have seen is 5 fps. Also, I move one of the boxes as a cursor and the movement is a bt jumpy.

Can someone help me ?
2   L A T E S T    R E P L I E S    (Newest First)
Fistandanbitus Posted - Jun 22 2005 : 04:03:26 AM
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 'how many events have just happened (usually 1)  
    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  
                       'the mouse has moved along the Z axis (Mouse wheel movement)  
  
                     Case DIMOFS_BUTTON0  
                        'the first (left) button has been pressed  
                        Me.Caption = "Button 0 State: " & IIf(pBuffer(I).lData = 0, "Up", "Down")  
  
                     Case DIMOFS_BUTTON1  
                        'the second (right) button has been pressed  
                        Me.Caption = "Button 1 State: " & IIf(pBuffer(I).lData = 0, "Up", "Down")  
  
                     Case DIMOFS_BUTTON2  
                        'the third (middle usually) button has been pressed  
                        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 'simple error checker...  
  
            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 'ESC key  
                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
                ' This is just for control  
    End Select
End Sub
  
Vankwysha Posted - Jun 22 2005 : 03:04:27 AM
Just to make things a little clearer:

1) How are you raising your event? Do you have a timer, a loop or what?

2) What do you mean by "a DirectX window"? Is it a simple form, a window with DirectDraw, Direc3D or what?

3) Can we see a snippet of your DirectInput code?

VBGamer © Go To Top Of Page
This page was generated in 0.36 seconds. Snitz Forums 2000

Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.