如何在 Windows OS 中将 HID 使用 ID 转换为虚拟键码?

How to convert from a HID Usage ID to a Virtual Key Code in Windows OS?

有没有办法将 USB HID 使用 ID 转换为 Windows OS 中的虚拟键代码?

例如,

HID Usage ID 0x04 ---> Virtual Key is 0x41 (this is key A)

HID 使用 ID 0x91 ---> 虚拟键为 0xE9(这是 OEM 特定键)

HID Usage ID 0x87 ---> Virtual Key is 0xC1 (this is a Reserved key code)

...

我刚找到一个 virtual keys code table, 但我找不到翻译 table 或有效翻译它的方法。

没有 API 可以在 HID 使用 ID 和虚拟键码之间进行转换。翻译由设备驱动程序执行。

键盘的使用 ID 发布在 http://usb.org in the HID Usage Tables 规范中(第 10 章“Keyboard/Keypad 页 (0x07)”)。