ppt title - PowerPoint PPT Presentation

1 / 38
About This Presentation
Title:

ppt title

Description:

Determine ID of key that is pressed. Call IDirectInputDevice8::GetProperty to recover the string ... If button pressed past threshold, it is 'active' ... – PowerPoint PPT presentation

Number of Views:34
Avg rating:3.0/5.0
Slides: 39
Provided by: spea2
Category:
Tags: ppt | pressed | title

less

Transcript and Presenter's Notes

Title: ppt title


1
(No Transcript)
2
DirectInput 9.0 C. Shane Evans / Bernard
George Program ManagerDirectX Microsoft
Corporation
3
Agenda
  • Mission Usability
  • New Features
  • Improvements
  • Whats Next?

4
New Features
  • Frame-based Input
  • Keyboard Text
  • New Device Enumeration Model
  • New Device Object Enumeration Model
  • Device Plug/Unplug Notifications
  • Modern Device Support

5
Frame-based Input
  • Motivation
  • State tracking of buttons and axes are common to
    the most games
  • Games are inherently frame-based
  • Why isnt DirectInput also frame-based?
  • Advantages
  • Application does not need to parse buffered data
  • Objects current states are reported
  • Developers wont complain (as much)!

6
Frame-based Input
  • Application can query DirectInput for events
    since the last frame
  • Data reported in each frame is tailored to
    particular controls on a device
  • Buttons
  • Relative Axes
  • Absolute Axes/POVs

7
Frame-based InputButtons
  • Four states to summarize the state of a button
  • Inactive
  • Active
  • Still Active
  • Changed/Still Active

8
Frame-based InputRelative Axes
  • Multiple axis events may occur between frames
  • Actual input is lt 15 20 30 3 10 8 gt
  • To smooth these axes events, DirectInput
    reports their average
  • Application receives lt 15 25 3 9 gt

9
Frame-based InputAbsolute Axes/POVs
  • DirectInput simply reports the current position
    of absolute axes
  • POVs are reported with the current single
    position (still as angle from N).
  • Single report is given because thats what games
    use.

10
Frame-based InputCommon Data
  • The following detailed data is provided for all
    types of controls for each frame
  • dwCurrent
  • Current value of the control
  • dwStart
  • Value at beginning of frame
  • dwMin
  • Minimum value at during frame
  • dwMax
  • Maximum value at during frame

11
Keyboard Text
  • Motivation
  • Constructing strings by treating keys as objects
    and retrieving DIPROP_KEYNAME can be cumbersome
  • Declare a DIPROPSTRING variable
  • Determine ID of key that is pressed
  • Call IDirectInputDevice8GetProperty to recover
    the string
  • Can be slow as well, since the a keys text is
    looked up on the fly

12
Keyboard Text
  • Application can enable new text input with
    IDirectInput9EnableKBText
  • An internal lookup table for keys is created
  • Key lookups are much faster
  • Application must keep track of the state of the
    shift key
  • Call IDirectInput9GetKeyText with the keys
    object ID and shift status to recover a keys
    text

13
New Device Enumeration Model
  • Motivation
  • General shift toward pull model in DirectX
  • Callback functions can be complicated
  • Advantages
  • Developer has more control
  • Simpler!

14
New Device Enumeration Model
  • Application can call IDirectInput9GetDeviceCount
    to retrieve the number of devices on the system
  • Flags can optionally be passed to indicate that
    only subset of available devices should be
    enumerated
  • Each device is internally assigned an index
    between 0 and the number of pertinent devices 1
    inclusive

15
New Device Enumeration Model
  • Devices are now addressed by index
  • IDirectInput9CheckDevice can test a devices
    capabilities
  • Force feedback
  • Action mapping

16
New Device Enumeration Model
  • As before, devices are created by calling
    CreateDevice method
  • Accepts device index
  • Sets a pointer to an IDirectInputDevice9
    interface
  • Dont need to set co-op level!
  • Otherwise IDirectInput9 can be used as you would
    expect

17
New Device Object Enumeration Model
  • Pull model as with device enumeration
  • Application can call IDirectInputDevice9GetObjec
    tCount to retrieve the number of objects on a
    device
  • Flags can optionally be passed to indicate that
    only subset of available objects should be
    enumerated
  • Each object is internally assigned an index
    between 0 and the number of pertinent objects 1
    inclusive

