> ## 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（已弃用）

> 注册在键盘布局更改时调用的回调函数（已在 v4 中移除）。

> [!WARNING]
>
> **已弃用。** 此方法已在 GameInput v4 中移除，当前 API 中不再提供。请改为处理 `GameInputDeviceEventKeyboardLayoutUpdated` [设备事件](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/input/gameinput/enums/gameinputdeviceevent)，并调用 [IGameInputDevice::GetKeyboardInfo](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getkeyboardinfo.md) 获取新布局。

注册在键盘布局更改时调用的回调函数。

## 语法

```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://learn.microsoft.com/en-us/gaming/gdk/docs/reference/input/gameinput/deprecated/functions/gameinputkeyboardlayoutcallback)

由标题定义、在键盘布局更改时调用的回调函数。

*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/deprecated/interfaces/igameinput/methods/igameinput_stopcallback.md) 方法。有关 GameInput API 的中级和高级用例，请参阅 [GameInput 高级主题](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/deprecated/interfaces/igameinput/methods/igameinput_stopcallback.md) 方法。有关 GameInput API 的中级和高级用例，请参阅 [GameInput 高级主题](https://docs.xbox.com/zh-CN/build/core-features/common/input/advanced/input-advanced-topics.md)。

**头文件：** GameInput.h

## 另请参阅

[已弃用的 GameInput API 成员](https://docs.xbox.com/zh-CN/reference/input/gameinput/deprecated/gameinput_deprecated_members.md)\
[GameInputDeviceEvent](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/input/gameinput/enums/gameinputdeviceevent)\
[IGameInputDevice::GetKeyboardInfo](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getkeyboardinfo.md)\
[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)

## 版本历史

| 版本 | 变更 |
| - | - |
| **v4** | 已移除。 |
| **v0** | 引入。 |


## Related topics

- [IGameInput::RegisterKeyboardLayoutCallback](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinput/methods/igameinput_registerkeyboardlayoutcallback.md)
- [IGameInput::StopCallback（已弃用）](https://docs.xbox.com/zh-CN/reference/input/gameinput/deprecated/interfaces/igameinput/methods/igameinput_stopcallback.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/deprecated/gameinput_deprecated_members.md)
- [RegisterSystemButtonCallback（已弃用）](https://docs.xbox.com/zh-CN/reference/input/gameinput/deprecated/interfaces/igameinput/methods/igameinput_registersystembuttoncallback.md)
