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

# IGameInput::RegisterReadingCallback

> IGameInput::RegisterReadingCallback

# IGameInput::RegisterReadingCallback

注册一个函数，当输入流中到达新的读取数据时调用该函数。

## 语法

```cpp theme={null}
HRESULT RegisterReadingCallback(
    IGameInputDevice* device,
    GameInputKind inputKind,
    void* context,
    GameInputReadingCallback callbackFunc,
    GameInputCallbackToken* callbackToken
);
```

### 参数

*device*   \_In\_opt\_\
类型:IGameInputDevice\*

将已注册的回调限制为仅对特定设备触发。

*inputKind*   \_In\_\
类型:[GameInputKind](/reference/input/gameinput/enums/gameinputkind)

将已注册的回调限制为仅对支持至少一种指定输入类型的设备触发。

*context*   \_In\_opt\_\
类型:void\*

为回调函数提供相关信息的对象。通常为调用方对象。

*callbackFunc*   \_In\_\
类型:GameInputReadingCallback

由游戏定义的回调函数。

*callbackToken*   \_Result\_zeroonfailure\_\
类型:GameInputCallbackToken\*

标识已注册回调函数的令牌。当您希望取消或注销回调函数时，将使用该令牌标识已注册的函数。

### 返回值

类型:HRESULT

函数结果。

## 注解

注册回调不会导致立即以与所提供的输入过滤器匹配的最新读取值分发初始回调。它只会为后续的状态变化分发回调。

## 要求

**头文件:** GameInput.h

[Input API 概述](/build/core-features/common/input/overviews/input-overview)\
[IGameInput](/reference/input/gameinput/interfaces/igameinput/igameinput)\
[IGameInput::UnregisterCallback](/reference/input/gameinput/interfaces/igameinput/methods/igameinput_unregistercallback)\
[IGameInput::StopCallback](/reference/input/gameinput/interfaces/igameinput/methods/igameinput_stopcallback)

## 版本历史

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


## Related topics

- [GameInputReadingCallback](/zh-CN/reference/input/gameinput/functions/gameinputreadingcallback.md)
- [IGameInput::StopCallback](/zh-CN/reference/input/gameinput/interfaces/igameinput/methods/igameinput_stopcallback.md)
- [IGameInput::FindDeviceFromId](/zh-CN/reference/input/gameinput/interfaces/igameinput/methods/igameinput_finddevicefromid.md)
- [IGameInput::UnregisterCallback](/zh-CN/reference/input/gameinput/interfaces/igameinput/methods/igameinput_unregistercallback.md)
- [IGameInput::RegisterDeviceCallback](/zh-CN/reference/input/gameinput/interfaces/igameinput/methods/igameinput_registerdevicecallback.md)
