> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# IGameInputReading::GetGamepadState

> IGameInputReading::GetGamepadState

# IGameInputReading::GetGamepadState

Retrieve a view of the input reading that describes the state of a gamepad.

## Syntax

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

### Parameters

*state*   \_Out\_\
Type: [GameInputGamepadState\*](/reference/input/gameinput/structs/gameinputgamepadstate)

Interpretation of the input as a gamepad.

### Return value

Type: bool

Returns true on successful interpretation of a gamepad.
Returns false when attempting to read an input that is not recognized as a gamepad.

## Remarks

Call the [IGameInputReading::GetInputKind](/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getinputkind) method to see which Get\*State functions will return a valid interpretation for some [IGameInputReading](/reference/input/gameinput/interfaces/igameinputreading/igameinputreading). Each Get\*State function has a corresponding entry in the [IGameInputReading::GetInputKind](/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getinputkind) enum. If you attempt to call a Get\*State function where the corresponding [IGameInputReading::GetInputKind](/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getinputkind) flag is not set, the function will return with default at rest values as well as a false return value.

The following C++ sample demonstrates how to read the gamepad state.

```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);
}
```

## Requirements

[Input API Overview](/build/core-features/common/input/overviews/input-overview)\
[IGameInputReading](/reference/input/gameinput/interfaces/igameinputreading/igameinputreading)\
[IGameInputReading::GetInputKind](/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getinputkind)

## Version History

| Version | Changes     |
| ------- | ----------- |
| **v0**  | Introduced. |


## Related topics

- [IGameInputReading::GetDevice](/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getdevice.md)
- [IGameInputReading::GetUiNavigationState](/reference/input/gameinput/deprecated/interfaces/igameinputreading/methods/igameinputreading_getuinavigationstate.md)
- [IGameInputReading::GetSensorsState](/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getsensorsstate.md)
- [IGameInputReading::GetKeyState](/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getkeystate.md)
- [IGameInputReading::GetMouseState](/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getmousestate.md)
