> ## 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 información sobre los interruptores de mando genéricos del dispositivo, como los hat switches y los pads direccionales.

Recupera información sobre los interruptores de mando genéricos del dispositivo, como los hat switches y los pads direccionales.

## Sintaxis

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

### Parámetros

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

Número de elementos de *infoArray*. Para recuperar todos los interruptores de mando, pase el valor devuelto por [GetControllerSwitchCount](https://docs.xbox.com/es/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrollerswitchcount.md).

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

Puntero a una matriz que recibe una estructura por cada interruptor de mando. Puede ser `nullptr`, en cuyo caso no se escribe nada y el método devuelve 0.

### Valor devuelto

Tipo: uint32\_t

El número de elementos escritos en *infoArray*. Es el menor de *infoArrayCount* y el número de interruptores de mando del dispositivo, o 0 si *infoArray* es `nullptr` o el dispositivo no tiene interruptores de mando.

## Comentarios

Cada elemento es una estructura [GameInputControllerSwitchInfo](https://docs.xbox.com/es/reference/input/gameinput/structs/gameinputcontrollerswitchinfo.md) que describe el tipo del interruptor correspondiente (de 2, 4 u 8 direcciones, como un valor de [GameInputSwitchKind](https://docs.xbox.com/es/reference/input/gameinput/enums/gameinputswitchkind.md)) y la etiqueta de cada una de sus posiciones.

Llame a [GetControllerSwitchCount](https://docs.xbox.com/es/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrollerswitchcount.md) para obtener el número de interruptores de mando, asigne una matriz de ese tamaño y, a continuación, llame a `GetControllerSwitchInfo` para rellenarla. Si *infoArrayCount* es menor que el número de interruptores de mando, solo se escriben los primeros *infoArrayCount* elementos. Los interruptores de mando de un dispositivo no cambian mientras el dispositivo está conectado, por lo que puede consultarlos una vez y almacenar en caché el resultado.

El elemento *i* de la matriz de información describe el interruptor situado en el índice *i* de la matriz devuelta por [IGameInputReading::GetControllerSwitchState](https://docs.xbox.com/es/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getcontrollerswitchstate.md) para las lecturas de este dispositivo.

En el siguiente ejemplo se muestra cómo recuperar los interruptores de mando de un 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].
}
```

En GameInput v3 y versiones anteriores, esta información estaba disponible en el miembro `controllerSwitchInfo` de la estructura [GameInputControllerInfo](https://docs.xbox.com/es/reference/input/gameinput/deprecated/structs/gameinputcontrollerinfo.md), a la que hacía referencia el miembro `controllerInfo` de la estructura [GameInputDeviceInfo](https://docs.xbox.com/es/reference/input/gameinput/deprecated/structs/gameinputdeviceinfo.md) devuelta por [IGameInputDevice::GetDeviceInfo](https://docs.xbox.com/es/reference/input/gameinput/deprecated/interfaces/igameinputdevice/methods/igameinputdevice_getdeviceinfo.md).

## Requisitos

**Encabezado:** GameInput.h

**Biblioteca:** gameinput.lib

**Plataformas compatibles:** Windows, consolas de la familia XBOX One y consolas XBOX Series

## Consulte también

[Información general de GameInput](https://docs.xbox.com/es/build/core-features/common/input/overviews/input-overview.md)\
[GetControllerSwitchCount](https://docs.xbox.com/es/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontrollerswitchcount.md)\
[GameInputControllerSwitchInfo](https://docs.xbox.com/es/reference/input/gameinput/structs/gameinputcontrollerswitchinfo.md)\
[GameInputSwitchKind](https://docs.xbox.com/es/reference/input/gameinput/enums/gameinputswitchkind.md)\
[IGameInputReading::GetControllerSwitchState](https://docs.xbox.com/es/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getcontrollerswitchstate.md)\
[IGameInputDevice](https://docs.xbox.com/es/reference/input/gameinput/interfaces/igameinputdevice/igameinputdevice.md)

## Historial de versiones

| Versión | Cambios |
| - | - |
| **v4** | Se introdujo. |


## Related topics

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