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

> 入力デバイス上の 1 つ以上のランプのカラーをステージングします。

入力デバイス上の 1 つ以上のランプのカラーをステージングします。このカラーは、次に [IGameInputDevice::ApplyLightingColors](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_applylightingcolors.md) を呼び出したときにデバイスに送信されます。

## 構文

```cpp theme={null}
void SetLightingColor(
    GameInputColor color,
    GameInputLightingGroups group,
    uint32_t groupOrderIndex = GAMEINPUT_LIGHTING_GROUP_ORDER_INDEX_ALL
);
```

### パラメーター

*color*\
型: [GameInputColor](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/input/gameinput/structs/gameinputcolor)

選択したランプに対してステージングするカラー。

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

設定するランプを含むライティング グループの選択範囲。1 つ以上の名前付きグループ フラグ、デバイス上のすべてのランプを選択する `GameInputLightingGroupAll`、またはどの名前付きグループにも属さないランプを選択する `GameInputLightingGroupUnknown` を指定できます。

*groupOrderIndex*   \_In\_opt\_\
型: uint32\_t

*group* 内の個々のランプを選択します。既定値の `GAMEINPUT_LIGHTING_GROUP_ORDER_INDEX_ALL` は、*group* 内のすべてのランプを選択します。その他の値の解釈については、「解説」を参照してください。

### 戻り値

型: void

## 解説

`SetLightingColor` はランプをすぐには変更しません。選択したランプのカラーを記録 (ステージング) します。ステージングされたすべてのカラーを 1 回の更新でデバイスに送信するには、[IGameInputDevice::ApplyLightingColors](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_applylightingcolors.md) を呼び出します。カラーを適用するまでは何も送信されないため、複数のグループや個々のランプを設定して、それらを同時に変化させることができます。ステージングされたカラーは適用された後も有効なままであるため、後で 1 つのグループを変更するには、そのグループの新しいカラーをステージングして、もう一度適用するだけで済みます。

*groupOrderIndex* パラメーターは次のように解釈されます。

| *groupOrderIndex* の値 | 選択されるランプ |
| - | - |
| `GAMEINPUT_LIGHTING_GROUP_ORDER_INDEX_ALL` (0xFFFFFFFF) | *group* 内のすべてのランプ。 |
| キーボード スキャン コード (*group* が `GameInputLightingGroupKeyboardKey` の場合) | そのスキャン コードを持つキーのランプ。スキャン コードには Set 1 エンコードを使用します: 0x01 ～ 0x7F、拡張スキャン コード 0xE001 ～ 0xE07F、または Pause キーの場合は 0xE11D。 |
| その他の値 | *group* 内で 0 から始まるその位置にあるランプ。この値は、*group* に対して [IGameInputDevice::GetSupportedLightingGroupSize](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getsupportedlightinggroupsize.md) から返される値より小さくなければなりません。 |

`GameInputLightingGroupKeyboardKey` を他の名前付きグループと組み合わせた選択範囲では、インデックスがあいまいになるため、個々のランプを選択できません。このような選択範囲では `GAMEINPUT_LIGHTING_GROUP_ORDER_INDEX_ALL` を使用してください。`GameInputLightingGroupAll` では、デバイス上のすべてのランプの中での 0 から始まる位置によって、個々のランプを選択できます。

選択範囲がデバイスに対して有効でない場合、呼び出しは無視され、何もステージングされません。選択範囲は、デバイスにない名前付きグループを含む場合 ([IGameInputDevice::GetSupportedLightingGroups](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getsupportedlightinggroups.md) を参照)、ランプを含まない場合、または範囲外の *groupOrderIndex* や有効なスキャン コードではない *groupOrderIndex* を指定した場合に無効になります。切断されたデバイスに対する呼び出しは何の効果もありません。

ステージングされたカラーを破棄してランプを既定の動作に戻すには、[IGameInputDevice::ApplyLightingSystemDefault](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_applylightingsystemdefault.md) を呼び出します。

次の例では、コントローラーのフェイス ボタンを赤に、センター ライトを青に設定してから、両方のカラーを 1 回の更新で適用します。

```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();
}
```

次の例では、キーごとのライティングを備えたキーボードのすべてのキーを暗くし、Set 1 スキャン コード 0x1E を持つ A キーを強調表示します。

```cpp theme={null}
void HighlightKeyA(IGameInputDevice* device) noexcept
{
    if ((device->GetSupportedLightingGroups() & GameInputLightingGroupKeyboardKey) == 0)
    {
        return;
    }

    device->SetLightingColor({ 16, 16, 16 }, GameInputLightingGroupKeyboardKey);
    device->SetLightingColor({ 0, 255, 0 }, GameInputLightingGroupKeyboardKey, 0x1E);
    device->ApplyLightingColors();
}
```

> [!NOTE]
>
> ライティングのサポートは、デバイスとプラットフォームによって異なります。現在、GameInput は、Windows Dynamic Lighting (LampArray) デバイスと DualSense コントローラーのライトバーでのライティングをサポートしています。

## 要件

**ヘッダー:** GameInput.h

**ライブラリ:** gameinput.lib

**サポートされているプラットフォーム:** Windows、XBOX One ファミリー本体、XBOX Series 本体

## 関連項目

[GameInput の概要](https://docs.xbox.com/ja-jp/build/core-features/common/input/overviews/input-overview.md)\
[IGameInputDevice](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/igameinputdevice.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)\
[IGameInputDevice::ApplyLightingColors](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_applylightingcolors.md)\
[IGameInputDevice::ApplyLightingSystemDefault](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_applylightingsystemdefault.md)\
[IGameInputDevice::GetSupportedLightingGroups](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getsupportedlightinggroups.md)\
[IGameInputDevice::GetSupportedLightingGroupSize](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getsupportedlightinggroupsize.md)

## バージョン履歴

| バージョン | 変更内容 |
| - | - |
| **v4** | 導入されました。 |


## Related topics

- [IGameInputDevice::ApplyLightingColors](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_applylightingcolors.md)
- [IGameInputDevice::ApplyLightingSystemDefault](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_applylightingsystemdefault.md)
- [IGameInputDevice::GetSupportedLightingGroups](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getsupportedlightinggroups.md)
- [IGameInputDevice::GetSupportedLightingGroupSize](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getsupportedlightinggroupsize.md)
- [GameInput API メンバー](https://docs.xbox.com/ja-jp/reference/input/gameinput/gameinput_members.md)
