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

# IGameInput::RegisterKeyboardLayoutCallback

> IGameInput::RegisterKeyboardLayoutCallback

# IGameInput::RegisterKeyboardLayoutCallback

在键盘布局发生变化时注册一个回调函数。

## 语法

```cpp theme={null}
HRESULT RegisterKeyboardLayoutCallback(
    IGameInputDevice* device,
    void* context,
    GameInputKeyboardLayoutCallback callbackFunc,
    GameInputCallbackToken* callbackToken
);
```

### 参数

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

可选参数，用于将已注册的回调限制为仅对特定设备触发。

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

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

*callbackFunc*   \_In\_\
类型:[GameInputKeyboardLayoutCallback](https://docs.xbox.com/zh-CN/reference/input/gameinput/functions/gameinputkeyboardlayoutcallback.md)

由游戏定义的回调函数，在键盘布局发生变化时被调用。

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

标识已注册回调函数的令牌。当需要取消或注销回调函数时，会使用此令牌来标识已注册的函数。

### 返回值

类型:HRESULT

函数结果。

## 注解

`RegisterKeyboardLayoutCallback` 方法在键盘布局发生变化时注册一个回调函数。有关相关信息，请参见 [IGameInput::UnregisterCallback](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinput/methods/igameinput_unregistercallback.md) 和 [IGameInput::StopCallback](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinput/methods/igameinput_stopcallback.md) 方法。有关 GameInput API 的中级和高级用法，请参见 [Advanced GameInput topics](https://docs.xbox.com/zh-CN/build/core-features/common/input/advanced/input-advanced-topics.md)。

## 要求

`RegisterKeyboardLayoutCallback` 方法在键盘布局发生变化时注册一个回调函数。有关相关信息，请参见 [IGameInput::UnregisterCallback](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinput/methods/igameinput_unregistercallback.md) 和 [IGameInput::StopCallback](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinput/methods/igameinput_stopcallback.md) 方法。有关 GameInput API 的中级和高级用法，请参见 [Advanced GameInput topics](https://docs.xbox.com/zh-CN/build/core-features/common/input/advanced/input-advanced-topics.md)。

**头文件:** GameInput.h

[GameInput 概述](https://docs.xbox.com/zh-CN/build/core-features/common/input/overviews/input-overview.md)\
[IGameInput](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinput/igameinput.md)

## 版本历史

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


## Related topics

- [IGameInput::RegisterDeviceCallback](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinput/methods/igameinput_registerdevicecallback.md)
- [IGameInput::RegisterReadingCallback](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinput/methods/igameinput_registerreadingcallback.md)
- [IGameInput::RegisterGuideButtonCallback（已弃用）](https://docs.xbox.com/zh-CN/reference/input/gameinput/deprecated/interfaces/igameinput/methods/igameinput_registerguidebuttoncallback.md)
- [GameInput API 成员](https://docs.xbox.com/zh-CN/reference/input/gameinput/gameinput_members.md)
- [IGameInput::StopCallback](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinput/methods/igameinput_stopcallback.md)
