十六进制键盘扫描码列表和 USB HID 键盘文档 [英] List of hex keyboard scan codes and USB HID keyboard documentation

查看:37
本文介绍了十六进制键盘扫描码列表和 USB HID 键盘文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在哪里可以找到不同键盘布局的十六进制键盘扫描代码列表?

Where am I able to find a list of the hex keyboard scan codes for different keyboard layouts?

我使用 bash 命令 echo -ne 通过(假)USB HID 键盘发送键码,然后是转义的十六进制键扫描码和 HID 设备:

I'm sending the key codes over a (fake) USB HID keyboard with the bash command echo -ne followed by the escaped hex key scan code and the HID device:

echo -ne "x00x00x00x38x00x00x00x00" > /dev/hidg0
echo -ne "x00x00x00x00x00x00x00x00"  > /dev/hidg0

美式键盘布局上的斜线 (/).

for a slash (/) on the US keyboard layout.

在我的键盘布局 (CH) 上是

On my keyboard layout (CH) it is

echo -ne "x00x00x00x24x00x00x00x00" > /dev/hidg0
echo -ne "x00x00x00x00x00x00x00x00"  > /dev/hidg0

为斜线.所以我想所有这些都必须存在一个列表.然而,我能够找到 美国布局 的列表,但找不到任何其他键盘布局.

for a slash. So I guess there has to exist a list for all of these. Yet I was able to find a list for the US layout but not for any other keyboard layout.

我知道第二行会停止键入键,但我不太了解这些转义序列的语法.我知道如果我将第一个 x00 更改为 x02 它将移动"输入的键.但是为什么还有 6 个修饰符呢?它们代表 ctrl, alt, ... 吗?哪个代表哪个?

I know the second line stops the typing of the key but I don't quite understand the syntax of these escape sequences. I know that if I change the first x00 to a x02 it will "shift" the entered key. But why are there 6 more modifiers? Do they stand for ctrl, alt, ... ? And which stands for which?

这种语法的文档会很酷.我还没找到.

A documentation of this syntax would be really cool. I wasn't able to find one yet.

(我在 Nexus 7 2012 上使用 Kali Nethunter)

(I'm using Kali Nethunter on a Nexus 7 2012)

推荐答案

扫码"(它们实际上是使用代码的索引)发布在 usb.org 的 USB HID 使用第 10 章键盘/键盘页面 (0x07)"中的表格 规范.典型的键盘报告布局可在 HID 的 USB 设备类规范中找到 在附录 B引导接口描述符"的B.1 协议 1(键盘)"部分中.

The "scan codes" (they are really indexes to usage codes) are published on usb.org in the USB HID Usage Tables specification in Chapter 10 "Keyboard/Keypad Page (0x07)". A typical keyboard report layout can be found in the USB Device Class Specification for HID in Appendix B "Boot Interface Descriptors", section "B.1 Protocol 1 (Keyboard)".

将键盘报告格式描述为:

That describes the keyboard report format as:

Byte 0: Keyboard modifier bits (SHIFT, ALT, CTRL etc)
Byte 1: reserved
Byte 2-7: Up to six keyboard usage indexes representing the keys that are 
          currently "pressed". 
          Order is not important, a key is either pressed (present in the 
          buffer) or not pressed.

请注意,USB 规范并未定义键盘布局.它只是列出了分配给特定键功能的使用代码.字母a"例如使用代码 0x04.如果您想要一个大写的A",那么您还需要设置字节 0 修饰符位以选择左移".(或右移").

Note that the USB spec doesn't define keyboard layouts. It simply lists the usage codes assigned to particular key functions. The letter "a" is usage code 0x04 for example. If you want an uppercase "A", then you would also need to set the Byte 0 modifier bits to select "Left Shift" (or "Right Shift").

报告缓冲区的确切格式取决于将键盘插入 USB 端口时发送到主机的报告描述符,因此以上只是一个(非常典型的)示例.

The exact format of the report buffer depends on the Report Descriptor sent to the host computer when the keyboard was plugged in to a USB port, so the above is just a (pretty typical) example.

这篇关于十六进制键盘扫描码列表和 USB HID 键盘文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