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

# XGameStreamingShowTouchControlLayout

> XGameStreamingShowTouchControlLayout

# XGameStreamingShowTouchControlLayout

请求所有已连接的流式处理客户端设备显示指定的触摸布局。

## 语法

```cpp theme={null}
void XGameStreamingShowTouchControlLayout(
         const char* layout  
)  
```

## 参数

*layout*   \_In\_opt\_z\_\
类型：char\*

要显示的触摸控件布局的名称，或 `nullptr` 以显示标准 XBOX 控制器布局。

要在流式处理客户端设备上显示的触摸控件布局的 ID。布局 ID 是特定于游戏的，与作为[触控适配工具包](/build/core-features/common/game-streaming/game-streaming-touch-touch-adaptation-kit-overview)的一部分提供给 XBOX Game Streaming 服务的布局的 ID 对应。此字符串应采用 UTF-8 编码。

如果提供 `nullptr`，将显示默认的触摸控件集。

任何不与游戏的触摸控件布局 ID 对应的字符串都不会更改客户端设备上触摸控件的状态。在这些情况下，Content Test Application 可能会提供诊断信息。

## 返回值

类型：void

## 备注

此 API 请求所有当前的游戏流式处理客户端在玩家的客户端设备上显示特定的触摸控件布局。如果玩家未在对游戏进行流式处理，或者他们正在流式处理到未启用触摸的设备，则此函数不执行任何操作。

如果玩家使用的是物理控制器而不是触摸控件，则此函数不会强制在其设备上显示触摸控件。相反，客户端将在下次玩家开始使用触摸控件时使用上次请求的布局。

你可以将此函数视为对客户端设备的提示，告诉它如果玩家正在使用触摸控件，哪种触摸控件布局最适合当前游戏状态。然后客户端设备将管理何时最适合将这些控件放在玩家的屏幕上。

每次调用 `XGameStreamingShowTouchControlLayout` 都会导致通过网络发送一条消息，因此不应该每帧调用它。相反，只有在游戏需要在不同的触摸控件布局之间切换时才调用此 API。

如果调用 `XGameStreamingShowTouchControlLayout` 时没有客户端设备连接，则当客户端连接时，它将接收最近请求的触摸控件布局。

如果你的游戏想在**特定**已连接的流式处理客户端设备上显示触摸控件布局，请考虑改用 [XGameStreamingShowTouchControlLayoutOnClient](/reference/system/xgamestreaming/functions/xgamestreamingshowtouchcontrollayoutonclient)。

## 示例

```C++ theme={null}
void OnGameStateChanged(GameState newState)
{
    // Toggle to the set of touch overlay controls which best match the new state of the game
    switch (newState)
    {
    case GameState::FirstPersonAction:
        XGameStreamingShowTouchControlLayout("FirstPersonAction");
        break;
    case GameState::Driving:
        XGameStreamingShowTouchControlLayout("Driving");
        break;
    case GameState::CutScene:
        // Don't show any touch overlay controls while the cut scene is rendering
        XGameStreamingHideTouchControls();
        break;
    }
}
```

## 要求

**标头：** xgamestreaming.h

**库：** xgameruntime.lib

**支持的平台：** Windows、XBOX One 系列主机和 XBOX Series 主机

## 另请参阅

[XGameStreamingHideTouchControls](/reference/system/xgamestreaming/functions/xgamestreaminghidetouchcontrols)\
[XGameStreamingShowTouchControlLayoutOnClient](/reference/system/xgamestreaming/functions/xgamestreamingshowtouchcontrollayoutonclient)\
[XGameStreaming](/reference/system/xgamestreaming/xgamestreaming_members#TouchAdaptation)


## Related topics

- [XGameStreamingShowTouchControlLayoutOnClient](/zh-CN/reference/system/xgamestreaming/functions/xgamestreamingshowtouchcontrollayoutonclient.md)
- [XGameStreamingHideTouchControls](/zh-CN/reference/system/xgamestreaming/functions/xgamestreaminghidetouchcontrols.md)
- [XGameStreamingShowTouchControlsWithStateUpdate](/zh-CN/reference/system/xgamestreaming/functions/xgamestreamingshowtouchcontrolswithstateupdate.md)
- [根据游戏状态更改触控布局](/zh-CN/build/core-features/common/game-streaming/building-touch-layouts/game-streaming-touch-changing-layouts-game-state.md)
- [XGameStreaming](/zh-CN/reference/system/xgamestreaming/xgamestreaming_members.md)
