Results 1 to 15 of 15

Thread: Joystick with DirectX [RESOLVED]

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2004
    Posts
    185

    Joystick with DirectX [RESOLVED]

    I am having issues getting a joystick to work with VB.NET and directx 9. I have gotten a joystick to work in VB6 no problem with directx 8, but now with 9, I just can't get it. Here is the code I have so far:

    VB Code:
    1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         Dim devices As Microsoft.DirectX.DirectInput.DeviceList
    3.         Dim dev As Microsoft.DirectX.DirectInput.DeviceInstance
    4.         Dim gamepadDevice As Microsoft.DirectX.DirectInput.Device
    5.         devices = Microsoft.DirectX.DirectInput.Manager.GetDevices(Microsoft.DirectX.DirectInput.DeviceClass.GameControl, Microsoft.DirectX.DirectInput.EnumDevicesFlags.AttachedOnly)
    6.         MsgBox(dev.ProductName)
    7.         gamepadDevice = New Microsoft.DirectX.DirectInput.Device(dev.ProductGuid)
    8.         gamepadDevice.RunControlPanel()
    9.         MsgBox(gamepadDevice.Caps.NumberButtons)
    10.     End Sub

    The error I receive is "An unhandled exception of type 'Microsoft.DirectX.DirectInput.DeviceNotRegisteredException' occurred in microsoft.directx.directinput.dll Additional information: Error in the application."

    Any thoughts? How do I register the device in directinput? I cannot figure out what is wrong, if anyone can even point me to ANY VB.NET examples for directinput, that would help greatly. I have found some examples for C/C#, but none for VB.NET. I got what I have so far by trying to take a C example and port it into VB.

    I don't know how to get a device registered with directinput. PLEASE help!!

    BTW if you know how to get a joystick to work with directx 8 and VB.NET, that might also help. I am not stuck on directx 9, but I am having lots of trouble with the code I had for VB6/directx 8 in .NET, because of the "As Any" types that were allowed in VB6 but are not in .NET. They were changed to System.IntPtr and I have no idea what that type even is, let alone how to get the deadzone's System.IntPtr for example! Ahhh, I am new to .NET and already having so many issues!
    Last edited by pjrage; Dec 22nd, 2004 at 02:23 PM.

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