【发布时间】:2022-10-15 15:17:56
【问题描述】:
我目前有这个 HID 报告描述符:
static
unsigned char hid_report_descriptor[] __attribute__ ((aligned(64))) = {
0x05, 0x01, // Usage Page (Generic Desktop Ctrls)
0x09, 0x05, // Usage (Game Pad)
0xA1, 0x01, // Collection (Application)
0xA1, 0x00, // Collection (Physical)
0x85, 0x01, // Report ID (1)
0x05, 0x09, // Usage Page (Button)
0x19, 0x01, // Usage Minimum (0x01)
0x29, 0x10, // Usage Maximum (0x10)
0x15, 0x00, // Logical Minimum (0)
0x25, 0x01, // Logical Maximum (1)
0x95, 0x10, // Report Count (16)
0x75, 0x01, // Report Size (1)
0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
0x05, 0x01, // Usage Page (Generic Desktop Ctrls)
0x09, 0x30, // Usage (X)
0x09, 0x31, // Usage (Y)
0x09, 0x32, // Usage (Z)
0x09, 0x33, // Usage (Rx)
0x15, 0x81, // Logical Minimum (-127)
0x25, 0x7F, // Logical Maximum (127)
0x75, 0x08, // Report Size (8)
0x95, 0x04, // Report Count (4)
0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
0xC0, // End Collection
0xC0, // End Collection
};
它对应于这个结构。
struct GamepadReport {
uint8_t report_id;
uint16_t buttons;
int8_t left_x;
int8_t left_y;
int8_t right_x;
int8_t right_y;
} __attribute__((packed));
我正在尝试添加对一个额外的按钮它应该用作“主页”按钮(想想 Xbox 控制器上的 X)。理论上,这应该通过将包含0x29, 0x10 和0x95, 0x10 的行分别更改为0x29, 0x11 和0x95, 0x11 来完成。但是,这样做会中断与自定义控制器的连接。
我一生都无法弄清楚为什么会这样,这对我来说绝对是零意义。对 HID 描述符有更多经验或知识的人可以帮帮我吗?
【问题讨论】:
-
定义“断开连接”?
-
您的报表布局有 16 位来保存按钮。第17个按钮应该去哪里?
-
是的,很确定
uint16_t buttons;为您提供 16 位而不是 17 位。 -
也许您可以为按钮添加第二个使用页面?
-
@user253751 当我让 HID 描述符保持 17 个按钮时,控制器会在连接后立即断开连接。