Code:
static uchar reportBuffer[10]; // buffer for HID output reports
PROGMEM char usbHidReportDescriptor[USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH] = { // USB report descriptor
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x04, // USAGE (Joystick)
0xa1, 0x01, // COLLECTION (Application)
0xa1, 0x02, // Collection (Logical)
0x85, 0x01, //report id 1
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x01, // REPORT_COUNT (1)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
0x81, 0x03, // Input (Constant, Variable, Absolute, No Wrap, Linear, Preferred State, No Null Position, Bitfield)
0x75, 0x01, // report size 1
0x95, 0x13, // report count 19
0x15, 0x00, //log min 0
0x25, 0x01, //log max 1
0x35, 0x00, //phy min 0
0x45, 0x01, //phy max 1
0x05, 0x09, //usage page button
0x19, 0x01, //usage min 1
0x29, 0x13, // usage max 19
0x81, 0x02, // Input (Data, Variable, Absolute, No Wrap, Linear, Preferred State, No Null Position, Bitfield)
0x75,0x01, // Report Size............. (1)
0x95,0x0d, // Report Count............ (13)
0x06,0x00, 0xff,// Usage Page (Vendor defined 0)
0x81,0x03, // Input................... (Constant, Variable, Absolute, No Wrap, Linear, Preferred State, No Null Position, Bitfield)
0x15,0x00, // Logical Minimum......... (0)
0x26,0xff,0x00, // Logical Maximum......... (255)
0x05,0x01, // Usage Page (Generic Desktop)
0x09,0x01, // Usage (Pointer)
0xa1,0x00, // Collection (Physical)
0x75,0x08, // Report Size............. (8)
0x95,0x04, // Report Count............ (4)
0x35,0x00, // Physical Minimum........ (0)
0x46, 0xff, 0x00, // Physical Maximum........ (255)
0x09,0x30, // Usage (X)
0x09,0x31,// Usage (Y)
0x09,0x32,// Usage (Z)
0x09,0x35,// Usage (Rz)
0x81,0x02,// Input................... (Data, Variable, Absolute, No Wrap, Linear, Preferred State, No Null Position, Bitfield)
0xc0, // End Collection
// 0x05,0x01,// Usage Page (Generic Desktop)
// 0x75,0x08, // Report Size............. (8)
// 0x95,0x27,// Report Count............ (39)
// 0x09,0x01, // Usage (Pointer)
// 0x81,0x02,// Input................... (Data, Variable, Absolute, No Wrap, Linear, Preferred State, No Null Position, Bitfield)
// 0x75,0x08,// Report Size............. (8)
// 0x95,0x30,// Report Count............ (48)
// 0x09,0x01,// Usage (Pointer)
// 0x91,0x02,// Output.................. (Data, Variable, Absolute, No Wrap, Linear, Preferred State, No Null Position, Nonvolatile, Bitfield)
// 0x75,0x08,// Report Size............. (8)
// 0x95,0x30,// Report Count............ (48)
// 0x09,0x01,// Usage (Pointer)
// 0xb1,0x02,// Feature................. (Data, Variable, Absolute, No Wrap, Linear, Preferred State, No Null Position, Nonvolatile, Bitfield)
0xc0,// End Collection
// 0xa1,0x02,// Collection (Logical)
// 0x85,0x02,// ReportID................ (2)
// 0x75,0x08,// Report Size............. (8)
// 0x95,0x30,// Report Count............ (48)
// 0x09,0x01,// Usage (Pointer)
// 0xb1,0x02,// Feature................. (Data, Variable, Absolute, No Wrap, Linear, Preferred State, No Null Position, Nonvolatile, Bitfield)
// 0xc0,// End Collection
// 0xa1,0x02,// Collection (Logical)
// 0x85,0xee,// ReportID................ (238)
// 0x75,0x08,// Report Size............. (8)
// 0x95,0x30,// Report Count............ (48)
// 0x09,0x01,// Usage (Pointer)
// 0xb1,0x02,// Feature................. (Data, Variable, Absolute, No Wrap, Linear, Preferred State, No Null Position, Nonvolatile, Bitfield)
// 0xc0,// End Collection
// 0xa1,0x02,// Collection (Logical)
// 0x85,0xef,// ReportID................ (239)
// 0x75,0x08,// Report Size............. (8)
// 0x95,0x30,// Report Count............ (48)
// 0x09,0x01,// Usage (Pointer)
// 0xb1,0x02,// Feature................. (Data, Variable, Absolute, No Wrap, Linear, Preferred State, No Null Position, Nonvolatile, Bitfield)
// 0xc0,// End Collection
0xc0,// End Collection
};
I have commented out the pieces which I currently do not use. This is because the device is recognized only if the size implied by the descriptor equals the size of the buffer. Now, this descriptor/buffer's size is 10 bytes, thus the polling cycle becomes: