> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# GameInputCreate

> GameInputCreate

# GameInputCreate

获取 IGameInput 接口的实例。

## 语法

```cpp theme={null}
HRESULT GameInputCreate(
    IGameInput** gameInput
);
```

### 参数

*gameInput*   \_COM\_Outptr\_\
类型：IGameInput\*\*

调用返回的底层每进程单例的实例。

### 返回值

类型：HRESULT

函数结果。

## 备注

`GameInputCreate` 函数是一个用于获取或创建 GameInput 实例的 Nano-COM 工厂。生成的接口由每个进程的单例支持，该单例在首次调用此函数时创建。因此，首次调用此函数可能需要少量时间才能返回——此时间足够短，通常从 UI 线程调用是安全的，但不适合从时间敏感的上下文（例如游戏循环）中调用。同一进程后续对该函数的调用仅会向底层单例添加另一个引用并快速返回。

由于系统上一次只有一个 GameInput 版本可用，因此支持的接口集可能会因所安装的 GameInput 版本而异。由于 GameInput 向后兼容，即使在添加新功能的同时，新版本也会继续支持旧接口。

应用程序应在启动期间调用一次 `GameInputCreate` 函数，并保留 `IGameInput` 对象引用，直到应用程序准备好关闭。即使对于响应进程生命周期管理 (PLM) 挂起事件的通用 Windows 平台 (UWP) 应用，这也适用，因为重新初始化 `GameInput` 单例（当应用恢复时）的开销通常超过在应用程序中释放少量内存所带来的好处。

## 要求

**标头：** GameInput.h

[高级 GameInput 主题](https://docs.xbox.com/zh-CN/build/core-features/common/input/advanced/input-advanced-topics.md)\
[GameInput 概述](https://docs.xbox.com/zh-CN/build/core-features/common/input/overviews/input-overview.md)\
[GameInput](https://docs.xbox.com/zh-CN/reference/input/gameinput/gameinput_members.md)

## 版本历史

| 版本 | 变更 |
| - | - |
| **v0** | 引入。 |

## 概念文档

* [GameInput 基础知识](https://docs.xbox.com/zh-CN/build/core-features/common/input/overviews/input-fundamentals.md)


## Related topics

- [GameInput 常见问题](https://docs.xbox.com/zh-CN/build/core-features/common/input/overviews/input-faq.md)
- [GameInput API 成员](https://docs.xbox.com/zh-CN/reference/input/gameinput/gameinput_members.md)
- [GameInput 简介](https://docs.xbox.com/zh-CN/build/core-features/common/input/overviews/input-overview.md)
- [IGameInput::CreateDispatcher](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinput/methods/igameinput_createdispatcher.md)
- [IGameInput::CreateAggregateDevice](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinput/methods/igameinput_createaggregatedevice.md)
