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

# GetGamepadState

> IGameInputReading::GetGamepadState

# IGameInputReading::GetGamepadState

Recupera una vista de la lectura de entrada que describe el estado de un mando.

## Sintaxis

```cpp theme={null}
bool GetGamepadState(
    GameInputGamepadState* state
);
```

### Parámetros

*state*   \_Out\_\
Tipo: [GameInputGamepadState\*](https://docs.xbox.com/es/reference/input/gameinput/structs/gameinputgamepadstate.md)

Interpretación de la entrada como un mando.

### Valor devuelto

Tipo: bool

Devuelve true si la interpretación como mando se realiza correctamente.
Devuelve false cuando se intenta leer una entrada que no se reconoce como un mando.

## Comentarios

Llame al método [IGameInputReading::GetInputKind](https://docs.xbox.com/es/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getinputkind.md) para ver qué funciones Get\*State devolverán una interpretación válida para una determinada [IGameInputReading](https://docs.xbox.com/es/reference/input/gameinput/interfaces/igameinputreading/igameinputreading.md). Cada función Get\*State tiene una entrada correspondiente en la enumeración [IGameInputReading::GetInputKind](https://docs.xbox.com/es/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getinputkind.md). Si intenta llamar a una función Get\*State cuya marca correspondiente de [IGameInputReading::GetInputKind](https://docs.xbox.com/es/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getinputkind.md) no está establecida, la función devolverá los valores predeterminados de reposo, así como un valor devuelto false.

El siguiente ejemplo de C++ muestra cómo leer el estado del mando.

```cpp theme={null}
void PlayerCrouch();
void PlayerStand();
void PlayerReload();
void PlayerMove(float, float);
void SetCameraOrientation(float, float);

void ProcessGamepadState(
    _In_ IGameInputReading * prevReading,
    _In_ IGameInputReading * currentReading) noexcept
{
    GameInputGamepadState prevState, currentState;
    prevReading->GetGamepadState(&prevState);
    currentReading->GetGamepadState(&currentState);

    GameInputGamepadButtons changedButtons = prevState.buttons ^ currentState.buttons;
    GameInputGamepadButtons pressedButtons = changedButtons & currentState.buttons;
    GameInputGamepadButtons releasedButtons = changedButtons ^ pressedButtons;

    if (pressedButtons & GameInputGamepadRightShoulder)
    {
        PlayerCrouch();
    }
    else if (releasedButtons & GameInputGamepadRightShoulder)
    {
        PlayerStand();
    }

    if (pressedButtons & GameInputGamepadLeftShoulder)
    {
        PlayerReload();
    }

    PlayerMove(currentState.leftThumbstickX, currentState.leftThumbstickY);
    SetCameraOrientation(currentState.rightThumbstickX, currentState.rightThumbstickY);
}
```

## Requisitos

[Información general de la API de entrada](https://docs.xbox.com/es/build/core-features/common/input/overviews/input-overview.md)\
[IGameInputReading](https://docs.xbox.com/es/reference/input/gameinput/interfaces/igameinputreading/igameinputreading.md)\
[IGameInputReading::GetInputKind](https://docs.xbox.com/es/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getinputkind.md)

## Historial de versiones

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


## Related topics

- [GetDevice](https://docs.xbox.com/es/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getdevice.md)
- [XINPUT_GAMEPAD](https://docs.xbox.com/es/reference/input/xinputongameinput/structs/xinput_gamepad.md)
- [XINPUT_STATE](https://docs.xbox.com/es/reference/input/xinputongameinput/structs/xinput_state.md)
- [GameInputGamepadButtons](https://docs.xbox.com/es/reference/input/gameinput/enums/gameinputgamepadbuttons.md)
- [GAMEPAD_VIBRATION](https://docs.xbox.com/es/reference/tools/xtf/xtfinput/structures/gamepad_vibration.md)
