> ## 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::GetSupportedLightingGroupSize

> 获取输入设备在指定灯光组选择中的灯数量。

获取输入设备在指定灯光组选择中的灯数量。

## 语法

```cpp theme={null}
uint32_t GetSupportedLightingGroupSize(
    GameInputLightingGroups group
);
```

### 参数

*group*\
类型：[GameInputLightingGroups](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/input/gameinput/enums/gameinputlightinggroups)

要统计其中灯数量的灯光组选择。可以是一个或多个命名组标志、`GameInputLightingGroupAll` 或 `GameInputLightingGroupUnknown`。

### 返回值

类型：uint32\_t

所选范围中的灯数量。如果设备在所选范围中没有灯，或者 *group* 包含未定义的标志，则返回 0。

## 备注

*group* 的值按如下方式解释。

| *group* 的值 | 统计的灯 |
| - | - |
| `GameInputLightingGroupAll` | 设备上的每个灯，包括不属于命名组的灯。 |
| `GameInputLightingGroupUnknown` | 仅统计不属于任何命名组的灯。 |
| 一个或多个命名组标志 | 所选范围中每个命名组的灯数量之和。 |

当你按序号对单个灯进行寻址时，所选范围的灯数量是 [IGameInputDevice::SetLightingColor](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_setlightingcolor.md) 的 *groupOrderIndex* 参数的上限（不含该值）。例外的是 `GameInputLightingGroupKeyboardKey`，它改为按键盘扫描码对单个灯进行寻址。

以下示例以不同深浅的绿色点亮正面按钮组中的每个灯。

```cpp theme={null}
void SetFaceButtonGradient(IGameInputDevice* device) noexcept
{
    const uint32_t lampCount = device->GetSupportedLightingGroupSize(GameInputLightingGroupFaceButtons);
    for (uint32_t i = 0; i < lampCount; ++i)
    {
        const uint8_t green = static_cast<uint8_t>(255 * (i + 1) / lampCount);
        device->SetLightingColor({ 0, green, 0 }, GameInputLightingGroupFaceButtons, i);
    }

    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)\
[GameInputLightingGroups](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/input/gameinput/enums/gameinputlightinggroups)\
[IGameInputDevice::GetSupportedLightingGroups](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getsupportedlightinggroups.md)\
[IGameInputDevice::SetLightingColor](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_setlightingcolor.md)\
[IGameInputDevice::ApplyLightingColors](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_applylightingcolors.md)

## 版本历史

| 版本 | 变更 |
| - | - |
| **v4** | 引入。 |


## Related topics

- [IGameInputDevice::GetSupportedLightingGroups](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getsupportedlightinggroups.md)
- [IGameInputDevice::SetLightingColor](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_setlightingcolor.md)
- [IGameInputDevice::GetSupportedInput](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getsupportedinput.md)
- [IGameInputDevice::GetSupportedRumbleMotors](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getsupportedrumblemotors.md)
- [IGameInputDevice::GetSupportedSystemButtons](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getsupportedsystembuttons.md)
