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

# 將 GameInput 與現有的輸入堆疊結合使用

> 將 GameInput 與現有的輸入堆疊結合使用

<a id="introductionSection" />

由於 GameInput 的功能保證可延伸至未來的裝置，並為應用程式提供抽象化，我們仍建議應用程式盡可能將輸入程式碼轉移至 `GameInput`。`GameInput` 的功能是所有舊版輸入 API 的超集。因此，在大多數情況下，從舊版輸入 API 移植是一個簡單的過程。最大的變更通常源自於 `GameInput` 是以輸入為中心，而非以裝置為中心。使用舊版 API 的程式碼通常會先列舉輸入裝置，再讀取其輸入。不過，在 `GameInput` 中，這並非必要。適應 `GameInput` 以輸入為中心的模型，通常佔了要移植之舊程式碼結構變更的大部分。

下列主題提供 `GameInput` 與舊版輸入 API 之間差異的詳細資訊。這些主題也包含程式碼範例，突顯 API 之間最大的差異。

[從 Windows.Xbox.Input 移植到 GameInput](/zh-TW/build/core-features/common/input/porting/input-porting-wxi)

說明如何從原始 XBOX One 軟體開發套件中的 `Windows.Xbox.Input` 移植。

[從 XInput 移植到 GameInput](/zh-TW/build/core-features/common/input/porting/input-porting-xinput)

說明如何從 `XInput` 移植。

<a id="sideBySideSection" />

## 並行使用 GameInput 與舊版 API

對於想要並行使用 GameInput 程式碼與舊版介面和 API 的應用程式，此 API 也具有足夠的彈性來支援此使用案例。這讓應用程式能夠輕鬆運用感應器和觸覺回饋支援等新功能，而不需取代整個輸入堆疊。從第 1 版 (v1) 開始，`GameInputDeviceInfo` 包含一個 `pnppath` 欄位，代表基礎裝置的路徑。此欄位與 DirectInput 所提供之 `DIPROPGUIDANDPATH` 中的路徑相同。應用程式也可以透過呼叫 `CreateFile`，使用此欄位直接與裝置互動。請注意，非遊戲台的 Game Input Protocol (GIP) 裝置可能沒有此屬性，因為它們無法直接開啟。

<a id="seeAlsoSection" />

## 另請參閱

[GameInput 簡介](/zh-TW/build/core-features/common/input/overviews/input-overview)

[輸入 API 參考](/zh-TW/reference/input/gc-reference-input-toc)

[Microsoft Game Development Kit](/zh-TW/services/playfab/sdks/platforms/gdk)


## Related topics

- [XR-013 將 Microsoft 帳戶與發行者帳戶連結](/zh-TW/publishing/certification/xr/xr-013.md)
- [将 GameInput 与现有输入堆栈结合](/zh-CN/build/core-features/common/input/porting/input-porting.md)
- [Windows 與 ROG XBOX Ally 總覽](/zh-TW/paths/windows/overview.md)
- [無障礙功能標籤](/zh-TW/build/game-principles/accessibility/accessibility-feature-tags.md)
- [将现有输入代码移植到 GameInput](/zh-CN/build/core-features/common/input/porting/index.md)
