Nar*_*yan 6 c embedded usb hid embedded-linux
我需要找出符合 HID 标准的触摸屏(单点触摸)输入数据结构(例如字节顺序以及每个字节中应写入的内容)。
我使用了 Microsoft 官方文档中的符合 HID 的触摸屏描述符
在使用设备管理器的主机 PC 中,我可以看到它成功枚举了 HID 兼容设备。现在我想将 HID 报告发送到主机,但问题是我还没有找到类似触摸屏的 HID 启动协议之类的东西(对于鼠标和键盘,它在 USB 组织规范中明确定义)。这是我用来创建触摸屏 HID 报告的代码示例,它可以工作,但不符合预期。我通过研究大量 github 代码和阅读文章找到了这种字节组合,但我想找到一些文档来证明顺序是正确的。
char report[8] = {0};
uint16_t x_access = 10000;
uint16_t y_access = 10000;
report[0] = 0x01; //reportid
report[1] = 0x3; //statuss
report[2] = LOWBYTE(x_access); //x low byte
report[3] = HIGHBYTE(x_access); //x high byte
report[4] = LOWBYTE(y_access); //y low byte
report[5] = HIGHBYTE(y_access); //y high byte
report[6] = 0x65; //touch parsing time low byte
report[7] = 0x00; //touch parsing time high byte
//report[8] = 1 //this doesn't have any impact (touch count)
Run Code Online (Sandbox Code Playgroud)
我使用过的有用链接
先谢谢您的帮助
与RDD!HID 报告描述符解码器工具我们可以轻松地从Microsoft 提供的触摸屏“示例报告描述符”生成 C 结构:
\n//--------------------------------------------------------------------------------\n// Digitizer Device Page inputReport 01 (Device --> Host)\n//--------------------------------------------------------------------------------\n\ntypedef struct\n{\n uint8_t reportId; // Report ID = 0x01 (1)\n // Collection: CA:TouchScreen CL:Finger\n uint8_t DIG_TouchScreenFingerTipSwitch : 1; // Usage 0x000D0042: Tip Switch, Value = 0 to 1\n uint8_t : 7; // Pad\n uint8_t DIG_TouchScreenFingerContactIdentifier; // Usage 0x000D0051: Contact Identifier, Value = 0 to 1\n uint16_t GD_TouchScreenFingerX[2]; // Usage 0x00010030: X, Value = 0 to 4095, Physical = Value x 241 / 819 in 10\xe2\x81\xbb\xc2\xb2 inch units\n uint16_t GD_TouchScreenFingerY[2]; // Usage 0x00010031: Y, Value = 0 to 4095, Physical = Value x 302 / 1365 in 10\xe2\x81\xbb\xc2\xb2 inch units\n uint16_t DIG_TouchScreenFingerWidth; // Usage 0x000D0048: Width, Value = 0 to 4095, Physical = Value x 302 / 1365 in 10\xe2\x81\xbb\xc2\xb2 inch units\n uint16_t DIG_TouchScreenFingerHeight; // Usage 0x000D0049: Height, Value = 0 to 4095, Physical = Value x 302 / 1365 in 10\xe2\x81\xbb\xc2\xb2 inch units\n uint16_t DIG_TouchScreenFingerAzimuth; // Usage 0x000D003F: Azimuth, Value = 0 to 62831, Physical = Value in 10\xe2\x81\xbb\xe2\x81\xb4 rad units\n uint8_t DIG_TouchScreenFingerTipSwitch_1 : 1; // Usage 0x000D0042: Tip Switch, Value = 0 to 1, Physical = Value x 62831 in 10\xe2\x81\xbb\xe2\x81\xb4 rad units\n uint8_t : 7; // Pad\n uint8_t DIG_TouchScreenFingerContactIdentifier_1; // Usage 0x000D0051: Contact Identifier, Value = 0 to 1, Physical = Value x 62831 in 10\xe2\x81\xbb\xe2\x81\xb4 rad units\n uint16_t GD_TouchScreenFingerX_1[2]; // Usage 0x00010030: X, Value = 0 to 4095, Physical = Value x 241 / 819 in 10\xe2\x81\xbb\xc2\xb2 inch units\n uint16_t GD_TouchScreenFingerY_1[2]; // Usage 0x00010031: Y, Value = 0 to 4095, Physical = Value x 302 / 1365 in 10\xe2\x81\xbb\xc2\xb2 inch units\n uint16_t DIG_TouchScreenFingerWidth_1; // Usage 0x000D0048: Width, Value = 0 to 4095, Physical = Value x 302 / 1365 in 10\xe2\x81\xbb\xc2\xb2 inch units\n uint16_t DIG_TouchScreenFingerHeight_1; // Usage 0x000D0049: Height, Value = 0 to 4095, Physical = Value x 302 / 1365 in 10\xe2\x81\xbb\xc2\xb2 inch units\n uint16_t DIG_TouchScreenFingerAzimuth_1; // Usage 0x000D003F: Azimuth, Value = 0 to 62831, Physical = Value in 10\xe2\x81\xbb\xe2\x81\xb4 rad units\n // Collection: CA:TouchScreen\n uint16_t DIG_TouchScreenRelativeScanTime; // Usage 0x000D0056: Relative Scan Time, Value = 0 to 65535, Physical = Value in 10\xe2\x81\xbb\xe2\x81\xb4 s units\n uint8_t DIG_TouchScreenContactCount; // Usage 0x000D0054: Contact Count, Value = 0 to 127, Physical = Value x 65535 / 127 in 10\xe2\x81\xbb\xe2\x81\xb4 s units\n} inputReport01_t;\nRun Code Online (Sandbox Code Playgroud)\n