HID Gamepad Report Descriptor Issue

2.1k views Asked by At

I am working on an adapter that takes two libraries and converts transmitter/controller input into HID input (through PPM, but I don't think that will matter for this post). I am using Arduino, but posting here because unless I am misunderstanding, my issue is in the HID Report Descriptor, not my Arduino code.

I have a sample descriptor, that works if I use it, the working one is this:

PROGMEM const char usbHidReportDescriptor[36] = {
0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
0x09, 0x05,                    // USAGE (Game Pad)
0xa1, 0x01,                    // COLLECTION (Application)
0xa1, 0x00,                    //   COLLECTION (Physical)
0x05, 0x01,                    //     USAGE_PAGE (Generic Desktop)
0x09, 0x30,                    //     USAGE (X)
0x09, 0x31,                    //     USAGE (Y)
0x09, 0x32,                    //     USAGE (Z) rx
0x09, 0x35,                    //     USAGE (Rx) ry
0x35, 0x00,                    //     PHYSICAL_MINIMUM (0)
0x46, 0xff, 0x00,              //     PHYSICAL_MAXIMUM (255)
0x15, 0x00,                    //     LOGICAL_MINIMUM (-127)
0x26, 0xff, 0x00,                    //     LOGICAL_MAXIMUM (127)
0x75, 0x08,                    //     REPORT_SIZE (8)
0x95, 0x04,                    //     REPORT_COUNT (4)
0x81, 0x02,                    //     INPUT (Data,Var,Abs)
0xc0,                          //   END_COLLECTION
0xc0                           // END_COLLECTION
};

The first sample only has the sticks, no buttons so I tried to create a descriptor that has buttons. The profile I generated with the HID Descriptor Tool is this:

 PROGMEM const char usbHidReportDescriptor[46] = {
  0x05, 0x01,                   //USAGE_PAGE (Generic Desktop)
  0x09, 0x05,                   //USAGE (Game Pad)
  0xa1, 0x01,                   //COLLECTION (APPLICATION)
  0xa1, 0x00,                    //   COLLECTION (Physical)
  0x05, 0x09,                   //USAGE_PAGE (Button)
  0x19, 0x01,                   //USAGE_MINIMUM (Button1)
  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, 0x81,                   //LOGICAL_MINIMUM(-127)
  0x25, 0x7f,                   //LOGICAL_MAXIMUM(127)
  0x75, 0x08,                   //REPORT_SIZE(8)
  0x95, 0x04,                   //REPORT_COUNT(4)
  0x81, 0x02,                   //INPUT(Data,Var,Abs)
  0xc0,                     //END_Collection
  0xc0                      //END_Collection


};

When I compile it, I do not get errors, but after uploading to the device I get the "This device cannot start. (Code 10)" message in the device profile. This is currently the only thing I'm changing in testing that causes this issue.

If you still feel this would be better asked in the Arduino section I can post there, but I think this is more something I'm doing wrong with the descriptor.

I really appreciate anyone's time and assistance! Please let me know if there is more information that would be helpful to post.

1

There are 1 answers

0
Kyle B On

Got the issue sorted out after having a simple realization. Just did a find in files of: usbHidReportDescriptor and found that there was a definition for length in the usbconfig.h file that I needed to adjust. Just posting this in case anyone has the same issue down the line!