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

# XGameStreamingGetAssociatedFrame

> XGameStreamingGetAssociatedFrame

# XGameStreamingGetAssociatedFrame

<Info>**已淘汰。** 此 API 自 2604 GDK 版本起已淘汰，並將在未來的 GDK 版本中移除。沒有替代 API：遊戲應改用 [XGameStreamingGetStreamAddedLatency](/zh-TW/reference/system/xgamestreaming/functions/xgamestreaminggetstreamaddedlatency) 進行可感知延遲的遊戲玩法調整。</Info>

從特定輸入讀數取得框架管線權杖。

## 語法

```cpp theme={null}
HRESULT XGameStreamingGetAssociatedFrame(  
         IGameInputReading* gamepadReading,  
         D3D12XBOX_FRAME_PIPELINE_TOKEN* framePipelineToken  
)  
```

### 參數

*gamepadReading*   \_In\_\
類型：IGameInputReading\*

正在查詢的遊戲台讀數。

*framePipelineToken*   \_Out\_\
類型：D3D12XBOX\_FRAME\_PIPELINE\_TOKEN\*

與玩家進行輸入時用戶端裝置上所顯示之框架相關聯的框架管線權杖。此管線權杖對應於遊戲呈現框架並將其傳送至用戶端裝置時的 PresentX 呼叫。

### 傳回值

類型：HRESULT

如果成功，則傳回 **S\_OK**；否則傳回錯誤碼。

#### 可能的錯誤

| 錯誤碼 | 錯誤值 | 錯誤原因 |
| - | - | - |
| E\_GAMESTREAMING\_NOT\_INITIALIZED | 0x89245400 | XGameStreaming 執行階段尚未初始化。呼叫其他 API 之前，請先呼叫 [XGameStreamingInitialize](/zh-TW/reference/system/xgamestreaming/functions/xgamestreaminginitialize)。 |
| E\_GAMESTREAMING\_NO\_DATA | 0x89245402 | 要求的資料無法使用。資料稍後可能會可供使用。 |
| E\_GAMESTREAMING\_NOT\_STREAMING\_CONTROLLER | 0x89245404 | 目前的讀數並非來自串流控制器。 |

## 備註

當玩家正在串流遊戲時，如果遊戲需要根據玩家進行輸入時其裝置上所顯示的特定框架來變更遊戲行為，即可使用 `XGameStreamingGetAssociatedFrame`。

這可讓遊戲根據玩家在輸入當下所看到的框架 (而非目前的框架) 做出模擬決策。

`XGameStreamingGetAssociatedFrame` 只能在建立新的輸入讀數時，為遊戲提供有關所顯示框架的資訊。如果遊戲需要判斷在玩家可能尚未進行輸入時所顯示的內容，遊戲應使用 [XGameStreamingGetLastFrameDisplayed](/zh-TW/reference/system/xgamestreaming/functions/xgamestreaminggetlastframedisplayed)。

## 範例

```C++ theme={null}
// In this example, when processing input, the game would like to pass along the frame 
// that was being displayed to the player at the time of input so that their simulation
// engine can take that into account.

// The framePipelineToken was initially captured at the callback of WaitFrameEventX

void Game::Update(DX::StepTimer const& timer)
{
    IGameInputReading* reading;
    if (SUCCEEDED(g_gameInput->GetCurrentReading(GameInputKindGamepad, g_gamepad, &reading)))
    {
        D3D12XBOX_FRAME_PIPELINE_TOKEN framePipelineToken = D3D12XBOX_FRAME_PIPELINE_TOKEN_NULL;        

        if SUCCEEDED(XGameStreamingGetAssociatedFrame(&reading, &framePipelineToken)) 
        {
            SimulateBasedOnInputAndFrameDisplayed(reading, framePipelineToken);
        }
        else 
        {
            // simulate based on current frame
            SimulateBasedOnInput(reading);
        }

        reading->Release();
    }
}

```

## 需求

**標頭：** xgamestreaming.h

**程式庫：** xgameruntime.lib

**支援的平台：** Windows、XBOX One 系列主機和 XBOX Series 主機

## 概念文件

* [遊戲串流延遲補償深入探討](/zh-TW/build/core-features/common/game-streaming/game-streaming-latency-compensation-deep-dive)

## 另請參閱

[XGameStreamingGetLastFrameDisplayed](/zh-TW/reference/system/xgamestreaming/functions/xgamestreaminggetlastframedisplayed)\
[XGameStreaming](/zh-TW/reference/system/xgamestreaming/xgamestreaming_members#Latency)\
[遊戲串流延遲補償概觀](/zh-TW/build/core-features/common/game-streaming/game-streaming-latency-compensation-overview)


## Related topics

- [XGameStreamingGetAssociatedFrame](/reference/system/xgamestreaming/functions/xgamestreaminggetassociatedframe.md)
- [XGameStreamingGetLastFrameDisplayed](/reference/system/xgamestreaming/functions/xgamestreaminggetlastframedisplayed.md)
