HID Gamepad Report Descriptor issue

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
kbishop

HID Gamepad Report Descriptor issue

Postby kbishop » Tue Dec 13, 2016 10:09 pm

I am working on a usbHidReportDescriptor and am having an issue with adding buttons to the report.

When I use this descriptor that I did not make (only stick axis, no buttons):

Code: Select all

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
};


My device gets recognized just fine and works how I hope, minus the buttons. I created a custom report to add buttons, and this is what I have:

Code: Select all

PROGMEM const char usbHidReportDescriptor[46] = {
  0x05, 0x01,               //USAGE_PAGE (Generic Desktop)
  0x09, 0x05,               //USAGE (Game Pad)
  0xa1, 0x01,               //
  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


This is the only code change I'm making, even though the code is set to handle button inputs in the gamepad_report struct and method calling it. Does anyone see anything I'm doing wrong in the second iteration? I'm getting no compiler errors. Thank you very much for any help!

kbishop

Re: HID Gamepad Report Descriptor issue

Postby kbishop » Tue Dec 13, 2016 10:12 pm

I guess I can't edit since I didnt login. Worth noting that the line without the comment description is //COLLECTION (APPLICATION)

And when I use the device with the second block, it throws the "This device cannot start. (Code 10)" in the device profile. So this is breaking it somehow xD

kbishop

Re: HID Gamepad Report Descriptor issue

Postby kbishop » Wed Dec 14, 2016 10:17 pm

Just wanted to post my solution in case someone else has this issue:

"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!"


Return to “V-USB”

Who is online

Users browsing this forum: No registered users and 8 guests