18
New Device Object Enumeration Model
  • Each object can now be referenced by its index
  • Calling IDirectInputDevice9GetObject retrieves
    a DIDEVICEOBJECTINSTANCE structure
  • dwOfsNative member added to DIDEVICEOBJECTINSTANCE

19
Plug/Unplug Notifications
  • Applications can request to be notified when a
    device is plugged in or unplugged
  • Call RegisterWindowMessage with
    DIRECTINPUT_NOTIFICATION_DEVICEPLUG message
    string (dinput.h)

20
Plug/Unplug Notifications
  • When a DIRECTINPUT_NOTIFICATION_DEVICEPLUG
    message is received
  • wParam is the devices index
  • lParam indicates the devices status
  • 0 value means the device is now unplugged
  • Nonzero means the device is now plugged in

21
Plug/Unplug Notifications
  • If a device is new to an application
  • wParam is 0xFFFFFFFF
  • lParam is nonzero (plugged)
  • The device can be created by calling CreateDevice
    with the index previously returned by
    GetDeviceCount 1

22
Modern Device Support
  • Support for new controls on todays complex
    devices
  • Proportional Buttons
  • Independent Axis Sets

23
Modern Device Support
  • Proportional Buttons
  • dwButtonData member added to DIDEVICEOBJECTDATA
    to represent degree to which button is pressed
  • Can also behave like standard buttons
  • If button pressed past threshold, it is active
  • Threshold implemented in property
    DIPROP_BUTTONTHRESHOLD
  • IDirectInputGet/SetButtonThreshold can
    manipulate threshold
  • Default is 10 of range

24
Modern Device Support
  • Independent Axis Sets
  • Mainly a hardware thing. Games should see better
    mappings from DirectInput.
  • Simple way of organizing axes on a device
  • Sets of axes are assigned ordinals
  • Ordinals differentiate between multiple, say, X -
    axes

25
Improvements
  • Joystick Control Panel
  • Default Cooperative Level
  • Simpler Device Properties

26
Joystick Control Panel
  • Test page
  • Device image added
  • Historically confusing Apply button removed

27
Joystick Control Panel
  • Settings Page
  • Racing Wheels pedal mode configuration for legacy
    games
  • Historically confusing Apply button removed

28
Joystick Control Panel
  • Calibration
  • Better use of space in calibration wizard
  • Additional racing wheel-specific calibration
  • New steering wheel position indicator
  • Accelerator/Brake discovery and calibration

29
Joystick Control Panel
30
Joystick Control Panel
31
Joystick Control Panel
32
Default Cooperative Level
  • Cooperative level need not be explicitly set
  • Default cooperative level set during device
    creation
  • Similar to DISCL_FOREGROUND DISCL_NONEXCLUSIVE
    with added benefits
  • Works for Force Feedback devices

33
Default Cooperative Level
  • Devices do not need to be explicitly reacquired
  • Use DISCL_FOCUSACQUIRE in IDirectInputDevice9
    SetCooperativeLevel
  • Automatic acquisition when application gains
    focus
  • Only valid with foreground cooperative levels

34
Simpler Device Properties
  • Separate methods to set each property rather than
    just IDirectInputDevice8Get/SetProperty
  • MUCH simpler than before

35
Simpler Device PropertiesDirectInput 8.0 Example
  • For example, the following code is needed to set
    the range of the X-axis with DirectInput 8.0
  • // DirectX 8.0 code for changing a
  • // property
  • DIPROPRANGE diprg
  • ZeroMemory(diprg, sizeof(diprg))
  • diprg.diph.dwObj DIJOFS_X
  • diprg.lMin -1000
  • diprg.lMax 1000
  • err pDIDev-gtSetProperty(DIPROP_RANGE,
    diprg.diph)

36
Simpler Device PropertiesDirectInput 9.0 Example
  • The same task can now be done with the following
    code
  • // Equivalent DirectX 9.0 code
  • err pDIDev-gtSetAxisRange(AXIS_X, -1000,
    1000)

37
Device Image Display Object
  • SDK sample code that performs simple device image
    rendering tasks
  • Very easy to incorporate device images into your
    game
  • Exposes simple methods to perform common but
    often code-intensive tasks
  • Display device
  • Change view
  • Show callout, display text
  • Highlight callout

38
DirectInput 9.0
  • Questions?
  • Contact ShaneE_at_microsoft.com
Write a Comment
User Comments (0)
About PowerShow.com