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

# XGameStreamingUpdateTouchControlsState

> XGameStreamingUpdateTouchControlsState

# XGameStreamingUpdateTouchControlsState

Atualiza, em todos os clientes de streaming, o estado que os layouts de toque podem usar para alterar seu comportamento.  Quaisquer alterações visuais no conjunto de controles por toque que está sendo exibido no momento serão feitas depois que TODAS as variáveis forem atualizadas.

## Sintaxe

```cpp theme={null}
HRESULT XGameStreamingUpdateTouchControlsState(  
         size_t operationCount,  
         const XGameStreamingTouchControlsStateOperation* operations  
)  
```

### Parâmetros

*operationCount*   \_In\_\
Tipo: size\_t

Tamanho da matriz de operações que está sendo passada.

*operations*   \_In\_reads\_opt\_(operationCount)\
Tipo: [XGameStreamingTouchControlsStateOperation\*](/pt-BR/reference/system/xgamestreaming/structs/xgamestreamingtouchcontrolsstateoperation)

Matriz de todas as atualizações de variáveis de estado que estão sendo solicitadas.

### Valor retornado

Tipo: HRESULT

Retornará **S\_OK** se for bem-sucedido; caso contrário, retornará um código de erro.

#### Erros potenciais

| Código de erro | Valor do erro | Motivo do erro |
| - | - | - |
| E\_GAMESTREAMING\_NOT\_INITIALIZED | 0x89245400 | O runtime do XGameStreaming não foi inicializado. Chame [XGameStreamingInitialize](/pt-BR/reference/system/xgamestreaming/functions/xgamestreaminginitialize) antes de chamar outras APIs. |
| E\_INVALIDARG | 0x80070057 | Uma operação especificada não tem dados que correspondam ao tipo de dados especificado no [XGameStreamingTouchControlsStateValueKind](/pt-BR/reference/system/xgamestreaming/enums/xgamestreamingtouchcontrolsstatevaluekind) da operação |

## Comentários

Os layouts de toque usados pelos clientes de streaming podem depender de um estado, cujos valores iniciais são incorporados ao pacote de layouts de toque.  O jogo pode atualizar esse estado, o que pode fazer com que o layout que está sendo exibido no momento para o jogador seja alterado.

O jogo pode usar `XGameStreamingUpdateTouchControlsState` para atualizar o estado de todos os clientes conectados ou [XGameStreamingUpdateTouchControlsStateOnClient](/pt-BR/reference/system/xgamestreaming/functions/xgamestreamingupdatetouchcontrolsstateonclient) para atualizar um cliente conectado específico.

Se o jogo precisar atualizar o estado E fazer uma alteração de layout ao mesmo tempo, ele poderá utilizar [XGameStreamingShowTouchControlsWithStateUpdate](/pt-BR/reference/system/xgamestreaming/functions/xgamestreamingshowtouchcontrolswithstateupdate) ou [XGameStreamingShowTouchControlsWithStateUpdateOnClient](/pt-BR/reference/system/xgamestreaming/functions/xgamestreamingshowtouchcontrolswithstateupdateonclient).

## Exemplos

```C++ theme={null}
// In this example, after the player has switched their active weapon - update the image of the fire
// button to match the current weapon and set the enabled state of reload based on whether the player has
// extra magazines.  
// 
// Assumes passing in game structure that includes the active weapon with appropriate state.  
//
// Assumes a game speciic GetImageName function which returns a constant string for the specified weapoon


void GameStreamingClientManager::UpdateStateAfterWeaponChange(const playerWeapon& playerWeapon)
{
    // create an update for the active weapon's image
    XGameStreamingTouchControlsStateOperation weaponImage;
    weaponImage.operationKind = XGameStreamingTouchControlsStateOperationKind::Replace;
    weaponImage.path = "/ActiveWeaponImage";
    weaponImage.value.valueKind = XGameStreamingTouchControlsStateValueKind::String;
    weaponImage.value.stringValue = GetImageName(playerWeapon.activeWeapon.id);

    // create an update for whether the reload button should be enabled
    XGameStreamingTouchControlsStateOperation reloadEnabled;
    reloadEnabled.operationKind = XGameStreamingTouchControlsStateOperationKind::Replace;
    reloadEnabled.path = "/ReloadEnabled";
    reloadEnabled.valueKind = XGameStreamingTouchControlsStateValueKind::Bool;
    reloadEnabled.booleanValue = playerWeapon.activeWeapon.reloadClips > 0;

    // combine all the updates into the update state call and make the call
    XGameStreamingTouchControlsStateOperation[2] updateOperations = {weaponImage, reloadEnabled};
    
    XGameStreamingUpdateTouchControlsState(updateOperations, _countof(updateOperations));
}
```

