I have written this simple wrapper for Joystick API's (attached). Just rename the file to a .vb extension and its ready for use.

If you are writing a game in VB and want stick support then include this file in your project (or compile it into a dll) and use instances of it in your code.

To create an instance:

VB Code:
  1. Dim Stick as Joystick
  2.     If Joystick.SticksPresent() =1 Then
  3.         Stick = New Joystick(0) 'bind to first stick
  4.     End If

The argument in the constructor tells the program which joystick you want to bind this instance to. You might have more than one stick plugged in so this number will vary depending which one(s) you are going to use.

This class provides axis data in the normal format and also in a relative format...

Calling XAxisRelative() will return values from -1 (left) to +1 (right) data type is single. Y and Z axis data is available in the same way.

I only have 1 joystick myself and so I need people with more than one stick plugged in to try to access the stick data.

Call the Refresh() sub to bring the data in the class up to date.

Have a look through the code to get the hang of it, its pretty simple

To test for 2 joystick compatibility, plug in both of your sticks, and use 2 instances of the class, bind one of them to 0 and the other to 1 using the constructor argument)

Then use a timer to refresh() each joystick (timer interval of 50 is fine). Then take some info from each joystick and show it on the form (I use a label to display the XAxisRelative() values).

Stick left should be approximately -1 (this can vary, and be as small as -0.5 on some sticks)

Then move both sticks simultaneously in random directions, the data for both sticks should change on the labels.

I probably haven't explained this well (sorry) so please let me know if you can't get it working.

Thanks for reading