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

> Retrieves information about the generic controller switches, such as hat switches and directional pads, on the device.

Retrieves information about the generic controller switches, such as hat switches and directional pads, on the device.

## Syntax

```cpp theme={null}
uint32_t GetControllerSwitchInfo(
    uint32_t infoArrayCount,
    GameInputControllerSwitchInfo* infoArray
);
```

### Parameters

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

Number of elements in *infoArray*. To retrieve all controller switches, pass the value returned by [GetControllerSwitchCount](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrollerswitchcount.md).

*infoArray*   \_Out\_writes\_to\_opt\_(infoArrayCount, return)\
Type: [GameInputControllerSwitchInfo](https://docs.xbox.com/reference/input/gameinput/structs/gameinputcontrollerswitchinfo.md)\*

Pointer to an array that receives one structure per controller switch. 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 *infoArray*. This is the smaller of *infoArrayCount* and the number of controller switches on the device, or 0 if *infoArray* is `nullptr` or the device has no controller switches.

## Remarks

Each element is a [GameInputControllerSwitchInfo](https://docs.xbox.com/reference/input/gameinput/structs/gameinputcontrollerswitchinfo.md) structure that describes the kind of the corresponding switch (2-way, 4-way, or 8-way, as a [GameInputSwitchKind](https://docs.xbox.com/reference/input/gameinput/enums/gameinputswitchkind.md) value) and the label of each of its positions.

Call [GetControllerSwitchCount](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrollerswitchcount.md) to get the number of controller switches, allocate an array of that size, and then call `GetControllerSwitchInfo` to fill it. If *infoArrayCount* is smaller than the number of controller switches, only the first *infoArrayCount* elements are written. The controller switches 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 info array describes the switch at index *i* of the array returned by [IGameInputReading::GetControllerSwitchState](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getcontrollerswitchstate.md) for readings from this device.

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

```cpp theme={null}
uint32_t switchCount = device->GetControllerSwitchCount();
std::vector<GameInputControllerSwitchInfo> switchInfo(switchCount);
switchInfo.resize(device->GetControllerSwitchInfo(switchCount, switchInfo.data()));

std::vector<GameInputSwitchPosition> switchStates(reading->GetControllerSwitchCount());
reading->GetControllerSwitchState(static_cast<uint32_t>(switchStates.size()), switchStates.data());

for (size_t i = 0; i < switchInfo.size() && i < switchStates.size(); ++i)
{
    // switchInfo[i] describes the switch whose position is switchStates[i].
}
```

In GameInput v3 and earlier, this information was available from the `controllerSwitchInfo` 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)\
[GetControllerSwitchCount](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrollerswitchcount.md)\
[GameInputControllerSwitchInfo](https://docs.xbox.com/reference/input/gameinput/structs/gameinputcontrollerswitchinfo.md)\
[GameInputSwitchKind](https://docs.xbox.com/reference/input/gameinput/enums/gameinputswitchkind.md)\
[IGameInputReading::GetControllerSwitchState](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getcontrollerswitchstate.md)\
[IGameInputDevice](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinputdevice/igameinputdevice.md)

## Version History

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


## Related topics

- [GameInputControllerSwitchInfo](https://docs.xbox.com/reference/input/gameinput/structs/gameinputcontrollerswitchinfo.md)
- [IGameInputDevice::GetControllerSwitchCount](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrollerswitchcount.md)
- [IGameInputDevice::GetControllerAxisCount](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrolleraxiscount.md)
- [IGameInputDevice::GetControllerButtonCount](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrollerbuttoncount.md)
- [IGameInputDevice::GetControllerAxisLabels](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrolleraxislabels.md)
