Chapter 7 -- Keyboard and Joystick Input

[Previous] [Next]

Chapter 7

As you know, the focus of this book is Microsoft Direct3D Immediate Mode. However, it's impossible to create a quality Direct3D application without using a few other Microsoft DirectX components. The additional three DirectX components this book covers are DirectDraw (described in Chapter 3), DirectInput (covered in this chapter), and DirectPlay (Chapter 15). We went over DirectDraw early in the book because it's an integral component of Direct3D and it isn't possible to explain Immediate Mode without covering at least the basics of DirectDraw. We'll continue to discuss aspects of DirectDraw because it is so integral to Direct3D.

DirectInput, on the other hand, isn't a requirement for creating a Direct3D-based application. If you create a Direct3D-based application that doesn't require any user input (such as a stand-alone demonstration program), you can get away with using only two DirectX components: DirectDraw and Direct3D. Furthermore, if speed and efficiency aren't issues, you can use the Microsoft Windows messages and APIs to acquire user input rather than using DirectInput.

However, for most useful 3D applications—such as games or simulations—you can't create a program without using an efficient form of input. DirectInput provides support for using input devices such as keyboards, mouse devices, joysticks and other game controllers, and force-feedback devices. The most important reason many developers use DirectInput is that it provides faster, more flexible access to input data by communicating directly with the hardware drivers rather than relying on Windows messaging. This way, DirectInput avoids the delays Windows can normally impose on software.

You access DirectInput via the DirectInput object, which supports the IDirectInput7 COM interface, and a DirectInputDevice2 object associated with each individual control or switches such as keys, buttons, axes, or even an individual force-input device that provides data. Each input device has object instances, which are feedback effects.

NOTE
To use DirectInput in your programs, you need to remember to include dinput.lib when you build your project so that the DirectInput library is included in your build.



Inside Direct3D
Inside Direct3D (Dv-Mps Inside)
ISBN: 0735606137
EAN: 2147483647
Year: 1999
Pages: 131

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net