char REPORT_MOUSE[52] = {
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x02, // Usage (Mouse)
0xA1, 0x01, // Collection (Application)
0x09, 0x01, // Usage (Pointer)
0xA1, 0x00, // Collection (Physical)
// -- 4 Buttons, 3 empty
0x05, 0x09, // Usage Page (Buttons)
0x19, 0x01, // Usage Minimum (01)
0x29, 0x01, // Usage Maximum (01)
0x15, 0x00, // Logical Minimum (0)
0x25, 0x01, // Logical Maximum (1)
0x95, 0x05, // Report Count (5)
0x75, 0x01, // Report Size (1)
0x81, 0x02, // Input (Data, Variable, Absolute)
0x95, 0x01, // Report Count (1)
0x75, 0x03, // Report Size (3)
0x81, 0x01, // Input (Constant) for padding
// -- X/Y Axis + Scroll Wheel
0x05, 0x01, // Usage Page (Generic Desktop)
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, Variable, Relative)
0xC0, // End Collection (Physical)
0xC0 // End Collection (Application)
};
// TODO: add 4 joystick buttons
char REPORT_JOYSTICK[38] = {
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x04, // Usage (Joystick)
0xA1, 0x01, // Collection (Application)
0x09, 0x01, // Usage (Pointer)
0xA1, 0x00, // Collection (Physical)
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x30, // Usage (X)
0x09, 0x31, // Usage (Y)
0x09, 0x32, // Usage (Z)
0x15, 0x81, // Logical Minimum (-127)
0x25, 0x7F, // Logical Maximum (127)
0x75, 0x08, // Report Size (8)
0x95, 0x03, // Report Count (3)
0x81, 0x06, // Input (Data, Variable, Relative)
0xC0, // End Collection (Physical)
0x05, 0x02, // Usage Page (Simulation Controls)
0x95, 0x01, // Report Count (1)
0x09, 0xBB, // Usage (Throttle)
0x81, 0x06, // Input (Data, Variable, Relative)
0xC0 // End Collection (Application)
};
char HIDCONFIGDESC[] = {
// configuration_descriptor hid_configuration_descriptor
sizeof(configuration_descriptor), // Length
0x02, // Type
LE(sizeof(hid_configuration_descriptor)),// Totallength (= 9+9+9+7)
0x02, // NumInterfaces
0x01, // bConfigurationValue
0x00, // iConfiguration
0x80, // bmAttributes
0x20, // MaxPower (in 2mA units)
// interface_descriptor hid_interface_descriptor
sizeof(interface_descriptor), // bLength
0x04, // bDescriptorType
0x00, // bInterfaceNumber
0x00, // bAlternateSetting
0x01, // bNumEndpoints
0x03, // bInterfaceClass (3 = HID)
0x01, // bInterfaceSubClass
0x02, // bInterfaceProcotol
0x00, // iInterface
// class_descriptor hid_descriptor
sizeof(class_descriptor), // bLength
0x21, // bDescriptorType
0x0101, // bcdHID
0x00, // bCountryCode
0x01, // bNumDescriptors
0x22, // bDescriptorType
LE(sizeof(REPORT_MOUSE)), // wItemLength
// endpoint_descriptor hid_endpoint_in_descriptor
sizeof(endpoint_descriptor), // bLength
0x05, // bDescriptorType
0x81, // bEndpointAddress
0x03, // bmAttributes
LE(EP1_PACKET_SIZE), // MaxPacketSize (LITTLE ENDIAN)
10, // bInterval
// interface_descriptor hid_interface_descriptor
sizeof(interface_descriptor), // bLength
0x04, // bDescriptorType
0x01, // bInterfaceNumber
0x00, // bAlternateSetting
0x01, // bNumEndpoints
0x03, // bInterfaceClass (3 = HID)
0x01, // bInterfaceSubClass
0x02, // bInterfaceProcotol
0x00, // iInterface
// class_descriptor hid_descriptor
sizeof(class_descriptor), // bLength
0x21, // bDescriptorType
0x0101, // bcdHID
0x00, // bCountryCode
0x01, // bNumDescriptors
0x22, // bDescriptorType
LE(sizeof(REPORT_JOYSTICK)), // wItemLength
// endpoint_descriptor hid_endpoint_in_descriptor
sizeof(endpoint_descriptor), // bLength
0x05, // bDescriptorType
0x82, // bEndpointAddress
0x03, // bmAttributes
LE(EP1_PACKET_SIZE), // MaxPacketSize (LITTLE ENDIAN)
10, // bInterval
}
Thankyou