【问题标题】:HID-compliant touch screen packet data structure符合 HID 标准的触摸屏数据包数据结构
【发布时间】:2021-12-18 18:42:01
【问题描述】:

我需要找出符合 HID 的触摸屏(单点触控)输入数据结构(如字节顺序以及每个字节应写入的内容)。

我使用了来自 Microsoft 官方 docs 的符合 HID 标准的触摸屏描述符

在使用设备管理器的主机 PC 中,我可以看到它成功枚举了符合 HID 的设备。现在我想向主机发送 HID 报告,但问题是我还没有找到类似用于触摸屏的 HID 启动协议(对于鼠标和键盘,它在 USB org 规范中明确定义)。 这是我用来创建触摸屏 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)

我使用过的有用链接

  1. https://www.usb.org/hid
  2. http://ww1.microchip.com/downloads/en/DeviceDoc/mXT1386E_2v9_Datasheet_BX.pdf
  3. https://www.interelectronix.com/de/sis95xx-series-touch-data-format.html
  4. http://ww1.microchip.com/downloads/en/devicedoc/41606b.pdf

提前感谢您的帮助

【问题讨论】:

  • IIRC,报告的结构完全取决于您提供的报告描述符。我建议阅读 HID 规范,第 8 节和第 6.2.2 节。您可能还想添加有关您正在使用的报告描述符的信息。另外,如果我理解正确引导协议不相关(仅针对鼠标或键盘定义,对于无法解析 HID 报告描述符的更简单实现,除非您想模拟鼠标)。

标签: c embedded usb embedded-linux hid


【解决方案1】:

使用RDD! HID Report Descriptor Decoder 工具,我们可以轻松地从Microsoft provided touchscreen "Sample Report Descriptor" 生成C 结构:

//--------------------------------------------------------------------------------
// Digitizer Device Page inputReport 01 (Device --> Host)
//--------------------------------------------------------------------------------

typedef struct
{
  uint8_t  reportId;                                 // Report ID = 0x01 (1)
                                                     // Collection: CA:TouchScreen CL:Finger
  uint8_t  DIG_TouchScreenFingerTipSwitch : 1;       // Usage 0x000D0042: Tip Switch, Value = 0 to 1
  uint8_t  : 7;                                      // Pad
  uint8_t  DIG_TouchScreenFingerContactIdentifier;   // Usage 0x000D0051: Contact Identifier, Value = 0 to 1
  uint16_t GD_TouchScreenFingerX[2];                 // Usage 0x00010030: X, Value = 0 to 4095, Physical = Value x 241 / 819 in 10⁻² inch units
  uint16_t GD_TouchScreenFingerY[2];                 // Usage 0x00010031: Y, Value = 0 to 4095, Physical = Value x 302 / 1365 in 10⁻² inch units
  uint16_t DIG_TouchScreenFingerWidth;               // Usage 0x000D0048: Width, Value = 0 to 4095, Physical = Value x 302 / 1365 in 10⁻² inch units
  uint16_t DIG_TouchScreenFingerHeight;              // Usage 0x000D0049: Height, Value = 0 to 4095, Physical = Value x 302 / 1365 in 10⁻² inch units
  uint16_t DIG_TouchScreenFingerAzimuth;             // Usage 0x000D003F: Azimuth, Value = 0 to 62831, Physical = Value in 10⁻⁴ rad units
  uint8_t  DIG_TouchScreenFingerTipSwitch_1 : 1;     // Usage 0x000D0042: Tip Switch, Value = 0 to 1, Physical = Value x 62831 in 10⁻⁴ rad units
  uint8_t  : 7;                                      // Pad
  uint8_t  DIG_TouchScreenFingerContactIdentifier_1; // Usage 0x000D0051: Contact Identifier, Value = 0 to 1, Physical = Value x 62831 in 10⁻⁴ rad units
  uint16_t GD_TouchScreenFingerX_1[2];               // Usage 0x00010030: X, Value = 0 to 4095, Physical = Value x 241 / 819 in 10⁻² inch units
  uint16_t GD_TouchScreenFingerY_1[2];               // Usage 0x00010031: Y, Value = 0 to 4095, Physical = Value x 302 / 1365 in 10⁻² inch units
  uint16_t DIG_TouchScreenFingerWidth_1;             // Usage 0x000D0048: Width, Value = 0 to 4095, Physical = Value x 302 / 1365 in 10⁻² inch units
  uint16_t DIG_TouchScreenFingerHeight_1;            // Usage 0x000D0049: Height, Value = 0 to 4095, Physical = Value x 302 / 1365 in 10⁻² inch units
  uint16_t DIG_TouchScreenFingerAzimuth_1;           // Usage 0x000D003F: Azimuth, Value = 0 to 62831, Physical = Value in 10⁻⁴ rad units
                                                     // Collection: CA:TouchScreen
  uint16_t DIG_TouchScreenRelativeScanTime;          // Usage 0x000D0056: Relative Scan Time, Value = 0 to 65535, Physical = Value in 10⁻⁴ s units
  uint8_t  DIG_TouchScreenContactCount;              // Usage 0x000D0054: Contact Count, Value = 0 to 127, Physical = Value x 65535 / 127 in 10⁻⁴ s units
} inputReport01_t;

【讨论】:

    猜你喜欢
    • 2012-11-08
    • 2018-12-13
    • 1970-01-01
    • 2012-06-07
    • 1970-01-01
    • 2010-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多