> ## 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-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_setlightingcolor.md) 设置的颜色只是被暂存；在调用 `ApplyLightingColors` 之前，它们不会改变灯的状态。此方法通过一次写入将每个灯的暂存颜色发送到设备，因此对多个组或多个灯所做的更改会同时生效。

只有具有暂存颜色的灯才会更新。如果没有暂存任何颜色，则此调用不起作用。

暂存的颜色在应用后仍然有效。若要稍后更改某个组，请为该组暂存新颜色并再次调用 `ApplyLightingColors`；其他灯的颜色会保持不变。若要丢弃所有暂存的颜色并让灯恢复默认行为，请调用 [IGameInputDevice::ApplyLightingSystemDefault](https://docs.xbox.com/zh-CN/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-CN/build/core-features/common/input/overviews/input-overview.md)\
[IGameInputDevice](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/igameinputdevice.md)\
[IGameInputDevice::SetLightingColor](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_setlightingcolor.md)\
[IGameInputDevice::ApplyLightingSystemDefault](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_applylightingsystemdefault.md)\
[IGameInputDevice::GetSupportedLightingGroups](https://docs.xbox.com/zh-CN/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-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_setlightingcolor.md)
- [IGameInputDevice::ApplyLightingSystemDefault](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_applylightingsystemdefault.md)
- [IGameInputDevice::GetSupportedLightingGroups](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getsupportedlightinggroups.md)
- [IGameInputDevice::GetSupportedLightingGroupSize](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getsupportedlightinggroupsize.md)
- [在一个应用程序中使用多个 GameInput API 版本](https://docs.xbox.com/zh-CN/build/core-features/common/input/overviews/input-version-interop.md)
