Integrating Joystick w/ DirectX9.0 and VB.net

I had successfully integrated a joystick using VB6 and DirectX8.0 (?) a few years ago. I wanted to do the same thing with newer technology...

I recently purchased VB.NETand a joystick thinking that the taks would be a cut and paste of old code with some minor modifications. I found that I can't download DirectX 8.0, and now I must accept 9.0. It seems as if every thing is skewed towards C# & C++ now regarding joysticks...

My simple question: If I download 9.0 SDK (Managed code) will I be able to 'enumerate' the device and read it using VB.NET?

Advanced question: I noticed that 8.0 SDK method SetCooperativeLevel expected a windows handle that was type 'long', which is now 'int32' (or something similar). Is this a 16-bit to 32-bit incompatibility which I've read about but never experienced?

[824 byte] By [KJ555] at [2007-12-23]
# 1

I recently purchased VB.NETand a joystick thinking that the taks would be a cut and paste of old code with some minor modifications.

As you've probably found out, VB.Net is very different from VB6. I had a go with VB.Net shortly after it appeared in VS2002, and found that whilst you could write a lot of code in a similar way to how I did with VB4/5/6 it generally wasn't the correct way to do things.

You'll probably find it best if you assume that VB6 and VB.Net are two different platforms - and you have to write code differently on both. Hopefully your knowledge of VB6 should make it a fairly easy transition Smile

It seems as if every thing is skewed towards C# & C++ now regarding joysticks...

Writing applications with DirectX is now typically in two categories - "Managed" (C#, VB.Net etc...) and "Native" (C/C++).

Reading through the C# tutorials, samples and general documentation is probably the closest you'll get to any missing VB.NET material.

If I download 9.0 SDK (Managed code) will I be able to 'enumerate' the device and read it using VB.NET?

Unfortunately I'm not a 'managed' programmer so I can't say for sure - but based on my general knowledge of the area I don't see why you wouldn't be able to access the joystick via VB.NET. Maybe someone else will reply to this thread with some better details.

a windows handle that was type 'long', which is now 'int32' (or something similar). Is this a 16-bit to 32-bit incompatibility which I've read about but never experienced?

IIRC, in VB6 the "Integer" datatype was a signed 16bit value and "Long" was a signed 32bit value. In this particular instance it's just a case of a name-change... under the covers it's pretty much the same thing Smile

hth
Jack

JackHoxley at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 2
KJ555 wrote:

My simple question: If I download 9.0 SDK (Managed code) will I be able to 'enumerate' the device and read it using VB.NET?

The simple answer is "yes". Actually the C# examples in the SDK should serve you just fine for this. The way that managed DirectX is used is identical between the two. Simply add the appropriate DirectX references (for a joystick it would be Microsoft.DirectX.DirectInput). For instance, to get a list of conneted devices, the C# call:
...
DeviceList myList =
Manager.GetDevices(DeviceClass.GameControl, EnumDeviceFlags.AttachedOnly));
...

will be identical in VB.NET.

What you will need to do is replace the C# syntax for control structures, etc. with their VB counterpart.

dmcrews4202 at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 3

Thank you Jack and dmcrews.

KJ555 at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 4
thank you
cakalfurkan44 at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 5
quero baixar
AndersonFariasCarneiro at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 6
KJ555 wrote:

I had successfully integrated a joystick using VB6 and DirectX8.0 (?) a few years ago. I wanted to do the same thing with newer technology...

I recently purchased VB.NETand a joystick thinking that the taks would be a cut and paste of old code with some minor modifications. I found that I can't download DirectX 8.0, and now I must accept 9.0. It seems as if every thing is skewed towards C# & C++ now regarding joysticks...

My simple question: If I download 9.0 SDK (Managed code) will I be able to 'enumerate' the device and read it using VB.NET?

Advanced question: I noticed that 8.0 SDK method SetCooperativeLevel expected a windows handle that was type 'long', which is now 'int32' (or something similar). Is this a 16-bit to 32-bit incompatibility which I've read about but never experienced?

bora237 at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...