Game Development Reference
Why do we never have time to do it right, but always have time to do it over?
The Principle of Feedback (Chapter 7, “Fundamentals of User Interface Design”)
is perhaps the most important concept of application design. This principle entails
visual cues that easily describe the state of the application, but this principle also
covers responsiveness of the user interface and cues related to waiting periods.
The standard Microsoft Windows message pump typically works well for most
applications, but applications that update their state each time the mouse is moved
can suffer from performance penalties. This is usually felt by applications that
employ the use of 3D real-time graphics technologies like Direct3D.
The Microsoft DirectX library has a technology called DirectInput that communi-
cates directly with device hardware drivers, completely avoiding the Microsoft
Windows message pump. DirectInput offers considerable performance boosts over
the message pump, and also supports asynchronous polling and data buffering.
This chapter focuses on using DirectInput to asynchronously read the mouse and
keyboard devices. The mouse positions are expressed as deltas (difference) between
the current and last positions. This chapter also shows how to read the mouse but-
tons. This is a useful technique for using the mouse to control a 3D camera. You will
also learn how to check whether a key is depressed on the keyboard.