XINPUT and Windows 8

The Windows 8 Consumer Preview includes version 1.4 of the XInput API for use with Xbox 360 Common Controller compatible game devices, and this API is fully supported for both Windows Store apps (including x86, x64, and Windows on ARM) and desktop Win32 applications. The full details of the differences compared to XInput 1.3 which shipped in the DirectX SDK (June 2010) release are addressed on MSDN. The headers and libraries for Xinput 1.4 are included in the Windows SDK 8.0 that is part Visual Studio 11 Beta. Windows 8 also includes an updated driver for these devices, XUSB22.SYS.

Update: This information also applies to Windows 8 Release Preview / RTM and Visual Studio 2012 RC / RTM. XINPUT 1.4 is supported on Windows RT as well.

REDIST: For XInput 1.4 on Windows 8 and Windows RT, no redistribution is required since XInput 1.4 is included with the OS. For XInput 9.1.0 on Windows Vista, Windows 7, or WIndows 8, no redistribution is required since XInput 9.1.0 is included with the OS. For XInput 1.3 on any version of Windows, use the legacy DirectX SDK REDIST.

Since Xinput version 1.4 is not available on Windows 7, Win32 desktop games that support older versions of Windows can use either XInput 1.3 or the still supported older XInput 9.1.0 which is included in Windows Vista, Windows 7, and Windows 8.

  • When building an application that is ‘down-level’ using headers in the Windows 8.0 SDK, be sure to explicitly select the correct ‘minimum’ _WIN32_WINNT value. For Windows 8, that is 0x0602 (which is the default when building code with Visual Studio 2012 and for all Windows Store apps). For Windows 7 use 0x0601, and for Windows Vista use 0x0600. Typically this is done as part of the project configuration via Preprocessor Definitions.

If you set _WIN32_WINNT correctly and try building with the Windows 8.0 SDK version of the xinput.h header, you will be using XInput 1.4 if set to 0x0602, or XInput 9.1.0 otherwise. If using XInput 1.4, you should link with XINPUT.LIB. If using XInput 9.1.0, link with XINPUT9_1_0.LIB instead.

If your usage of XInput is limited to basic gamepad functionality via XInputGetState and XInputSetState, then XInput 9.1.0 may be all the functionailty you require and is supported on a broad range of Windows OSes without the need to use the DirectSetup redistribution package. A few things to note about XInput 9.1.0 are that XInputGetCapabilities returns a fixed set of values regardless of the attached device (notably including the subtype), and this version of XInput does not support headset audio functionality.

The following code will compile using all three versions of XInput:

 #include <xinput.h>

memset( &state, 0, sizeof(XINPUT_STATE) );

if( XInputGetState( 0, &state ) == ERROR_SUCCESS )
// Controller is connected
if ( state.Gamepad.wButtons & XINPUT_GAMEPAD_A )
// Button A is pressed

memset( &motor, 0, sizeof(XINPUT_VIBRATION) );

if ( state.Gamepad.bLeftTrigger > XINPUT_GAMEPAD_TRIGGER_THRESHOLD )
motor.wLeftMotorSpeed = state.Gamepad.bLeftTrigger << 8;

if ( state.Gamepad.bRightTrigger > XINPUT_GAMEPAD_TRIGGER_THRESHOLD )
motor.wRightMotorSpeed = state.Gamepad.bRightTrigger << 8;

XInputSetState( 0, &motor );

// Controller is not connected, shouldn't recheck it for a few seconds

If using the XInput 1.3 solution, You should follow the instructions on MSDN to use the Windows 8.0 SDK headers and libraries where possible and explicitly link to the DXSDK_DIR for the headers where you need older versions to support older versions of Windows. (see “Where is the DirectX SDK?“).

In a future post, I’ll address the details of using XInput 1.4’s audio features, and how to implement similiar behavior down-level using XInput 1.3. XInput 9.1.0 doesn’t support audio features.

Note: The Windows 7.1 SDK includes the xinput.h header and xinput.lib import library for the the Xinput 9.1.0 version as well. XInput 9.1.0 can be deployed on Windows XP using the legacy DirectX SDK’s REDIST (aka DirectSetup).

Windows Server: Note that XInput is not included in Windows Server 2012. XInput 9.1.0 is also not present on Windows Server 2008 or 2012.

Xbox One Controller: The Xbox One controller is not supported by the XUSB21.SYS (Windows 7) or XUSB22.SYS (Windows 8.x) driver. There is a X1USB1.SYS driver now available which does support the Xbox One Controller for XINPUT when using a micro-USB cable–the Xbox One controller is not compatible with the Xbox 360 Wireless Receiver for Windows.

Windows 10: To continue to use XInput 1.4 with universal Windows apps, be sure to link with xinputuap.lib rather than xinput.lib. Alternatively, you can make direct use of the new Windows.Gaming.Input API or the GamePad class in DirectX Tool Kit.

Related: XInput Win32 Samples, Game controller sample

Comments (7)

  1. v00d00m4n says:

    Way to fail MS!

    Making DX 11.1 , Xinput 1.4 and few other DX features artificially  Windows 8 exclusive without releasing proper updates of DX for XP, Vista and 7 not going to boost sales of crappy Win 8!

    I smell bad greedy marketing, same as i seen with VIsta… which failed because of same mistakes as Win 8 marketing shows! MS dont be Apple!

    There is no real reason for no releasing xinput 1.4 for XP-7 range!

  2. walbourn says:

    This charge has been basically made every release of Windows since 2004, so I doubt there's much I can say to make you feel better about the technical merits of the decision.

    What feature of XINPUT 1.4 that is not available in XINPUT 1.3 are you finding yourself needing to use?

    FWIW, at least some portion of DirectX 11.1 is down-level for Windows 7.

    Windows Vista officially hit the end of mainstream support last year.

    No version of Direct3D beyond 9 is available on Windows XP, so it would be strange to expect 11.1 to appear on Windows XP given it is well past it's lifecycle.

  3. edward duffy says:

    do I have to go back to windows 7 to play crisis 3

  4. walbourn says:

    @Edward – That's a question for Crytek and/or Electronic Arts. Windows 8 x86 and Windows 8 x64 generally have excellent compatibility with Windows 7 applications, but as with every major OS release there are minor issues that might need addressed by the developer. Developers should review this post and the appcompat cookbook.

  5. tsw says:

    any examples on using Xinput with C# for WinRT and WSA?  I'm digging around, but only finding the 8.1 sample of 'controller sketch' here:…/sourcecode

    I guess I could use the CPP and do a WinMD for it… but not even sure where to start for that.. any suggestions would be helpful!

  6. walbourn says:

    SharpDX has a pretty solid set of C# wrappers for DirectX.

  7. ronaldo says:

    how to download this one ya