DirectInput - DirectInput Vs XInput

DirectInput Vs XInput

Microsoft has not made any major changes to DirectInput since DirectX 8, and introduced XInput later in DirectX 9: there remains some confusion about the current status and future of the two APIs. As of 2011 each has unique features not present in the other, and neither had major updates since the release of DirectX 9 (2002).

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

  • the left and right triggers will act as a single axis representing the signed difference between the triggers, not as independent analog axes
  • vibration effects will not operate
  • querying for headset devices will not operate

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.

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 driver, XBCD, gives the Xbox 360 controllers the vibration support, dead zones and (optionally) independent triggers through DirectInput. This suggests that Microsoft's Xbox 360 controller driver intentionally has weaker DirectInput support, rather than due to any differences between DirectInput and XInput APIs. On the other hand, Xbox 360 controller and XInput support only very basic control of vibration motors in contrast with great palette of various effects supported by DirectInput.

The XInput API also as of 2010 has limits that DirectInput does not:

  • XInput supports only "next generation" controllers. This limits it basically to controllers for the Xbox 360 that also have Windows drivers. Legacy Windows controllers, joysticks and generalized force-feedback devices are not supported.
  • XInput supports a maximum of four controllers at a time. This is an Xbox limit, carried over to Windows. Although as of 2010 few PC games require more than four controllers at once, DirectInput itself has no such limitation.
  • XInput does not support keyboards, mice, or mouse-type devices. While this mirrors Microsoft's recommendation not to use DirectInput with these devices, programmers can use DirectInput with these devices.
  • XInput supports maximum of 4 axes, 10 buttons, 2 triggers and 8-direction digital pad per controller, compared to DirectInput's support for 8 axes, 128 buttons, and full-range POV. (Incidentally, the number of axes, buttons and triggers XInput supports corresponds directly to the Xbox 360 controller.)

As of 2011 XInput is for Xbox 360 controllers, while DirectInput is for any controller.

Read more about this topic:  DirectInput