> ## 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 是 GDK 的统一输入 API，支持 XBOX 主机及 Windows 10 及更高版本上的游戏手柄、键盘、鼠标和其他控制器。

<a id="introductionSection" />

GameInput 是新一代输入 API，通过单一一致的接口公开各种输入设备。它采用简单的编程模型设计，易于使用。GameInput 从零开始构建以实现最佳性能。GameInput API 的关键特性如下。

* **可用性**

  GameInput 通过 Microsoft Game Development Kit (GDK) 在 XBOX 上可用，通过 NuGet 在 PC 上可用。支持从 Windows 10 19H1（2019 年 5 月更新）开始的旧版本 Windows。

* **一致性**

  GameInput 通过统一的输入模型公开来自键盘、鼠标、游戏手柄以及其他游戏控制器的输入，并同步到共同的时间基准。处理这些设备输入的代码几乎完全相同，使用大致相同的函数，只是应用不同的筛选器。这种一致性使得添加对更多输入设备的支持变得容易，无需对输入代码进行重大更改。

* **功能**

  GameInput 是所有遗留输入 API（XInput、DirectInput、Raw Input、Human Interface Device (HID) 以及 WinRT API）的功能超集，并新增了自有功能。GameInput 的功能既包括简单的固定格式游戏手柄状态，也涵盖详细的低层原始设备访问。你可以通过轮询或以事件驱动方式使用回调获取输入。完全支持触觉反馈、传感器和力反馈。开发者可以在 GameInput 之上轻松编写第三方设备 SDK，以访问自定义设备功能。

* **性能**

  GameInput 直接构建在 Windows 硬件接口之上，实现最低的输入延迟和资源占用。几乎所有 API 函数都是无锁的，且具有严格的性能保证，同时 100% 线程安全。此设计使其在渲染线程等对时序敏感的上下文中调用是安全的（最大例外是 GameInputCreate 调用）。高级应用程序可以直接控制 GameInput 内部异步工作队列的调度，控制哪个线程执行工作以及执行频率。

* **可维护性**

  新版 GameInput 运行时支持从 v.0 到最新的所有 API 版本，游戏可以指定其开发时所用的 API 版本。这种版本管理确保即使 GameInput 发布了新版本并引入新功能与改进，游戏仍能按预期工作。此外，随着 Windows 平台的发展，旧版游戏也能受益于生活质量的改进，包括对新发布硬件设备的支持以及平台侧修复。

* **易用性**

  GameInput 在设计上将易用性置于首要位置。大多数常见输入任务只需几行代码即可实现。

<a id="gettingStartedSection" />

## 入门

无论目标平台是什么，都应对所有新代码使用 GameInput API。它跨所有 Microsoft 平台提供支持，包括早期版本的 Windows，并且相较于遗留 API 提供更佳的性能。

<Note>对于在 XBOX One GDK 上开发的游戏，GameInput 是唯一可用的输入 API。</Note>

如果你正在开发面向 PC 的游戏，请从 [Microsoft.GameInput](https://www.nuget.org/packages/Microsoft.GameInput) NuGet 包安装 GameInput。

若要详细了解 GameInput API，请从 [GameInput 基础](/build/core-features/common/input/overviews/input-fundamentals)开始。

如果你要从现有代码库移植输入代码，或计划并行使用 GameInput 的部分扩展能力，请参阅 [GameInput 移植指南](/build/core-features/common/input/porting/input-porting)，获取特定 API 的指导。

<a id="seeAlsoSection" />

## 另请参阅

[GameInput 基础](/build/core-features/common/input/overviews/input-fundamentals)

[通过 NuGet 在 PC 上使用 GameInput](/build/core-features/common/input/overviews/input-nuget)

[GameInput 移植指南](/build/core-features/common/input/porting/input-porting)

[GameInput API 参考](/reference/input/gc-reference-input-toc)

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


## Related topics

- [概述](/zh-CN/build/core-features/common/input/overviews/index.md)
- [从 XInput 移植到 GameInput](/zh-CN/build/core-features/common/input/porting/input-porting-xinput.md)
- [GameInputCreate](/zh-CN/reference/input/gameinput/functions/gameinputcreate.md)
- [从 Windows.XBOX.Input 移植到 GameInput](/zh-CN/build/core-features/common/input/porting/input-porting-wxi.md)
- [GameInputGamepadButtons](/zh-CN/reference/input/gameinput/enums/gameinputgamepadbuttons.md)
