Main Site Links Resources Tutorials
News VB Gaming Code Downloads DirectX 7
Contact Webmaster VB Programming Product Reviews DirectX 8
  General Multimedia Articles DirectX 9
      Miscellaneous

DirectInput: Mouse control
By: Jack Hoxley
Written: June 2000

Download: DI_Mouse.Zip (14kb)


Using the mouse really only benefits two main use:

  1. C/C++ developers who already have to program their own mouse control (to a certain extent).
  2. VB developers that are using the Win32 libraries to create their own forms. See Win32 Windows Tutorial

To a standard VB developer, the form window will probably provide enough control of the mouse for all but the most complicated programs. The DirectInput mouse section does make it easier to get information about the mouse; including scroll wheels and additional buttons.

There is one big down side to it all though; you cant use it if you're using the Win32 Window library (see above). This is because this program requires the use of DirectXEvent - which can only be declared in an object module (ie, a form; not a module or class). Which makes it slightly pointless to use the Win32 libraries as shown on my page.... oh well...

DirectInput mouse can handle up to 4 buttons and 3 axis:

  • Button0 and Button1 are the normal Left/Right buttons. Button2 and Button3 are found on the more flashy mice -Button2 tends to either be the scrollwheel button or the middle button. Despite what you may have heard/read, VB can only use up to 4 buttons. C++ on the other hand can use up to 8.
  • AxisX and AxisY are the normal Left/Right/Up/Down entries. Axis Z represents the movement on the Z axis. It is unlikely that you'll need the Z axis.

When you use DirectInput Mouse you will be responsible for the mouse completely. Whilst the mouse is in your control windows will ignore it - it wont track it's position, it wont show the default cursor, and it wont send any messages about it (to you or other applications). It is therefore possible to gain a lot of control form this; you have to read the mouse coordinates; and you have to set the sensitivity - allowing you to customise the mouse's behaviour, and you can also set the cursor easily - allowing for animated cursors (nothing particularly new).

Because of the way the tutorial is designed it is better for you to download it. It is very well commented, and will explain everything you need to know. You can get it from the top of this page; or from my downloads page.

DirectX 4 VB © 2000 Jack Hoxley. All rights reserved.
Reproduction of this site and it's contents, in whole or in part, is prohibited,
except where explicitly stated otherwise.
Design by Mateo
Contact Webmaster