1 / 6

GAM666 – Introduction To Game Programming

GAM666 – Introduction To Game Programming. DirectInput. DirectInput is the part of DirectX 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

Download Presentation

GAM666 – Introduction To Game Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. GAM666 – Introduction To Game Programming DirectInput • DirectInput is the part of DirectX 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)

  2. GAM666 – Introduction To Game Programming DirectInput • Use DirectInput8Create() once to create a LPDIRECTINPUT8 COM object to control all subsequent DirectInput activity • Use its EnumDevices() 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 CreateDevice() function to create a LPDIRECTINPUTDEVICE8 object to handle a specific device

  3. GAM666 – Introduction To Game Programming DirectInput • Once you have a device, use its SetDataFormat() function to identify the structure that will be receiving data • Use its EnumObjects() function to find out about available buttons, axes, etc., supplying your own function to handle each object • Use its SetCooperativeLevel() function to identify how the device is to be shared with other running programs • Use its SetProperty() function to control how it works

  4. GAM666 – Introduction To Game Programming DirectInput • 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 axis

  5. GAM666 – Introduction To Game Programming DirectInput • 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

  6. GAM666 – Introduction To Game Programming DirectInput • To poll an input device (immediate data)use the GetDeviceState() member function to fill up a structure containing a snapshot of the current state of the device • Some devices require calling Poll() before GetDeviceState() [it doesn't hurt to call it even if not necessary] • To get buffered data use the GetDeviceData() function to fill an array of object state changes

More Related