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

> Recupera informações sobre as chaves de controle genérico, como chaves hat e direcionais (D-pads), no dispositivo.

Recupera informações sobre as chaves de controle genérico, como chaves hat e direcionais (D-pads), no dispositivo.

## Sintaxe

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

### Parâmetros

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

Número de elementos em *infoArray*. Para recuperar todas as chaves de controle, passe o valor retornado por [GetControllerSwitchCount](https://docs.xbox.com/pt-BR/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrollerswitchcount.md).

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

Ponteiro para uma matriz que recebe uma estrutura por chave de controle. Pode ser `nullptr`; nesse caso, nada é gravado e o método retorna 0.

### Valor retornado

Tipo: uint32\_t

O número de elementos gravados em *infoArray*. Esse é o menor valor entre *infoArrayCount* e o número de chaves de controle no dispositivo, ou 0 se *infoArray* for `nullptr` ou se o dispositivo não tiver chaves de controle.

## Comentários

Cada elemento é uma estrutura [GameInputControllerSwitchInfo](https://docs.xbox.com/pt-BR/reference/input/gameinput/structs/gameinputcontrollerswitchinfo.md) que descreve o tipo da chave correspondente (de 2, 4 ou 8 posições, como um valor de [GameInputSwitchKind](https://docs.xbox.com/pt-BR/reference/input/gameinput/enums/gameinputswitchkind.md)) e o rótulo de cada uma de suas posições.

Chame [GetControllerSwitchCount](https://docs.xbox.com/pt-BR/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrollerswitchcount.md) para obter o número de chaves de controle, aloque uma matriz desse tamanho e, em seguida, chame `GetControllerSwitchInfo` para preenchê-la. Se *infoArrayCount* for menor que o número de chaves de controle, somente os primeiros *infoArrayCount* elementos serão gravados. As chaves de controle de um dispositivo não mudam enquanto o dispositivo está conectado, portanto você pode consultá-las uma vez e armazenar o resultado em cache.

O elemento *i* da matriz de informações descreve a chave no índice *i* da matriz retornada por [IGameInputReading::GetControllerSwitchState](https://docs.xbox.com/pt-BR/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getcontrollerswitchstate.md) para leituras desse dispositivo.

O exemplo a seguir mostra como recuperar as chaves de controle de um dispositivo.

```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].
}
```

No GameInput v3 e anteriores, essas informações estavam disponíveis no membro `controllerSwitchInfo` da estrutura [GameInputControllerInfo](https://docs.xbox.com/pt-BR/reference/input/gameinput/deprecated/structs/gameinputcontrollerinfo.md), referenciada pelo membro `controllerInfo` da estrutura [GameInputDeviceInfo](https://docs.xbox.com/pt-BR/reference/input/gameinput/deprecated/structs/gameinputdeviceinfo.md) retornada por [IGameInputDevice::GetDeviceInfo](https://docs.xbox.com/pt-BR/reference/input/gameinput/deprecated/interfaces/igameinputdevice/methods/igameinputdevice_getdeviceinfo.md).

## Requisitos

**Cabeçalho:** GameInput.h

**Biblioteca:** gameinput.lib

**Plataformas com suporte:** Windows, consoles da família XBOX One e consoles XBOX Series

## Confira também

[Visão geral do GameInput](https://docs.xbox.com/pt-BR/build/core-features/common/input/overviews/input-overview.md)\
[GetControllerSwitchCount](https://docs.xbox.com/pt-BR/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrollerswitchcount.md)\
[GameInputControllerSwitchInfo](https://docs.xbox.com/pt-BR/reference/input/gameinput/structs/gameinputcontrollerswitchinfo.md)\
[GameInputSwitchKind](https://docs.xbox.com/pt-BR/reference/input/gameinput/enums/gameinputswitchkind.md)\
[IGameInputReading::GetControllerSwitchState](https://docs.xbox.com/pt-BR/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getcontrollerswitchstate.md)\
[IGameInputDevice](https://docs.xbox.com/pt-BR/reference/input/gameinput/interfaces/igameinputdevice/igameinputdevice.md)

## Histórico de versões

| Versão | Alterações |
| - | - |
| **v4** | Introduzido. |


## Related topics

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