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

# IGameInput::GetCurrentReading

> IGameInput::GetCurrentReading

# IGameInput::GetCurrentReading

Recupera la lectura más reciente de la secuencia de entrada que coincide con un filtro proporcionado por el autor de la llamada.

## Sintaxis

```cpp theme={null}
HRESULT GetCurrentReading(
    GameInputKind inputKind,
    IGameInputDevice* device,
    IGameInputReading** reading
);
```

### Parámetros

*inputKind*   \_In\_\\
Tipo: [GameInputKind](/reference/input/gameinput/enums/gameinputkind)

Uno de los valores de la enumeración que designa el tipo de dispositivo de entrada que se usa, como un mando, un teclado o un mouse. Los valores de la enumeración pueden combinarse para designar varios tipos de entrada. Cuando se especifican varios tipos de entrada, cualquier lectura que contenga al menos uno de los tipos de entrada coincidirá y se devolverá.

*device*   \_In\_opt\_\\
Tipo: IGameInputDevice\*

Filtro opcional que devuelve lecturas de un dispositivo específico.

*reading*   \_COM\_Outptr\_\\
Tipo: IGameInputReading\*\*

La lectura de entrada que se va a devolver. Devuelve `NULL` en caso de error.

### Valor devuelto

Tipo: HRESULT

Resultado de la función.

## Comentarios

Esta función se usa para acceder inicialmente a la secuencia de entrada. Puede usar esta función junto con los métodos `GetNextReading` y `GetPreviousReading` para recorrer la secuencia de entrada sin perder entradas. Como alternativa, puede seguir llamando a `GetCurrentReading` para continuar obteniendo la lectura más actual si su juego puede permitirse perder alguna entrada.

En el ejemplo de código siguiente se muestra cómo sondear el estado actual del mando.

```cpp theme={null}
Microsoft::WRL::ComPtr<IGameInput> gameInput;

void PollGamepadInput() noexcept
{
    Microsoft::WRL::ComPtr<IGameInputReading> reading;

    if (SUCCEEDED(gameInput->GetCurrentReading(
        GameInputKindGamepad,
        nullptr,
        &reading)))
    {
        // Application-specific code to process the reading.
    }
}
```

En el ejemplo de código siguiente se muestra cómo sondear el estado actual del mando desde un dispositivo específico.

```cpp theme={null}
Microsoft::WRL::ComPtr<IGameInput> gameInput;
Microsoft::WRL::ComPtr<IGameInputDevice> gamepad;

void PollGamepadInput() noexcept
{
    Microsoft::WRL::ComPtr<IGameInputReading> reading;

    if (SUCCEEDED(gameInput->GetCurrentReading(
        GameInputKindGamepad,
        gamepad.Get(),
        &reading)))
    {
        // Lock onto the first device we find input from, since this
        // must be the one the player is using (if it's generating input).
        if (!gamepad)
        {
            reading->GetDevice(&gamepad);
        }

        // Application-specific code to process the reading.
    }

    else
    {
        // Go back to looking for a device to lock onto, if the previous one is gone.
        gamepad = nullptr;
    }
}
```

En el ejemplo de código siguiente se muestra cómo sondear todos los estados del mando desde un dispositivo específico.

```cpp theme={null}
Microsoft::WRL::ComPtr<IGameInput> gameInput;
Microsoft::WRL::ComPtr<IGameInputDevice> gamepad;
Microsoft::WRL::ComPtr<IGameInputReading> prevReading;

void PollGamepadInput() noexcept
{
    if (!prevReading)
    {
        if (SUCCEEDED(gameInput->GetCurrentReading(
            GameInputKindGamepad,
            nullptr,
            &prevReading)))
        {
            gamepad.Attach(prevReading->GetDevice());

            // Application-specific code to process the initial reading.
        }
    }

    else
    {
        Microsoft::WRL::ComPtr<IGameInputReading> nextReading;
        HRESULT hr = gameInput->GetNextReading(
            prevReading.Get(),
            GameInputKindGamepad,
            gamepad.Get(),
            &nextReading);

        if (SUCCEEDED(hr))
        {
            // Application-specific code to process the next reading.

            prevReading = nextReading;
        }

        else if (hr != GAMEINPUT_E_READING_NOT_FOUND)
        {
            gamepad = nullptr;
            prevReading = nullptr;
        }
    }
}
```

## Requisitos

[Información general de la API de entrada](/build/core-features/common/input/overviews/input-overview)\
[IGameInput\_GetNextReading](/reference/input/gameinput/interfaces/igameinput/methods/igameinput_getnextreading)\
[IGameInput\_GetPreviousReading](/reference/input/gameinput/interfaces/igameinput/methods/igameinput_getpreviousreading)\
[IGameInput](/reference/input/gameinput/interfaces/igameinput/igameinput)

## Historial de versiones

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


## Related topics

- [IGameInput::GetTemporalReading](/es/reference/input/gameinput/deprecated/interfaces/igameinput/methods/igameinput_gettemporalreading.md)
- [IGameInput::GetPreviousReading](/es/reference/input/gameinput/interfaces/igameinput/methods/igameinput_getpreviousreading.md)
- [IGameInput::GetNextReading](/es/reference/input/gameinput/interfaces/igameinput/methods/igameinput_getnextreading.md)
- [IGameInput::FindDeviceFromId](/es/reference/input/gameinput/interfaces/igameinput/methods/igameinput_finddevicefromid.md)
- [GameInputKind](/es/reference/input/gameinput/enums/gameinputkind.md)
