update hid to use tud_hid_descriptor_report_cb()

This commit is contained in:
hathach committed 2019-05-12 00:20:50 +07:00
1 parent 11614dae70
commit 6f639b023f
4 files changed
+9 -4

No files matched your search

@@ -44,7 +44,6 @@ tud_desc_set_t tud_desc_set =
{
.device = NULL, // update later
.config = NULL, // update later
.hid_report = NULL // update later
};
// Invoked when received GET_STRING_DESC request
@@ -77,6 +76,7 @@ uint8_t tud_descriptor_string_cb(uint8_t index, uint16_t* desc, uint8_t max_char
break;
case 3:
// serial Number
return load_serial_number(desc);
default: return 0;
@@ -85,6 +85,7 @@ uint8_t tud_descriptor_string_cb(uint8_t index, uint16_t* desc, uint8_t max_char
return 0;
}
} // extern C
Adafruit_USBD_Device USBDevice;
@@ -201,7 +201,8 @@ bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * p_reque
if (p_request->bRequest == TUSB_REQ_GET_DESCRIPTOR && desc_type == HID_DESC_TYPE_REPORT)
{
usbd_control_xfer(rhport, p_request, (void*) tud_desc_set.hid_report, p_hid->reprot_desc_len);
uint8_t const * desc_report = tud_hid_descriptor_report_cb();
usbd_control_xfer(rhport, p_request, (void*) desc_report, p_hid->reprot_desc_len);
}else
{
return false; // stall unsupported request
@@ -68,6 +68,11 @@ bool tud_hid_mouse_report(uint8_t report_id, uint8_t buttons, int8_t x, int8_t y
// Callbacks (Weak is optional)
//--------------------------------------------------------------------+
// Invoked when received GET REPORT DESCRIPTOR
// Application return pointer to report descriptor.
// descriptor contents must exist long enough for transfer to complete
ATTR_WEAK uint8_t const * tud_hid_descriptor_report_cb(void);
// Invoked when received GET_REPORT control request
// Application must fill buffer report's content and return its length.
// Return zero will cause the stack to STALL request
@@ -41,8 +41,6 @@
typedef struct {
void const * device; ///< pointer to device descriptor \ref tusb_desc_device_t
void const * config; ///< pointer to the whole configuration descriptor, starting by \ref tusb_desc_configuration_t
uint8_t const* hid_report;
}tud_desc_set_t;
// Descriptor collection set, must be defined by application