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

# SetRumbleState

> SetRumbleState

# SetRumbleState

設定裝置上四個震動馬達所需的強度。

## 語法

```cpp theme={null}
void SetRumbleState(
    const GameInputRumbleParams* params
);
```

### 參數

*params*   \_In\_opt\_\
類型：[GameInputRumbleParams\*](/zh-TW/reference/input/gameinput/structs/gameinputrumbleparams)

包含每個震動馬達所需強度的結構。震動馬達強度範圍為 0.0 到 1.0。

### 傳回值

類型：void

## 備註

`SetRumbleState` 方法會設定裝置上四個震動馬達所需的強度。與其他類型的回饋一樣，應用程式可以隨時呼叫此方法，但只有在應用程式處於焦點時才會套用至裝置。

為了盡可能簡化，應用程式不需要檢查裝置支援哪些震動馬達，並且可以為全部四個馬達指定強度。如果裝置缺少四個馬達中的任何一個，GameInput 實作會嘗試透過為其他馬達增加額外強度來進行調整，讓使用者仍能感受到一定程度的回饋。例如，在雙馬達遊戲台上，會透過為高頻震動馬達增加少量額外震動強度來模擬扳機震動值。

在已中斷連線的裝置或沒有震動馬達的裝置上，呼叫 `SetRumbleState` 方法不會有任何作用。馬達強度值的範圍為 \[0.0, 1.0]。任何超出此範圍的值都會被限制為最接近的有效值。

## 需求

**標頭：** GameInput.h

[GameInput 概觀](/zh-TW/build/core-features/common/input/overviews/input-overview)\
[GameInputRumbleParams](/zh-TW/reference/input/gameinput/structs/gameinputrumbleparams)\
[IGameInputDevice](/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/igameinputdevice)

## 版本歷程記錄

| 版本 | 變更 |
| - | - |
| **v0** | 已推出。 |


## Related topics

- [SetRumbleState](/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_setrumblestate.md)
- [GameInputRumbleParams](/reference/input/gameinput/structs/gameinputrumbleparams.md)
- [Porting from XInput to GameInput](/build/core-features/common/input/porting/input-porting-xinput.md)
- [IGameInput::GetCurrentTimestamp](/reference/input/gameinput/interfaces/igameinput/methods/igameinput_getcurrenttimestamp.md)
