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

# IGameInputDevice::ApplyLightingColors

> 在單一更新中將所有暫存的燈光色彩傳送至輸入裝置。

在單一更新中將所有暫存的燈光色彩傳送至輸入裝置。

## 語法

```cpp theme={null}
void ApplyLightingColors();
```

### 參數

此方法沒有參數。

### 傳回值

類型：void

## 備註

您透過呼叫 [IGameInputDevice::SetLightingColor](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_setlightingcolor.md) 所設定的色彩只會被暫存；在您呼叫 `ApplyLightingColors` 之前，燈不會改變。此方法會在單次寫入中將每盞燈的暫存色彩傳送至裝置，因此對多個群組或多盞燈的變更會同時生效。

只有具有暫存色彩的燈會更新。如果沒有暫存任何色彩，呼叫不會有任何作用。

暫存色彩在套用後仍會持續生效。若之後要變更某個群組，請為該群組暫存新色彩，然後再次呼叫 `ApplyLightingColors`；其他燈的色彩會保留。若要捨棄所有暫存色彩並讓燈恢復預設行為，請呼叫 [IGameInputDevice::ApplyLightingSystemDefault](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_applylightingsystemdefault.md)。

當裝置中斷連線時，其暫存色彩會被捨棄。對已中斷連線之裝置的呼叫不會有任何作用。

下列範例會將控制器的正面按鈕設定為紅色、將其中央燈設定為藍色，然後在單一更新中套用這兩種色彩。

```cpp theme={null}
void SetControllerLighting(IGameInputDevice* device) noexcept
{
    const GameInputLightingGroups groups = device->GetSupportedLightingGroups();

    if ((groups & GameInputLightingGroupFaceButtons) != 0)
    {
        device->SetLightingColor({ 255, 0, 0 }, GameInputLightingGroupFaceButtons);
    }

    if ((groups & GameInputLightingGroupCenterLight) != 0)
    {
        device->SetLightingColor({ 0, 0, 255 }, GameInputLightingGroupCenterLight);
    }

    device->ApplyLightingColors();
}
```

> [!NOTE]
>
> 燈光支援取決於裝置和平台。目前，GameInput 支援 Windows 動態燈光 (LampArray) 裝置以及 DualSense 控制器燈條上的燈光。

## 需求

**標頭：** GameInput.h

**程式庫：** gameinput.lib

**支援的平台：** Windows、XBOX One 系列主機和 XBOX Series 主機

## 另請參閱

[GameInput 概觀](https://docs.xbox.com/zh-TW/build/core-features/common/input/overviews/input-overview.md)\
[IGameInputDevice](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/igameinputdevice.md)\
[IGameInputDevice::SetLightingColor](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_setlightingcolor.md)\
[IGameInputDevice::ApplyLightingSystemDefault](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_applylightingsystemdefault.md)\
[IGameInputDevice::GetSupportedLightingGroups](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getsupportedlightinggroups.md)\
[GameInputColor](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/input/gameinput/structs/gameinputcolor)\
[GameInputLightingGroups](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/input/gameinput/enums/gameinputlightinggroups)

## 版本歷程記錄

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


## Related topics

- [IGameInputDevice::SetLightingColor](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_setlightingcolor.md)
- [IGameInputDevice::ApplyLightingSystemDefault](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_applylightingsystemdefault.md)
- [IGameInputDevice::GetSupportedLightingGroups](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getsupportedlightinggroups.md)
- [IGameInputDevice::GetSupportedLightingGroupSize](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getsupportedlightinggroupsize.md)
- [在單一應用程式中使用多個 GameInput API 版本](https://docs.xbox.com/zh-TW/build/core-features/common/input/overviews/input-version-interop.md)
