DirectInput explained

In computing, DirectInput is a legacy[1] Microsoft API for collecting input from a computer user, via input devices such as the mouse, keyboard, or a gamepad. It also provides a system for action mapping, which allows the user to assign specific actions within a game to the buttons and axes of the input devices. Additionally it handles haptic feedback (input/output) devices. Microsoft introduced a new input library called XInput specifically for the Xbox 360 controller.

DirectInput and XInput provide benefits over normal Win32 input events:

While DirectInput forms a part of the DirectX library, it has not been significantly revised since DirectX 8 (2001–2002). Microsoft recommends that new applications make use of the Windows message loop for keyboard and mouse input instead of DirectInput (as indicated in the Meltdown 2005 slideshow[2]), and to use GameInput instead of DirectInput and other legacy APIs, such as XInput, for controllers.[3]

History

DirectX included DirectInput from version 1.0 (1995). It initially offered true support only for joysticks, as the mouse and keyboard modules simply provided wrappers to the standard Win32 API. DirectX version 3.0 (1996) added support for keyboards and mice; it also improved joystick support. DirectX 5.0 (1997) included greatly improved joystick support, including adding haptic feedback, increasing the number of buttons, changing the underlying device-driver model and incorporating a COM-based API. Mouse support also increased the number of buttons seen from four to eight. In DirectX 7.0 (1999-), DirectInput added a long-promised feature of seeing individual mice much like individual joysticks, but the feature didn't work with the later released Windows XP, even though it works with Windows 98/Me and DirectX 9. DirectX 8.0 (2000), the last version with major changes, included action mapping and broader support for different types of devices.

While Microsoft initially intended that DirectInput would handle all inputs, this didn't work out. Microsoft no longer recommends using DirectInput for keyboards or mice, and has started pushing the newer XInput for Xbox 360 controllers.[4] In Windows Vista, Windows 7 and later Windows versions, the in-built action mapping UI has been removed.[5] DirectInput is not available for Windows Store apps.

XInput

XInput,[6] a legacy[7] API for "next generation" controllers, was introduced in December 2005 alongside the launch of the Xbox 360. This specification provided support for Xbox 360 controllers in Windows XP SP1 and subsequent operating systems, and is described by Microsoft as being easier to program for and requiring less setup than DirectInput. XInput is compatible with DirectX version 9 and later.

Xbox 360 Controller support

An Xbox 360 Controller, with the default Microsoft driver, has the following limitations with DirectInput, compared to XInput:[8]

According to MSDN, "the combination of the left and right triggers in DirectInput is by design. Games have always assumed that DirectInput device axes are centered when there is no user interaction with the device. However, the Xbox 360 controller was designed to register minimum value, not center, when the triggers are not being held." MSDN proffered the "solution" of combining the triggers, setting one trigger to a positive direction and the other to a negative direction, so no user interaction is indicative to DirectInput of the "control" being at center.[10]

The above, however, ignores the fact that many DirectInput controllers, such as gamepads with dual analog sticks and racing-wheel controller sets, already map triggers and pedals independently. In addition, many DirectInput devices also have vibration effects. At least one 3rd-party driver, XBCD, gives the Xbox 360 controllers the vibration support, dead zones and (optionally) independent analog/digital triggers through DirectInput its XInput driver possesses.[11] This suggests that Microsoft's Xbox 360 controller driver was given intentionally weaker DirectInput support, rather than due to any differences between DirectInput and XInput APIs. On the other hand, Xbox 360 controllers using XInput support only very basic control of vibration motors[12] [13] in contrast with greater palette of effects supported via DirectInput.[14]

External links

Notes and References

  1. Web site: DirectInput.
  2. Web site: Meltdown 2005 slideshow (.zip) . 2012-11-13 . bot: unknown . https://web.archive.org/web/20150521162503/http://download.microsoft.com/download/b/0/0/b0095d07-01fe-47f1-ad3c-fc463f88ef83/Meltdown2005.zip . 2015-05-21 .
  3. Web site: Overview of GameInput . GameInput introduction, "Getting started" . GameInput is the recommended API for all new code, regardless of the target platform, because it provides support across all Microsoft platforms (including earlier versions of Windows), and provides superior performance versus legacy APIs..
  4. Web site: Taking Advantage of High-Definition Mouse Movement . MSDN . Microsoft . 2009-01-25.
  5. Web site: DirectInput ConfigureDevices in Windows Vista . 2008-12-27 . 2012-11-13 . dead . https://web.archive.org/web/20081227003119/http://forums.microsoft.com/msdn/showpost.aspx?postid=1198467&siteid=1 . December 27, 2008 .
  6. Web site: Comparison of XInput and DirectInput features - Win32 apps Microsoft Docs.
  7. Web site: Overview of GameInput .
  8. Web site: Comparison of XInput and DirectInput features - Win32 apps Microsoft Docs.
  9. Web site: XInputGetAudioDeviceIds function. MSDN. 10 December 2013.
  10. Web site: XInput and DirectInput . Microsoft . 2012-09-17 . 2012-12-27.
  11. Web site: DirectInput ConfigureDevices in Windows Vista . 2020-07-17 . dead . https://web.archive.org/web/20110425142352/http://www.matt-land.com/xbcd/ . April 25, 2011 .
  12. Web site: Gamepad - Rumbler Control . https://web.archive.org/web/20090313051343/http://free60.org/wiki/GamePad#Rumbler_Control. 2009-03-13 . Free60 Project . 2009-01-25.
  13. Web site: XINPUT_VIBRATION . Msdn.microsoft.com . 2009-01-25.
  14. Web site: DIEFFECT . MSDN . Microsoft . 2009-01-25.