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

タッチ レイアウトが動作を変更するために利用できる状態を、すべてのストリーミング クライアントで更新します。現在表示されているタッチ コントロール セットに対する視覚的な変更は、すべての変数が更新された後に行われます。

## 構文

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

### パラメーター

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

渡される操作の配列のサイズ。

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

要求されているすべての状態変数の更新の配列。

### 戻り値

Type: HRESULT

成功した場合は **S\_OK** を返します。それ以外の場合はエラー コードを返します。

#### 想定されるエラー

| エラー コード                            | エラー値       | エラーの原因                                                                                                                                                               |
| ---------------------------------- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| E\_GAMESTREAMING\_NOT\_INITIALIZED | 0x89245400 | XGameStreaming ランタイムが初期化されていません。他の API を呼び出す前に [XGameStreamingInitialize](/reference/system/xgamestreaming/functions/xgamestreaminginitialize) を呼び出してください。           |
| E\_INVALIDARG                      | 0x80070057 | 指定された操作に、操作の [XGameStreamingTouchControlsStateValueKind](/reference/system/xgamestreaming/enums/xgamestreamingtouchcontrolsstatevaluekind) で指定されたデータ型と一致するデータがありません。 |

## 解説

ストリーミング クライアントで使用されるタッチ レイアウトは状態に依存する場合があり、その初期値はタッチ レイアウト バンドルに埋め込まれています。ゲームは状態を更新でき、これにより、プレイヤーに現在表示されているレイアウトが変更される可能性があります。

ゲームは `XGameStreamingUpdateTouchControlsState` を使用して接続されているすべてのクライアントの状態を更新するか、[XGameStreamingUpdateTouchControlsStateOnClient](/reference/system/xgamestreaming/functions/xgamestreamingupdatetouchcontrolsstateonclient) を使用して特定の接続クライアントを更新することができます。

ゲームが同時に状態を更新し、レイアウト変更を行う必要がある場合は、[XGameStreamingShowTouchControlsWithStateUpdate](/reference/system/xgamestreaming/functions/xgamestreamingshowtouchcontrolswithstateupdate) または [XGameStreamingShowTouchControlsWithStateUpdateOnClient](/reference/system/xgamestreaming/functions/xgamestreamingshowtouchcontrolswithstateupdateonclient) を利用できます。

## 例

```C++ theme={null}
// この例では、プレイヤーがアクティブな武器を切り替えた後 - 発射ボタンのイメージを
// 現在の武器と一致するように更新し、プレイヤーが予備のマガジンを持っているかどうかに基づいて
// リロードの有効状態を設定します。
// 
// 適切な状態を持つアクティブな武器を含むゲーム構造体が渡されることを想定しています。
//
// 指定された武器の定数文字列を返す、ゲーム固有の GetImageName 関数を想定しています


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}
// この例では、プレイヤーがインベントリ画面に移動し、アイテムを 2 つのアクティブ スロットに
// 割り当てられるようにした後、レイアウトの状態を更新して、レイアウトがプレイヤーの現在の
// インベントリから読み込まれたアイテムと一致するようにします (現在表示されているレイアウトかどうかは問いません)。
// 
// プレイヤーのアクティブなインベントリを含むゲーム構造体が渡されることを想定しています


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

```

## 要件

**ヘッダー:** XGameStreaming.h

**ライブラリ:** xgameruntime.lib\
**サポートされているプラットフォーム**: Windows、XBOX One ファミリー本体および XBOX Series 本体

## 関連項目

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


## Related topics

- [XGameStreamingUpdateTouchControlsStateOnClient](/ja-jp/reference/system/xgamestreaming/functions/xgamestreamingupdatetouchcontrolsstateonclient.md)
- [XGameStreamingShowTouchControlsWithStateUpdate](/ja-jp/reference/system/xgamestreaming/functions/xgamestreamingshowtouchcontrolswithstateupdate.md)
- [XGameStreamingTouchControlsStateOperation](/ja-jp/reference/system/xgamestreaming/structs/xgamestreamingtouchcontrolsstateoperation.md)
- [XGameStreamingTouchControlsStateValue](/ja-jp/reference/system/xgamestreaming/structs/xgamestreamingtouchcontrolsstatevalue.md)
- [XGameStreamingShowTouchControlsWithStateUpdateOnClient](/ja-jp/reference/system/xgamestreaming/functions/xgamestreamingshowtouchcontrolswithstateupdateonclient.md)
