XInputSetState function (xinput.h)

Sends data to a connected controller. This function is used to activate the vibration function of a controller.

Syntax

DWORD XInputSetState(
  [in]      DWORD            dwUserIndex,
  [in, out] XINPUT_VIBRATION *pVibration
);

Parameters

[in] dwUserIndex

Index of the user's controller. Can be a value from 0 to 3. For information about how this value is determined and how the value maps to indicators on the controller, see Multiple Controllers.

[in, out] pVibration

Pointer to an XINPUT_VIBRATION structure containing the vibration information to send to the controller.

Return value

If the function succeeds, the return value is ERROR_SUCCESS.

If the controller is not connected, the return value is ERROR_DEVICE_NOT_CONNECTED.

If the function fails, the return value is an error code defined in WinError.h. The function does not use SetLastError to set the calling thread's last-error code.

Requirements

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

See also

XINPUT_VIBRATION

XInput Functions

XInputGetState