GAM 666 Introduction To Game Programming Direct Input

  • Slides: 6
Download presentation
GAM 666 – Introduction To Game Programming Direct. Input is the part of Direct.

GAM 666 – Introduction To Game Programming Direct. Input is the part of Direct. X for managing input devices, such as keyboard, mouse and joystick ●Supports both digital (buttons, D-pads) and analog (sliders, joystick axes, mouse axes) objects on a device ●Can handle relative (e. g. mouse axes) and absolute (e. g. Joystick axes) analog objects ●Data coming from the device can be buffered or immediate (in which case you poll the device) ●Also controls force feedback joysticks (input device used for output) ●

GAM 666 – Introduction To Game Programming Direct. Input Use Direct. Input 8 Create()

GAM 666 – Introduction To Game Programming Direct. Input Use Direct. Input 8 Create() once to create a LPDIRECTINPUT 8 COM object to control all subsequent Direct. Input activity ●Use its Enum. Devices() function to enumerate available devices of the desired type, supplying your own function to handle each matching device (e. g. to find each one's GUID) ●Use its Create. Device() function to create a LPDIRECTINPUTDEVICE 8 object to handle a specific device ●

GAM 666 – Introduction To Game Programming Direct. Input Once you have a device,

GAM 666 – Introduction To Game Programming Direct. Input Once you have a device, use its Set. Data. Format() function to identify the structure that will be receiving data ●Use its Enum. Objects() function to find out about available buttons, axes, etc. , supplying your own function to handle each object ●Use its Set. Cooperative. Level() function to identify how the device is to be shared with other running programs ●Use its Set. Property() function to control how it works ●

GAM 666 – Introduction To Game Programming Direct. Input Any absolute axis you have

GAM 666 – Introduction To Game Programming Direct. Input Any absolute axis you have must be configured before use, setting the at least the following properties: ●DIPROP_RANGE – the minimum and maximum values returned by the axis ●DIPROP_DEADZONE – the percentage play (i. e. area where there is no change in input) at the middle of the axis (in hundreths of a percent) ●DIPROP_SATURATION – the percentage play at the end of the ●

GAM 666 – Introduction To Game Programming Direct. Input When specifying a device object

GAM 666 – Introduction To Game Programming Direct. Input When specifying a device object such as an axis or a button, you can identify it by offset (i. e. position in the structure receiving the data) or by ID (available when enumerating device objects) ●Before being able to read from the device it must be Acquire()ed ●At any time the device might be taken from the program, in which case it must be Acquire()ed again ●

GAM 666 – Introduction To Game Programming Direct. Input To poll an input device

GAM 666 – Introduction To Game Programming Direct. Input To poll an input device (immediate data)use the Get. Device. State() member function to fill up a structure containing a snapshot of the current state of the device ●Some devices require calling Poll() before Get. Device. State() [it doesn't hurt to call it even if not necessary] ●To get buffered data use the Get. Device. Data() function to fill an array of object state changes ●