Can't get HID Report Description to work for mouse wheel only
I'm trying to teach myself USB HID with an STM32. Right now I'm stuck trying to get a custom Report Description to work.
Here's what's working right now:
Report Description:
0x05, 0x01, // Usage Page (Generic Desktop Ctrls)
0x09, 0x02, // Usage (Mouse)
0xA1, 0x01, // Collection (Application)
0x09, 0x01, // Usage (Pointer)
0xA1, 0x00, // Collection (Physical)
0x05, 0x01, // Usage Page (Generic Desktop Ctrls)
0x09, 0x30, // Usage (X)
0x09, 0x31, // Usage (Y)
0x09, 0x38, // Usage (Wheel)
0x15, 0x81, // Logical Minimum (-127)
0x25, 0x7F, // Logical Maximum (127)
0x75, 0x08, // Report Size (8)
0x95, 0x03, // Report Count (3)
0x81, 0x06, // Input (Data,Var,Rel,No Wrap,Linear,Preferred State,No Null Position)
0xC0, // End Collection
0xC0, // End CollectionReport Description size:
#define USBD_CUSTOM_HID_REPORT_DESC_SIZE 0x1Estruct declared in main.c
struct mouseHID_t {
int8_t x;
int8_t y;
int8_t wheel;
};
struct mouseHID_t mouseHID;code in while loop:
while (1)
{
if (HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_9) == 0)
{
mouseHID.wheel = 1;
USBD_CUSTOM_HID_SendReport(&hUsbDeviceFS, &mouseHID, sizeof(struct mouseHID_t));
mouseHID.wheel = 0;
}
}When I push a button on my board it will scroll the mouse wheel up. If I change the report description to remove the x & y usage, change the description size to say 0x1A (26) and change the mouseHID struct to remove the x & y, the board no longer scrolls the mouse wheel.
The furthest I've been able to run it down to is in "USBD_CUSTOM_HID_SendReport" the statement "if (hhid->state == CUSTOM_HID_IDLE)" never equals true as the hhid->state == CUSTOM_HID_BUSY.
Changes I make so anyone can check my work:
0x05, 0x01, // Usage Page (Generic Desktop Ctrls)
0x09, 0x02, // Usage (Mouse)
0xA1, 0x01, // Collection (Application)
0x09, 0x01, // Usage (Pointer)
0xA1, 0x00, // Collection (Physical)
0x05, 0x01, // Usage Page (Generic Desktop Ctrls)
0x09, 0x38, // Usage (Wheel)
0x15, 0x81, // Logical Minimum (-127)
0x25, 0x7F, // Logical Maximum (127)
0x75, 0x08, // Report Size (8)
0x95, 0x01, // Report Count (1)
0x81, 0x06, // Input (Data,Var,Rel,No Wrap,Linear,Preferred State,No Null Position)
0xC0, // End Collection
0xC0, // End Collection
#define USBD_CUSTOM_HID_REPORT_DESC_SIZE 0x1A