Results 1 to 2 of 2

Thread: DirectX: Button states for other devices [Resolved]

Threaded View

  1. #1

    Thread Starter
    Lively Member Xman51's Avatar
    Join Date
    Mar 2005
    Location
    Tampa, FL USA
    Posts
    88

    Resolved DirectX: Button states for other devices [Resolved]

    whazaap?!?

    I am trying to figure out how you can call the state of the device you have aquired when it is not a joystick, mouse or keyboard.

    Does anyone know?

    Here is my code. I would like the event handler to be tied to the timer control:

    VB Code:
    1. Dim dx As New DirectX8
    2. Dim di As DirectInput8
    3. Dim diDEV As DirectInputDevice8
    4. Dim iKeyCounter As Integer
    5. Dim aKeys(2) As String
    6.  
    7.  
    8. Private Sub Form_Load()
    9.  
    10.     Set di = dx.DirectInputCreate()
    11.        
    12.     If Err.Number <> 0 Then
    13.         MsgBox "Error starting Direct Input, please make sure you have DirectX installed", vbApplicationModal
    14.         End
    15.     End If
    16.        
    17.     'Create the DirectX input Device
    18.     Set di = dx.DirectInputCreate()
    19.     'Make it point to the Footpedal
    20.     Set diDEV = di.CreateDevice("{DE261610-ADC9-11D9-8001-444553540000}")
    21.  
    22.  'Gather information from the device
    23.  Dim diEnumObjects As DirectInputEnumDeviceObjects
    24. Set diEnumObjects = diDEV.GetDeviceObjectsEnum(DIDFT_ALIAS)
    25. Dim diDevObjInstance As DirectInputDeviceObjectInstance
    26.  
    27. 'populate the listbox with available buttons
    28. Dim i As Integer
    29. For i = 1 To diEnumObjects.GetCount
    30.   Set diDevObjInstance = diEnumObjects.GetItem(i)
    31.   Call lstDevice.AddItem(diDevObjInstance.GetName)
    32. Next i
    33.  
    34. 'Set the cooperative level for your device
    35. Call diDEV.SetCooperativeLevel(hWnd, _
    36.         DISCL_NONEXCLUSIVE Or DISCL_FOREGROUND)
    37.  
    38. 'Set the properties for the device
    39.  Dim diProp As DIPROPLONG
    40. diProp.lHow = DIPH_DEVICE
    41. diProp.lObj = 0
    42. diProp.lData = 10
    43. Call diDEV.SetProperty("DIPROP_BUFFERSIZE", diProp)
    44.  
    45.  
    46.  
    47.     Me.Show
    48.     'Make the progrm acquire the device
    49.     diDEV.Acquire
    50.        
    51.     tmrKey.Interval = 10
    52.     tmrKey.Enabled = True
    53.    
    54.  
    55. End Sub
    56.  
    57. Private Sub Form_Unload(Cancel As Integer)
    58.     diDEV.Unacquire
    59. End Sub
    60.  
    61. Function KeyNames(iNum As Integer) As String
    62.  
    63.     aKeys(0) = "FWD"
    64.     aKeys(1) = "PLAY"
    65.     aKeys(2) = "REW"
    66.     If iNum < 3 Then
    67.     KeyNames = aKeys(iNum)
    68.     End If
    69. End Function
    70.  
    71.  
    72. Private Sub tmrKey_Timer()
    73.  
    74. lstKeys.Clear
    75. 'During the timer event must have some kind of event
    76. 'handler that recognizes when one of the buttons is
    77. 'pressed on the device
    78. End Sub

    Thanks in advance,
    Last edited by Xman51; Apr 18th, 2005 at 03:36 PM. Reason: resolved
    Xman51
    Area 51


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width