USB鼠标实现——HID 报告的返回(八)

HID 报告的返回

仓库地址

仓库地址

USB 鼠标阅读顺序

报告返回

根据 HID 报告描述符 中设置的报告,返回 5 字节数据

typedef struct __attribute__ ((packed))
{
    
    
    uint8_t buttons; /**< buttons mask for currently pressed buttons in the mouse. */
    int8_t  x;       /**< Current delta x movement of the mouse. */
    int8_t  y;       /**< Current delta y movement on the mouse. */
    int8_t  wheel;   /**< Current delta wheel movement on the mouse. */
    int8_t  pan;     // using AC Pan
} hid_mouse_report_t;

USB 端点数据分析

0x0 0x5 0x5 0x0 0x0
  • buttons:0x00
    • 鼠标左键是否按下 0 表示没有按下
  • x:0x05
    • x 轴移动量
  • y:0x05
    • y 轴移动量
  • whell:0x00
    • 滚轮移动量
  • pan:0x00
    • AC pan

配置描述符集合 中设置的端点地址为 0x81 ,bit7 位表示数据方向,输入端点 D7 为 1。所以输入端点 1 的地址为 0x81。

将上述报告通过端点返回即可。

猜你喜欢

转载自blog.csdn.net/tyustli/article/details/129782939