> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XInputSetState

> XInputSetState

# XInputSetState

将振动数据发送到指定的双电机控制器。

<a id="syntaxSection" />

## 语法

```cpp theme={null}
DWORD XInputSetState(  
         DWORD dwUserIndex,  
         const XINPUT_VIBRATION * pVibration  
)  
```

<a id="parametersSection" />

### 参数

*dwUserIndex*   \_In\_\
类型：DWORD

与设备关联的玩家索引；取值范围为 0 到 `XUSER_MAX_COUNT - 1`。

*pVibration*   \_In\_\
类型：[XINPUT\_VIBRATION](/reference/input/xinputongameinput/structs/xinput_vibration)\*

指向 [XINPUT\_VIBRATION](/reference/input/xinputongameinput/structs/xinput_vibration) 对象的指针，其中包含要发送到控制器的振动信息。

<a id="retvalSection" />

### 返回值

类型：DWORD

如果函数成功，则返回 `ERROR_SUCCESS`。

如果未连接控制器，函数将返回 `ERROR_DEVICE_NOT_CONNECTED`。

如果函数失败，将返回 WinError.h 中定义的错误代码。

<a id="remarksSection" />

## 备注

此函数支持仅具有两个触觉反馈电机的较旧控制器。要支持较新控制器中的其他反馈电机，请调用 [XInputSetStateEx](/reference/input/xinputongameinput/functions/xinputsetstateex)。

有关详细信息，请参阅 [XInputOnGameInput 包装器](/build/core-features/common/input/porting/input-porting-xinput#xinputWrapperSection)。

<a id="requirementsSection" />

## 要求

**头文件：** XInputOnGameInput.h

**库：** xgameruntime.lib

**支持的平台：** XBOX One 系列主机和 XBOX Series 主机

<a id="seealsoSection" />

## 另请参阅

[从 XInput 移植到 GameInput](/build/core-features/common/input/porting/input-porting-xinput)\
[XInputOnGameInput](/reference/input/xinputongameinput/xinputongameinput_members)


## Related topics

- [XInputSetStateEx](/zh-CN/reference/input/xinputongameinput/functions/xinputsetstateex.md)
- [XInputEnable](/zh-CN/reference/input/xinputongameinput/functions/xinputenable.md)
- [XINPUT_VIBRATION_EX](/zh-CN/reference/input/xinputongameinput/structs/xinput_vibration_ex.md)
- [从 XInput 移植到 GameInput](/zh-CN/build/core-features/common/input/porting/input-porting-xinput.md)
- [XInputOnGameInput](/zh-CN/reference/input/xinputongameinput/xinputongameinput_members.md)
