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

Récupère la lecture la plus récente du flux d'entrée qui correspond à un filtre fourni par l'appelant.

## Syntaxe

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

### Paramètres

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

L'une des valeurs d'énumération qui désigne le type de périphérique d'entrée utilisé, par exemple une manette, un clavier, une souris ou une manette de jeu. Les valeurs d'énumération peuvent être combinées pour désigner plusieurs types d'entrée. Lorsque plusieurs types d'entrée sont spécifiés, toutes les lectures contenant au moins l'un de ces types d'entrée sont considérées comme correspondantes et retournées.

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

Filtre facultatif qui retourne les lectures d'un périphérique spécifique.

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

Lecture d'entrée à retourner. Retourne `NULL` en cas d'échec.

### Valeur de retour

Type : HRESULT

Résultat de la fonction.

## Remarques

Cette fonction sert à accéder initialement au flux d'entrée. Vous pouvez utiliser cette fonction avec les méthodes `GetNextReading` et `GetPreviousReading` pour parcourir le flux d'entrée sans manquer d'entrées. Vous pouvez également continuer à appeler `GetCurrentReading` pour obtenir en permanence la lecture la plus récente si votre jeu peut tolérer la perte de certaines entrées.

L'exemple de code suivant montre comment interroger l'état actuel de la manette de jeu.

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

L'exemple de code suivant montre comment interroger l'état actuel de la manette de jeu à partir d'un périphérique spécifique.

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

L'exemple de code suivant montre comment interroger tous les états de la manette de jeu à partir d'un périphérique spécifique.

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

## Configuration requise

[Vue d'ensemble de l'API d'entrée](/fr/build/core-features/common/input/overviews/input-overview)\
[IGameInput\_GetNextReading](/fr/reference/input/gameinput/interfaces/igameinput/methods/igameinput_getnextreading)\
[IGameInput\_GetPreviousReading](/fr/reference/input/gameinput/interfaces/igameinput/methods/igameinput_getpreviousreading)\
[IGameInput](/fr/reference/input/gameinput/interfaces/igameinput/igameinput)

## Historique des versions

| Version | Modifications |
| - | - |
| **v0** | Introduite. |


## Related topics

- [IGameInput::GetCurrentReading](/reference/input/gameinput/interfaces/igameinput/methods/igameinput_getcurrentreading.md)
- [IGameInput::GetTemporalReading](/reference/input/gameinput/deprecated/interfaces/igameinput/methods/igameinput_gettemporalreading.md)
- [IGameInput::GetPreviousReading](/reference/input/gameinput/interfaces/igameinput/methods/igameinput_getpreviousreading.md)
- [IGameInput::GetNextReading](/reference/input/gameinput/interfaces/igameinput/methods/igameinput_getnextreading.md)
