it's me with a stupid question again
I was wondering how to handle a HID descriptor with multiple report ids correctly? For example, if I had a device with a HID descriptor containing two reports (report id(1) and report id(2)), would it be sufficient to modify the function "usbFunctionSetup" delivered with the HID-mouse-example in this way?
Code: Select all
static uint32_t UsbReport_t_1; /* Data for report id(1) */
static uint32_t UsbReport_t_2; /* Data for report id(2) */
usbMsgLen_t usbFunctionSetup(uchar data[8])
{
usbRequest_t *rq = (void *)data;
uchar localReportId;
uchar localSize;
/* The following requests are never used. But since they are required by
* the specification, we implement them in this example.
*/
if((rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_CLASS){ /* class request type */
if(rq->bRequest == USBRQ_HID_GET_REPORT){ /* wValue: ReportType (highbyte), ReportID (lowbyte) */
/* Get current Report ID */
localReportId = rq->wValue.bytes[0];
/* Determine which report to send */
switch (localReportId) {
case 0x01: usbMsgPtr = (void *)&UsbReport_t_1;
localSize = sizeof(UsbReport_t_1);
break;
case 0x02: usbMsgPtr = (void *)&UsbReport_t_2;
localSize = sizeof(UsbReport_t_2);
break;
}
return localSize;
}else if(rq->bRequest == USBRQ_HID_GET_IDLE){
usbMsgPtr = &idleRate;
return 1;
}else if(rq->bRequest == USBRQ_HID_SET_IDLE){
idleRate = rq->wValue.bytes[1];
}
}else{
/* no vendor specific requests implemented */
}
return 0; /* default for not implemented requests: return no data back to host */
Would that work or would I have to do something else/additional?
Thanks in advance for any comments!