Page 1 of 1

Report Defn

Posted: Thu Jan 08, 2009 12:53 am
by Drools
The following is a working Report Definition for a 2-Axis 1-btn joystick, provided by ZX_USBJoy.

<code>
PROGMEM char usbHidReportDescriptor[USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH] =
{
//ZX-Joystick-1
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x04, // USAGE (Joystick)
0xa1, 0x01, // COLLECTION (Application)
0x09, 0x01, // USAGE (Pointer)
0xa1, 0x00, // COLLECTION (Physical)
0x85, 0x01, // REPORT_ID (1)
0x09, 0x30, // USAGE (X)
0x09, 0x31, // USAGE (Y)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x02, // LOGICAL_MAXIMUM (2)
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x02, // REPORT_COUNT (2)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x95, 0x01, // REPORT_COUNT (1)
0x75, 0x01, // REPORT_SIZE (1)
0x05, 0x09, // USAGE_PAGE (Button)
0x19, 0x01, // USAGE_MINIMUM (Button 1)
0x29, 0x01, // USAGE_MAXIMUM (Button 1)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x95, 0x07, // REPORT_COUNT (7)
0x75, 0x01, // REPORT_SIZE (1)
0x81, 0x01, // INPUT (Constant) - 7 bits are empty
0xc0, // END_COLLECTION
0xc0, // END_COLLECTION
};
</code>
I was hoping someone could show me how to modify it to include 6 more buttons. I’m very new to AVRs in general and AVR-USB as well.
Any help would be appreciated.


[code][/code]

Posted: Thu Jan 08, 2009 2:12 am
by Drools
I have learned one thing, originally I thought the indentations were just formatting error when I copied the code into a new project however now I think that was a mistake.
Here is the original with formatting intact.

Code: Select all

//HID Report Descriptor
PROGMEM char usbHidReportDescriptor[USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH] =
{ //ZX-Joystick-1
  0x05, 0x01, // USAGE_PAGE (Generic Desktop)
  0x09, 0x04, // USAGE (Joystick)
  0xa1, 0x01, // COLLECTION (Application)
  0x09, 0x01, //       USAGE (Pointer)
  0xa1, 0x00, //      COLLECTION (Physical)
  0x85, 0x01, //           REPORT_ID (1)
  0x09, 0x30, //           USAGE (X)
  0x09, 0x31, //           USAGE (Y)
  0x15, 0x00, //           LOGICAL_MINIMUM (0)
  0x25, 0x02, //           LOGICAL_MAXIMUM (2)
  0x75, 0x08, //           REPORT_SIZE (8)
  0x95, 0x02, //           REPORT_COUNT (2)
  0x81, 0x02, //           INPUT (Data,Var,Abs)
  0x15, 0x00, //           LOGICAL_MINIMUM (0)
  0x25, 0x01, //           LOGICAL_MAXIMUM (1)
  0x95, 0x01, //           REPORT_COUNT (1)
  0x75, 0x01, //           REPORT_SIZE (1)
  0x05, 0x09, //           USAGE_PAGE (Button)
  0x19, 0x01, //           USAGE_MINIMUM (Button 1)
  0x29, 0x01, //           USAGE_MAXIMUM (Button 1)
  0x81, 0x02, //           INPUT (Data,Var,Abs)
  0x95, 0x07, //           REPORT_COUNT (7)
  0x75, 0x01, //           REPORT_SIZE (1)
  0x81, 0x01, //           INPUT (Constant) - 7 bits are empty   
  0xc0,       //      END_COLLECTION
  0xc0,       // END_COLLECTION
};

The size of this discriptor is 50, now I think the area I need to focus on is USAGE_PAGE (Button). I have not found a document that describes the Descriptor Line for Line.

Posted: Thu Jan 08, 2009 4:55 am
by Drools
How do I calculate the size of the report descriptor?

Posted: Fri Jan 09, 2009 2:16 am
by Grendel
Drools wrote:I was hoping someone could show me how to modify it to include 6 more buttons.

Code: Select all

//HID Report Descriptor
PROGMEM char usbHidReportDescriptor[USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH] =
{ //ZX-Joystick-1
  0x05, 0x01, // USAGE_PAGE (Generic Desktop)
  0x09, 0x04, // USAGE (Joystick)
  0xa1, 0x01, // COLLECTION (Application)
  0x09, 0x01, //       USAGE (Pointer)
  0xa1, 0x00, //      COLLECTION (Physical)
  0x85, 0x01, //           REPORT_ID (1)
  0x09, 0x30, //           USAGE (X)
  0x09, 0x31, //           USAGE (Y)
  0x15, 0x00, //           LOGICAL_MINIMUM (0)
  0x25, 0x02, //           LOGICAL_MAXIMUM (2)
  0x75, 0x08, //           REPORT_SIZE (8)
  0x95, 0x02, //           REPORT_COUNT (2)
  0x81, 0x02, //           INPUT (Data,Var,Abs)
  0x15, 0x00, //           LOGICAL_MINIMUM (0)
  0x25, 0x01, //           LOGICAL_MAXIMUM (1)
  0x95, 0x07, //           REPORT_COUNT (7)
  0x75, 0x01, //           REPORT_SIZE (1)
  0x05, 0x09, //           USAGE_PAGE (Button)
  0x19, 0x01, //           USAGE_MINIMUM (Button 1)
  0x29, 0x07, //           USAGE_MAXIMUM (Button 7)
  0x81, 0x02, //           INPUT (Data,Var,Abs)
  0x95, 0x01, //           REPORT_COUNT (1)
  0x75, 0x01, //           REPORT_SIZE (1)
  0x81, 0x01, //           INPUT (Constant) - 1 bit is empty   
  0xc0,       //      END_COLLECTION
  0xc0,       // END_COLLECTION
};


Drools wrote:How do I calculate the size of the report descriptor?

Count the bytes. Or did you mean the size of the report ?

This thread may be interesting to you.