> ## 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.

# XInputSetStateEx

> XInputSetStateEx

# XInputSetStateEx

將震動資料傳送至指定的控制器。支援新型控制器的四馬達震動功能。

<a id="syntaxSection" />

## 語法

```cpp theme={null}
DWORD XInputSetStateEx(  
         DWORD dwUserIndex,  
         const XINPUT_VIBRATION_EX * pVibration  
)  
```

<a id="parametersSection" />

### 參數

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

與裝置相關聯之玩家的索引；值的範圍為 0 到 `XUSER_MAX_COUNT - 1`。

*pVibration*   \_In\_\
類型：[XINPUT\_VIBRATION\_EX](/zh-TW/reference/input/xinputongameinput/structs/xinput_vibration_ex)\*

指向 [XINPUT\_VIBRATION\_EX](/zh-TW/reference/input/xinputongameinput/structs/xinput_vibration_ex) 物件的指標，該物件包含要傳送至控制器的震動資訊。

<a id="retvalSection" />

### 傳回值

類型：DWORD

如果函式成功，會傳回 `ERROR_SUCCESS`。

如果控制器未連接，函式會傳回 `ERROR_DEVICE_NOT_CONNECTED`。

如果函式失敗，會傳回 WinError.h 中定義的錯誤碼。

<a id="remarksSection" />

## 備註

即使在與雙馬達控制器互動期間，呼叫此函式也是安全的。針對雙馬達控制器傳送至 `XInputSetStateEx` 的任何震動設定都會經過調整，以確保控制器仍能以最接近所傳送輸入的方式震動。因此，建議您在會呼叫 [XInputSetState](/zh-TW/reference/input/xinputongameinput/functions/xinputsetstate) 的情況下改為呼叫 `XInputSetStateEx`。

如需詳細資訊，請參閱 [XInputOnGameInput 包裝函式](/zh-TW/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](/zh-TW/build/core-features/common/input/porting/input-porting-xinput)\
[XInputOnGameInput](/zh-TW/reference/input/xinputongameinput/xinputongameinput_members)


## Related topics

- [XInputSetStateEx](/reference/input/xinputongameinput/functions/xinputsetstateex.md)
- [XInputSetState](/reference/input/xinputongameinput/functions/xinputsetstate.md)
- [XINPUT_VIBRATION_EX](/reference/input/xinputongameinput/structs/xinput_vibration_ex.md)
