> ## 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::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](/reference/input/gameinput/functions/gameinputkeyboardlayoutcallback)

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

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

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

### 返回值

类型:HRESULT

函数结果。

## 注解

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

## 要求

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

**头文件:** GameInput.h

[GameInput 概述](/build/core-features/common/input/overviews/input-overview)\
[IGameInput](/reference/input/gameinput/interfaces/igameinput/igameinput)

## 版本历史

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


## Related topics

- [IGameInput::RegisterReadingCallback](/zh-CN/reference/input/gameinput/interfaces/igameinput/methods/igameinput_registerreadingcallback.md)
- [IGameInput::RegisterDeviceCallback](/zh-CN/reference/input/gameinput/interfaces/igameinput/methods/igameinput_registerdevicecallback.md)
- [IGameInput::RegisterGuideButtonCallback](/zh-CN/reference/input/gameinput/deprecated/interfaces/igameinput/methods/igameinput_registerguidebuttoncallback.md)
- [GameInput](/zh-CN/reference/input/gameinput/gameinput_members.md)
- [IGameInput::StopCallback](/zh-CN/reference/input/gameinput/interfaces/igameinput/methods/igameinput_stopcallback.md)
