summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2021-02-09 17:05:12 +0700
committerGitHub <[email protected]>2021-02-09 17:05:12 +0700
commit5d20b8f19b459189835bcb8d0532521ba0206808 (patch)
tree5da590fa3c0e19d6172221579ab7d40fe56a3c5b /src
parentecd16cf24bcef606019c8e4d694b3bf0f138c9aa (diff)
parent9c3a44b6a3bfa6951213b0f24476f5360c8b5fdf (diff)
Merge pull request #640 from hathach/add-hid-complete-callback
Diffstat (limited to 'src')
-rw-r--r--src/class/hid/hid_device.c20
-rw-r--r--src/class/hid/hid_device.h5
2 files changed, 19 insertions, 6 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
diff --git a/src/class/hid/hid_device.h b/src/class/hid/hid_device.h
index a92dc14e0..d5de53221 100644
--- a/src/class/hid/hid_device.h
+++ b/src/class/hid/hid_device.h
@@ -123,7 +123,10 @@ TU_ATTR_WEAK bool tud_hid_set_idle_cb(uint8_t idle_rate);
#endif
-// TU_ATTR_WEAK void tud_hid_report_complete_cb(uint8_t itf, );
+// Invoked when sent REPORT successfully to host
+// Application can use this to send the next report
+// Note: For composite reports, report[0] is report ID
+TU_ATTR_WEAK void tud_hid_report_complete_cb(uint8_t itf, uint8_t const* report, uint8_t len);
//--------------------------------------------------------------------+