Question
HID issue with multiple report id
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;
uint8_t id;
uint16_t buttons;
uint16_t x,y,z,rx;
}usbData;
struct keyboardData{
uint8_t reportId;
uint32_t keys;
}m_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));
