07 02


Delphi Graphics and Game Programming Exposed! with DirectX For versions 5.0-7.0:Input Techniques                       Search Tips   Advanced Search        Title Author Publisher ISBN    Please Select ----------- Artificial Intel Business & Mgmt Components Content Mgmt Certification Databases Enterprise Mgmt Fun/Games Groupware Hardware IBM Redbooks Intranet Dev Middleware Multimedia Networks OS Productivity Apps Programming Langs Security Soft Engineering UI Web Services Webmaster Y2K ----------- New Arrivals









Delphi Graphics and Game Programming Exposed with DirectX 7.0

by John Ayres

Wordware Publishing, Inc.

ISBN: 1556226373   Pub Date: 12/01/99














Search this book:
 



Previous Table of Contents Next Perhaps the easiest to implement, and the most effective in terms of user configuration preferences, is a method by which users can redefine which keys or buttons perform which actions. This could be accomplished by presenting the user with a dialog box containing all available actions and the keys or buttons to which those actions are mapped. This should include keys on the keyboard and buttons on both the mouse and joystick. For example, the trigger button on a joystick may be used to fire a round of bullets in a flight simulator game, by default. However, the user may be more comfortable performing this action with another button. Allowing for the remapping of input methods in this way lets the individual user customize the game to his or her preferences, thus making it more enjoyable to a wider audience. Tip: For an excellent example of an implementation of this technique, take a look at games like Quake and Halflife. DirectInput DirectInput is the DirectX component responsible for providing user input from all manner of input devices, such as keyboards, mice, and game controllers. As with other DirectX components, the DirectInput API is large, and has its own set of requirements and nuances. For some devices, DirectInput programming is almost trivial. For others, it is incredibly complex. DirectInput’s complexity comes from the fact that it was designed to provide input from future game controllers that have not yet been invented. This forward thinking allows developers to provide support for new game controllers without having to rely on a new version of DirectInput. This support comes at the price of obscurity and complexity, but the marketing hook of supporting the latest input device may well be worth the effort. Fortunately, standard input devices such as the mouse and keyboard are relatively easy to interface with. Even joysticks and similar game controllers, while more complex, are not absolutely arcane in their implementation. Features DirectInput offers many features above and beyond what is available through the Win32 API. As with all DirectX components, DirectInput gives the developer more control over user input than the Windows API, while also providing an improvement in performance. DirectInput provides the following features of specific interest to game developers: •  Responsive input retrieval directly from input device hardware •  Support for almost any input device, including mice, keyboards, joysticks, and other game controllers •  Access to force feedback devices for providing tactile output •  Support for multiple input devices attached to the machine, such as two or more keyboards or mice Later in this chapter we will see how DirectInput is used to retrieve user input from the keyboard, the mouse, and standard game controllers such as joysticks. Functional Overview Similar to DirectDraw, DirectInput programming consists of creating a DirectInput object and several DirectInputDevice objects. The DirectInput object itself acts as a liaison between the application and input device drivers. Individual DirectInputDevice objects represent the application’s interface directly to input hardware or, more specifically, that hardware’s device driver. The DirectInput object is used to create individual DirectInputDevice objects, which can then be queried to determine the specific capabilities of the device. The DirectInputDevice object is used to communicate with all input devices. In other words, there is not a separate object type for communicating with keyboards, mice, or joysticks; they are all interfaced through a DirectInputDevice object. This is one of the reasons why DirectInput programming can be complex. The individual methods of a DirectInputDevice object all work with input devices in similar ways according to the context of the type of device. For example, you set device properties through a single function call, yet the properties themselves are dependent upon the device. You can set the range of motion returned from a joystick as a property, but this wouldn’t make any sense if you tried to do the same with a keyboard. However, at the same time that this type of interface introduces a level of complexity, communicating with different devices is very similar in form from device to device. After you’ve grasped a particular concept with one device, it is very easy to apply that knowledge to other devices. This may result in what appears to be some redundancy when we discuss individual devices later in the chapter. However, the information reported by these methods is dependent on the device we are communicating with, making these concepts uniquely different depending on the context in which they are used. Buttons and Axes Where DirectInput is concerned, a button is considered to be any switch that has an on and off position. There is no distinction made between buttons on a mouse, keyboard, or joystick. Bear in mind that just because a device is referred to as a button, it does not necessarily have to be physically represented as a button. A device on a game controller that has a specific on and off position may take the form of a physical toggle switch, but will be treated by DirectInput as a button. Conversely, an axis has a range of positions where its value is affected by the physical movement of a device in some particular direction. Like buttons, axes do not necessarily have a specific physical representation. Joysticks and mice are objects that, generally speaking, represent two axes. However, sliders and dials on joysticks or game controllers and the wheel on a Microsoft IntelliMouse are also axes. Rudder pedals, steering wheels, and flight yokes are other examples of controllers that represent axes. In similar fashion, an axis does not necessarily have an association with any particular direction in space. Joysticks and mice report movement along the x and y axes, which may translate into the movement of a pointer or a change in the direction of flight. However, in the context of a specific game, this information may be used to indicate the depth at which an object is placed or the circular rotation of a dial. This points out that just because an axis may have a specific name, its value is meaningful only in the context in which it is used and does not have to map to any physical direction or movement. While many devices report movement along various axes, the measurement of this movement is dependent on the type of device reporting it. Some devices report axis movement as a relative measurement, which others report it as an absolute measurement. Relative Measurement Some axes can move an infinite distance in a particular direction, and lack a default or “rest” position. An example of this type of axis measurement would be that reported by a mouse. Therefore, the values returned by this type of device are meaningful only in relation to the last measurement taken from the device. Absolute Measurement Other axes can physically only move a specific distance. This would include the movement of the joystick or the movement of dials and sliders on a game controller. These values are typically measured from a fixed point and have a specific range. Previous Table of Contents Next Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.

Wyszukiwarka

Podobne podstrony:
07 02 Koukitu Surface polarity GaN
07 02 Niewybuchy niewypaly
wywiad z Simonem Parkesem 07 02 2016r
US Billboard Top 100 Single Charts 07 02 15 (2015) Tracklista
ZL2 07 02
ZL2 07 02
TI 98 07 02 T pl(1)
07 02
07 02 2016 Metody obliczeniowe
FIDE Trainers Surveys 2013 07 02, Uwe Boensch The system of trainer education in the German Chess
Treść do zadań Gołoś, wytrzymałość 1, 2 termin, 07 02 2012 ogarnijtemat com
TI 98 07 02 GT T pl(1)
02 07
od 02 07 09 do 10 07 09

więcej podobnych podstron