cancel
Showing results for 
Search instead for 
Did you mean: 

Can't get HID Report Description to work for mouse wheel only

MEvan.4
Associate

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 Collection

Report Description size:

#define USBD_CUSTOM_HID_REPORT_DESC_SIZE   0x1E

struct 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

1 ACCEPTED SOLUTION

Accepted Solutions
Lubos KOUDELKA
ST Employee

Hello,

I tried your configuration and also on my side it was not working with reduced report descriptor only to wheel. But on USB analyzer I haven't seen any issue, also in HID specification I haven't noticed any mention, that such configuration would not be valid. https://www.usb.org/sites/default/files/hid1_11.pdf

I can see on USB analyzer, that reports with wheel value are being send, just Windows system is not able to interpret them and also in device manager HID device has warning "cannot start".

When I tried with Linux PC, HID device worked as expected. So I see here more issue with acceptance on Windows (I use Windows 10 x64) side. As workaround you can use original configuration with x and y axes, which won't be used.

Best regards,

Lubos

View solution in original post

2 REPLIES 2
Lubos KOUDELKA
ST Employee

Hello,

I tried your configuration and also on my side it was not working with reduced report descriptor only to wheel. But on USB analyzer I haven't seen any issue, also in HID specification I haven't noticed any mention, that such configuration would not be valid. https://www.usb.org/sites/default/files/hid1_11.pdf

I can see on USB analyzer, that reports with wheel value are being send, just Windows system is not able to interpret them and also in device manager HID device has warning "cannot start".

When I tried with Linux PC, HID device worked as expected. So I see here more issue with acceptance on Windows (I use Windows 10 x64) side. As workaround you can use original configuration with x and y axes, which won't be used.

Best regards,

Lubos

Thanks a bunch! That confirms what I was thinking. It seemed like it would be with Windows.

Much appreciated!