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

# ILampArray::SetColorsForScanCodes method

> Sets colors for one or more Lamps on a LampArray keyboard by mapping a parallel array of keyboard scan codes to a parallel array of colors.

# ILampArray::SetColorsForScanCodes

Sets the color of one or more Lamps, corresponding to keyboard scan codes. Position within each array maps keys to desired colors.

## Syntax

```cpp theme={null}
void SetColorsForScanCodes(
    uint32_t scanCodesCount,
    const uint32_t * scanCodes,
    const LampArrayColor * desiredColors)
```

### Parameters

*scanCodesCount*
Type: uint32\_t

The size of the color and scan code buffers.

*scanCodes*  \_In\_reads\_(scanCodesCount)
Type: uint32\_t\*

The array of scan codes for which color updates are being applied.

*desiredColors*  \_In\_reads\_(scanCodesCount)
Type: [LampArrayColor\*](/reference/lighting/lamparray/structs/lamparraycolor)

The array of corresponding Lamp colors.

### Return value

Type: void

## Remarks

Scan codes buffer and desired colors buffer are implied to be the same size.

Black (a zero-filled LampArrayColor) is equivalent to a Lamp being 'off'.

The alpha value (LampArrayColor::a) represents the relative transparency of a color, where zero is fully transparent and 0xFF is fully opaque. If an alpha value other than 0xFF is used, the color will undergo an additional blending step against black. To avoid this blending step, do not pass in any alpha value other than 0xFF when setting colors.

Lamp state will not be flushed to the device if the ILampArray is disabled for the current process (see [ILampArray::SetIsEnabled](/reference/lighting/lamparray/interfaces/ilamparray/methods/ilamparray_setisenabled)).

If a scan code is not bound to any Lamp on the device, it is ignored and the remaining scan codes are still applied.

If a scan code is used multiple times in the same buffer, the API will overwrite the previous state of any Lamps corresponding to that scan code.

If [ILampArray::SupportsScanCodes](/reference/lighting/lamparray/interfaces/ilamparray/methods/ilamparray_supportsscancodes) returns false, this function will have no effect.

The following sample shows how to set Lamp colors for the WASD keys on the keyboard.

```cpp theme={null}
#define SC_W    0x11
#define SC_A    0x1E
#define SC_S    0x1F
#define SC_D    0x20

void UpdateWASDKeys(ILampArray* lampArray)
{
    const LampArrayColor blueColor = { 0x0 /* r */, 0x0 /* g */, 0xFF /* b */, 0xFF /* a */};
    const LampArrayColor yellowColor = { 0xFF /* r */, 0xFF /* g */, 0x0 /* b */, 0xFF /* a */};

    // Set the color for all lamps. We will override the WASD keys below.
    lampArray->SetColor(blueColor);

    // Set up the buffer of scan codes for the Lamps we want to target
    std::vector<uint32_t> scanCodesBuffer = { SC_W, SC_A, SC_S, SC_D };

    // Create a matching buffer of LampArrayColors. In this example, we will set all of the WASD keys to yellow.
    std::vector<LampArrayColor> colorsBuffer;
    for (size_t i = 0; i < scanCodesBuffer.size(); i++)
    {
        colorsBuffer.push_back(yellowColor);
    }

    // Set the color for the WASD keys
    lampArray->SetColorsForScanCodes(static_cast<uint32_t>(scanCodesBuffer.size()), scanCodesBuffer.data(), colorsBuffer.data());
}
```

## Requirements

**Header:** LampArray.h

**Library:** xgameplatform.lib

**Supported platforms:** XBOX One family consoles and XBOX Series consoles

## See also

[Lighting API Overview](/build/core-features/common/lighting/gc-lighting-toc)\
[Setting Colors on a LampArray](/build/core-features/common/lighting/lighting-colors)\
[Windows Keyboard Input Reference - Scan Codes](https://learn.microsoft.com/windows/win32/inputdev/about-keyboard-input#scan-codes)\
[LampArrayColor](/reference/lighting/lamparray/structs/lamparraycolor)\
[ILampArray::SetColor](/reference/lighting/lamparray/interfaces/ilamparray/methods/ilamparray_setcolor)\
[ILampArray::SetColorsForIndices](/reference/lighting/lamparray/interfaces/ilamparray/methods/ilamparray_setcolorsforindices)\
[ILampArray](/reference/lighting/lamparray/interfaces/ilamparray/ilamparray)


## Related topics

- [ILampArray::SupportsScanCodes method](/reference/lighting/lamparray/interfaces/ilamparray/methods/ilamparray_supportsscancodes.md)
- [ILampArray::SetColor method](/reference/lighting/lamparray/interfaces/ilamparray/methods/ilamparray_setcolor.md)
- [ILampArray::SetColorsForIndices method](/reference/lighting/lamparray/interfaces/ilamparray/methods/ilamparray_setcolorsforindices.md)
- [ILampArray::SetIsEnabled method](/reference/lighting/lamparray/interfaces/ilamparray/methods/ilamparray_setisenabled.md)
- [ILampArray::SetBrightnessLevel method](/reference/lighting/lamparray/interfaces/ilamparray/methods/ilamparray_setbrightnesslevel.md)
