diff options
| author | hathach <[email protected]> | 2021-02-09 15:57:29 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2021-02-09 15:57:29 +0700 |
| commit | d2b8e591f6f939f87c28aaa8b12f67a5072d2b06 (patch) | |
| tree | c97c4692866d3ec7cf3b3f7c4e1fe3acd3fcead5 /src/class/hid/hid_device.c | |
| parent | ecd16cf24bcef606019c8e4d694b3bf0f138c9aa (diff) | |
tud_hid_report_complete_cb() API
update hid composite to make use of tud_hid_report_complete_cb() for
sending reports when possible.
Diffstat (limited to 'src/class/hid/hid_device.c')
| -rw-r--r-- | src/class/hid/hid_device.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/class/hid/hid_device.c b/src/class/hid/hid_device.c index 5b9735071..4cdcecc9e 100644 --- a/src/class/hid/hid_device.c +++ b/src/class/hid/hid_device.c @@ -381,14 +381,24 @@ bool hidd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_ uint8_t itf = 0; hidd_interface_t * p_hid = _hidd_itf; - for ( ; ; itf++, p_hid++) + // Identify which interface to use + for (itf = 0; itf < CFG_TUD_HID; itf++) { - if (itf >= TU_ARRAY_SIZE(_hidd_itf)) return false; - - if ( ep_addr == p_hid->ep_out ) break; + p_hid = &_hidd_itf[itf]; + if ( (ep_addr == p_hid->ep_out) || (ep_addr == p_hid->ep_in) ) break; } + TU_ASSERT(itf < CFG_TUD_HID); - if (ep_addr == p_hid->ep_out) + // Sent report successfully + if (ep_addr == p_hid->ep_in) + { + if (tud_hid_report_complete_cb) + { + tud_hid_report_complete_cb(itf, p_hid->epin_buf, (uint8_t) xferred_bytes); + } + } + // Received report + else if (ep_addr == p_hid->ep_out) { tud_hid_set_report_cb( #if CFG_TUD_HID > 1 |
