Skip to content

Commit 5d4ec0b

Browse files
committed
update hid with tud_hid_descriptor_report_cb()
1 parent df5219c commit 5d4ec0b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/Adafruit_USBD_HID.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,7 @@ bool Adafruit_USBD_HID::begin(void)
103103
{
104104
if ( !USBDevice.addInterface(*this) ) return false;
105105

106-
tud_desc_set.hid_report = _desc_report;
107106
_hid_dev = this;
108-
109107
return true;
110108
}
111109

@@ -123,6 +121,13 @@ bool Adafruit_USBD_HID::sendReport(uint8_t report_id, void const* report, uint8_
123121
extern "C"
124122
{
125123

124+
uint8_t const * tud_hid_descriptor_report_cb(void)
125+
{
126+
if (!_hid_dev) return NULL;
127+
128+
return _hid_dev->_desc_report;
129+
}
130+
126131
// Invoked when received GET_REPORT control request
127132
// Application must fill buffer report's content and return its length.
128133
// Return zero will cause the stack to STALL request

src/Adafruit_USBD_HID.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class Adafruit_USBD_HID : Adafruit_USBD_Interface
7575

7676
friend uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen);
7777
friend void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize);
78+
friend uint8_t const * tud_hid_descriptor_report_cb(void);
7879
};
7980

8081
#endif /* ADAFRUIT_USBD_HID_H_ */

0 commit comments

Comments
 (0)