|
-
Dec 22nd, 2004, 01:40 PM
#1
Thread Starter
Addicted Member
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:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim devices As Microsoft.DirectX.DirectInput.DeviceList
Dim dev As Microsoft.DirectX.DirectInput.DeviceInstance
Dim gamepadDevice As Microsoft.DirectX.DirectInput.Device
devices = Microsoft.DirectX.DirectInput.Manager.GetDevices(Microsoft.DirectX.DirectInput.DeviceClass.GameControl, Microsoft.DirectX.DirectInput.EnumDevicesFlags.AttachedOnly)
MsgBox(dev.ProductName)
gamepadDevice = New Microsoft.DirectX.DirectInput.Device(dev.ProductGuid)
gamepadDevice.RunControlPanel()
MsgBox(gamepadDevice.Caps.NumberButtons)
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|