Skip to main content
Visitor II
January 13, 2024
Question

HID issue with multiple report id

  • January 13, 2024
  • 2 replies
  • 3056 views

Hi Everyone,
I am currently using STM32F103 for making a usb hid which acts as both, a keyboard and a gamepad.

Please take a look at the descriptor and code below.

Both of these work properly when used individually but when I combine them both and add report ID no input is detected. In my main function I detect the key press and then assign the data in buttons and keys.

 

    0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
    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 (Button 1)
    0x29, 0x10,                    //     USAGE_MAXIMUM (Button 16)
    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)
    0x05, 0x01,                    //     USAGE_PAGE (Generic Desktop)
    0x09, 0x30,                    //     USAGE (X)
    0x09, 0x31,                    //     USAGE (Y)
    0x09, 0x32,                    //     USAGE (Z)
    0x09, 0x33,                    //     USAGE (Rx)
    0x15, 0x00,                    //     LOGICAL_MINIMUM (0)
    0x26, 0x00, 0x10,              //     LOGICAL_MAXIMUM (4096)
    0x75, 0x10,                    //     REPORT_SIZE (16)
    0x95, 0x04,                    //     REPORT_COUNT (4)
    0x81, 0x02,                    //     INPUT (Data,Var,Abs)
    0xc0,                          //   END_COLLECTION
    0xc0,                          // END_COLLECTION
    0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
    0x09, 0x06,                    // USAGE (Keyboard)
    0xa1, 0x01,                    // COLLECTION (Application)
    0x85, 0x02,                    //   REPORT_ID (2)
    0x05, 0x07,                    //   USAGE_PAGE (Keyboard)
    0x19, 0x04,                    //   USAGE_MINIMUM (Keyboard a and A)
    0x29, 0x1d,                    //   USAGE_MAXIMUM (Keyboard z and Z)
    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
    0x25, 0x01,                    //   LOGICAL_MAXIMUM (1)
    0x75, 0x01,                    //   REPORT_SIZE (1)
    0x95, 0x20,                    //   REPORT_COUNT (32)
    0x81, 0x02,                    //   INPUT (Data,Var,Abs)
    0xc0                           // END_COLLECTION
struct gamepadInfo{
uint8_t id;
uint16_t buttons;
uint16_t x,y,z,rx;
}usbData;
 
struct keyboardData{
uint8_t reportId;
uint32_t keys;
}m_keyboardData;
 
//In main function
usbData.id = 1;
m_keyboardData.reportId = 2;
USBD_CUSTOM_HID_SendReport(&hUsbDeviceFS, &usbData, sizeof(usbData));
USBD_CUSTOM_HID_SendReport(&hUsbDeviceFS, &m_keyboardData, sizeof(m_keyboardData));
    This topic has been closed for replies.

    2 replies

    Super User
    January 13, 2024

    This should work if done properly.  There are online tools to display and validate HID report descriptors, try these. Try also chatgpt & Co. They boast so much recently, take them to a challenge ))

     

    aksh3101Author
    Visitor II
    January 14, 2024

    Thanks for the reply Pavel.

    I tried searching for HID validators online but could not find any.

    If you know any or have their links can you please share them with me?

    Also tried chatgpt but it didn't help.

    Super User
    January 14, 2024

    Let me google this for you ))

    https://eleccelerator.com/usbdescreqparser/

    https://www.usb.org/document-library/hid-descriptor-tool

    Now, the AI. Let's take the new free Windows Copilot:

    Me: - Dear Copilot, I want to ask how to find online parser or USB HID report descriptor but do not know how to ask. Please generate me a prompt.

    Copilot

    "A possible prompt for your question is:

    How can I use an online tool to parse the binary data of a USB HID report descriptor and convert it into a human-readable format?

    You can also try searching the web for some keywords related to your topic, such as “USB HID report descriptor parser” or “USB HID report descriptor tool”. I found some relevant results for you: