Problem with CALLBACK_HID_Device_CreateHIDReport

42 views
Skip to first unread message

Евгений

unread,
Jun 12, 2020, 10:29:49 PM6/12/20
to LUFA Library Support List
Hello, everybody!
First of all - im sorry for mu broken English.

Can anybody explain me, why i get wrong Feature Report from my HID Device?

HID Report Descriptor:

const USB_Descriptor_HIDReport_Datatype_t PROGMEM JoystickReport[] =
{
 
0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
 
0x09, 0x04,                    // USAGE (Joystick)
 
0xa1, 0x01,                    // COLLECTION (Application)
 
0x85, 0x01,                    //   REPORT_ID (1)
 
0x05, 0x02,                    //   USAGE_PAGE (Simulation Controls)
 
0x09, 0xbb,                    //   USAGE (Throttle)
 
0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
 
0x26, 0xff, 0x00,              //   LOGICAL_MAXIMUM (255)
 
0x75, 0x08,                    //   REPORT_SIZE (8)
 
0x95, 0x01,                    //   REPORT_COUNT (1)
 
0x81, 0x02,                    //   INPUT (Data,Var,Abs)
 
0x05, 0x01,                    //   USAGE_PAGE (Generic Desktop)
 
0x09, 0x30,                    //   USAGE (X)
 
0x81, 0x02,                    //   INPUT (Data,Var,Abs)
 
0x09, 0x31,                    //   USAGE (Y)
 
0x81, 0x02,                    //   INPUT (Data,Var,Abs)
 
0x09, 0x32,                    //   USAGE (Z)
 
0x81, 0x02,                    //   INPUT (Data,Var,Abs)
 
 
0x06, 0x00, 0xFF,              //   Vendor Defined Page 1
 
0x09, 0x02,                    //   Vendor Usage 2
 
0x85, 0x01,                    //   REPORT_ID (1)
 
0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
 
0x26, 0xff, 0x00,              //   LOGICAL_MAXIMUM (255)
 
0x75, 0x08,                    //   REPORT_SIZE (8)
 
0x95, 0x07,                    //   REPORT_COUNT (7)
 
0xb1, 0x02,                    //   FEATURE (Data,Var,Abs)
 
0x09, 0x02,                    //   Vendor Usage 2
 
0x85, 0x02,                    //   REPORT_ID (2)
 
0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
 
0x26, 0xff, 0x00,              //   LOGICAL_MAXIMUM (255)
 
0x75, 0x08,                    //   REPORT_SIZE (8)
 
0x95, 0x40,                    //   REPORT_COUNT (64)
 
0x91, 0x02,                    // OUTPUT (Data,Var,Abs)  
 
0xc0,                          // END_COLLECTION  
};

Process Feature report:

bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
uint8_t
* const ReportID,
const uint8_t ReportType,
void* ReportData,
uint16_t
* const ReportSize)
{
 
switch (ReportType)
 
{
 
case HID_REPORT_ITEM_Feature:
 
if (*ReportID == 1)
 
{
 HID_JoyEventReport2_t
* EventReport = (HID_JoyEventReport2_t*)ReportData;
 
 
EventReport->EventCount = 0;
 
EventReport->Event1Id = 255;
 
EventReport->Event1Data = 0;
 
EventReport->Event2Id = 255;
 
EventReport->Event2Data = 0;
 
EventReport->Event3Id = 255;
 
EventReport->Event3Data = 0;
 
 
*ReportSize = sizeof(HID_JoyEventReport2_t); //
 
}
 
break;
 
}
 
 
return false;
}

Struct just for test (without array of byte):

typedef struct
{
 uint8_t
EventCount;
 uint8_t
Event1Id;
 uint8_t
Event1Data;
 uint8_t
Event2Id;
 uint8_t
Event2Data;
 uint8_t
Event3Id;
 uint8_t
Event3Data;
} HID_JoyEventReport2_t;

When i use HidD_GetFeature WinAPI Func, i get next data:


It seems like the data is left shifted...
i think "7" in buffer[3] is the sizeof(HID_JoyEventReport2_t) value from CALLBACK_HID_Device_CreateHIDReport function.

Help plz. I don't understand why it's happening? 
Message has been deleted

Евгений

unread,
Jun 14, 2020, 3:43:22 AM6/14/20
to LUFA Library Support List

Refresh the picture.

And i figured out, why it's happening.
The buffer, which needed for inner using of library was too small... So, there are was not room for processing data in right way...

static uint8_t PrevJoystickHIDReportBuffer[sizeof(USB_JoystickReport_Data_t)];

This buffer must be large enough to accommodate the biggest IN report...
Reply all
Reply to author
Forward
0 new messages