```c++ theme={null}
// In this example, after the player has gone to their inventory screen and had the ability to apply items
// to two active slots. Update the state for layouts to have layouts match the player's current
// loaded items from inventory (may or may not be the current layout being displayed).
// 
// Assumes passing in game structure that includes the player's active inventory


void GameStreamingClientManager::AfterInventoryScreen(const PlayerInventory& playerInventory)
{
    std::vector<XGameStreamingTouchControlsStateOperation> updateOperations;
    
    // check the first inventory slots, if empty hide that button from the layout
    // if item is placed in that slot, update the image to match the inventory items
    
    XGameStreamingTouchControlsStateOperation slot1Visible;
    slot1Visible.operationKind = XGameStreamingTouchControlsStateOperationKind::Replace;
    slot1Visible.path = "/Slot1IsVisible";
    slot1Visible.valueKind = XGameStreamingTouchControlsStateValueKind::Boolean;
    slot1Visible.boolValue =  playerInventory.slot1 != nullptr;
    
    updateOperations.push_back(slot1Visible);

    if (playerInventory.slot1 != nullptr) 
    {
        // create an update for the active weapon's image
        XGameStreamingTouchControlsStateOperation slot1Image;
        slot1Image.operationKind = XGameStreamingTouchControlsStateOperationKind::Replace;
        slot1Image.path = "/Slot1Image";
        slot1Image.value.valueKind = XGameStreamingTouchControlsStateValueKind::String;
        slot1Image.value.stringValue = GetImageName(playerInventory.slot1.id);        
        updateOperations.pushBack(slot1Image);
    }
    

    // ... 
    // do the same for the second inventory spot
    // ...

    // Update the state so that layouts will be updated correctly
    XGameStreamingUpdateTouchControlsState(updateOperations.data(), updateOperations.size());
}

```

## Requisitos

**Cabeçalho:** XGameStreaming.h

**Biblioteca:** xgameruntime.lib\
**Plataformas com suporte**: Windows, consoles da família XBOX One e consoles XBOX Series

## Confira também

[XGameStreaming](/pt-BR/reference/system/xgamestreaming/xgamestreaming_members#TouchAdaptation)\
[XGameStreamingTouchControlsStateOperationKind](/pt-BR/reference/system/xgamestreaming/enums/xgamestreamingtouchcontrolsstateoperationkind)\
[XGameStreamingTouchControlsStateOperation](/pt-BR/reference/system/xgamestreaming/structs/xgamestreamingtouchcontrolsstateoperation)\
[XGameStreamingTouchControlsStateValue](/pt-BR/reference/system/xgamestreaming/structs/xgamestreamingtouchcontrolsstatevalue)\
[XGameStreamingShowTouchControlsWithStateUpdate](/pt-BR/reference/system/xgamestreaming/functions/xgamestreamingshowtouchcontrolswithstateupdate)\
[XGameStreamingShowTouchControlsWithStateUpdateOnClient](/pt-BR/reference/system/xgamestreaming/functions/xgamestreamingshowtouchcontrolswithstateupdateonclient)\
[XGameStreamingUpdateTouchControlsStateOnClient](/pt-BR/reference/system/xgamestreaming/functions/xgamestreamingupdatetouchcontrolsstateonclient)


## Related topics

- [XGameStreamingUpdateTouchControlsState](/ko/reference/system/xgamestreaming/functions/xgamestreamingupdatetouchcontrolsstate.md)
- [XGameStreamingUpdateTouchControlsStateOnClient](/ko/reference/system/xgamestreaming/functions/xgamestreamingupdatetouchcontrolsstateonclient.md)
