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

> Retrieves the labels of the generic controller buttons on the device.

Retrieves the labels of the generic controller buttons on the device.

## Syntax

```cpp theme={null}
uint32_t GetControllerButtonLabels(
    uint32_t labelArrayCount,
    GameInputLabel* labelArray
);
```

### Parameters

*labelArrayCount*   \_In\_\
Type: uint32\_t

Number of elements in *labelArray*. To retrieve all controller button labels, pass the value returned by [GetControllerButtonCount](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrollerbuttoncount.md).

*labelArray*   \_Out\_writes\_to\_opt\_(labelArrayCount, return)\
Type: [GameInputLabel](https://docs.xbox.com/reference/input/gameinput/enums/gameinputlabel.md)\*

Pointer to an array that receives one label per controller button. Can be `nullptr`, in which case nothing is written and the method returns 0.

### Return value

Type: uint32\_t

The number of elements written to *labelArray*. This is the smaller of *labelArrayCount* and the number of controller button labels on the device, or 0 if *labelArray* is `nullptr` or the device has no controller button labels.

## Remarks

Each element is a [GameInputLabel](https://docs.xbox.com/reference/input/gameinput/enums/gameinputlabel.md) value that identifies the marking printed on the corresponding button, if the device reports one.

Call [GetControllerButtonCount](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrollerbuttoncount.md) to get the number of controller button labels, allocate an array of that size, and then call `GetControllerButtonLabels` to fill it. If *labelArrayCount* is smaller than the number of controller button labels, only the first *labelArrayCount* elements are written. The controller button labels of a device don't change while the device is connected, so you can query them once and cache the result.

Element *i* of the label array describes the button at index *i* of the array returned by [IGameInputReading::GetControllerButtonState](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getcontrollerbuttonstate.md) for readings from this device.

The following example shows how to retrieve the controller button labels of a device.

```cpp theme={null}
uint32_t buttonCount = device->GetControllerButtonCount();
std::vector<GameInputLabel> buttonLabels(buttonCount);
buttonLabels.resize(device->GetControllerButtonLabels(buttonCount, buttonLabels.data()));

std::unique_ptr<bool[]> buttonStates(new bool[buttonCount]);
uint32_t stateCount = reading->GetControllerButtonState(buttonCount, buttonStates.get());

for (uint32_t i = 0; i < buttonLabels.size() && i < stateCount; ++i)
{
    // buttonLabels[i] is the label of the button whose state is buttonStates[i].
}
```

In GameInput v3 and earlier, this information was available from the `controllerButtonLabels` member of the [GameInputControllerInfo](https://docs.xbox.com/reference/input/gameinput/deprecated/structs/gameinputcontrollerinfo.md) structure, which was referenced by the `controllerInfo` member of the [GameInputDeviceInfo](https://docs.xbox.com/reference/input/gameinput/deprecated/structs/gameinputdeviceinfo.md) structure returned by [IGameInputDevice::GetDeviceInfo](https://docs.xbox.com/reference/input/gameinput/deprecated/interfaces/igameinputdevice/methods/igameinputdevice_getdeviceinfo.md).

## Requirements

**Header:** GameInput.h

**Library:** gameinput.lib

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

## See also

[Overview of GameInput](https://docs.xbox.com/build/core-features/common/input/overviews/input-overview.md)\
[GetControllerButtonCount](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrollerbuttoncount.md)\
[GameInputLabel](https://docs.xbox.com/reference/input/gameinput/enums/gameinputlabel.md)\
[IGameInputReading::GetControllerButtonState](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getcontrollerbuttonstate.md)\
[IGameInputDevice](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinputdevice/igameinputdevice.md)

## Version History

| Version | Changes |
| - | - |
| **v4** | Introduced. |


## Related topics

- [GameInputLabel](https://docs.xbox.com/reference/input/gameinput/enums/gameinputlabel.md)
- [IGameInputDevice::GetControllerButtonCount](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrollerbuttoncount.md)
- [IGameInputDevice::GetGamepadInfo](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getgamepadinfo.md)
- [IGameInputDevice::GetControllerAxisLabels](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrolleraxislabels.md)
- [IGameInputDevice::GetFlightStickInfo](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getflightstickinfo.md)
