> ## 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](/zh-TW/reference/input/xinputongameinput/structs/xinput_vibration)\*

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

<a id="retvalSection" />

### 傳回值

類型：DWORD

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

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

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

<a id="remarksSection" />

## 備註

此函式支援只有兩個觸覺回饋馬達的舊型控制器。若要支援新型控制器中的其他回饋馬達，請呼叫 [XInputSetStateEx](/zh-TW/reference/input/xinputongameinput/functions/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

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