XInputEnable function (xinput.h)

Sets the reporting state of XInput.

Syntax

void XInputEnable(
  [in] BOOL enable
);

Parameters

[in] enable

If enable is FALSE, XInput will only send neutral data in response to XInputGetState (all buttons up, axes centered, and triggers at 0). XInputSetState calls will be registered but not sent to the device. Sending any value other than FALSE will restore reading and writing functionality to normal.

Return value

None

Remarks

This function is meant to be called when an application gains or loses focus (such as via WM_ACTIVATEAPP). Using this function, you will not have to change the XInput query loop in your application as neutral data will always be reported if XInput is disabled.

In a controller that supports vibration effects:

  • Passing FALSE will stop any vibration effects currently playing. In this state, calls to XInputSetState will be registered, but not passed to the device.
  • Passing TRUE will pass the last vibration request (even if it is 0) sent to XInputSetState to the device.

Windows 10 or later: Deprecated, as game controller input is automatically enabled/disabled by the system based on the application window focus.

Platform Requirements

Windows 8 (XInput 1.4), DirectX SDK (XInput 1.3)

Requirements

Requirement Value
Target Platform Windows
Header xinput.h
Library Xinput.lib
DLL Xinput1_4.dll

See also

XINPUT_GAMEPAD

XINPUT_STATE

XInput Functions

XInputGetState

XInputSetState