mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-29 01:20:19 +00:00
add tud_hid_out_report_cb() for hid epout
This commit is contained in:
parent
a25ca701cd
commit
1c0ec61aa1
@ -159,7 +159,7 @@ bool hidd_open(uint8_t rhport, tusb_desc_interface_t const * desc_itf, uint16_t
|
|||||||
uint8_t const *p_desc = (uint8_t const *) desc_itf;
|
uint8_t const *p_desc = (uint8_t const *) desc_itf;
|
||||||
|
|
||||||
// TODO support multiple HID interface
|
// TODO support multiple HID interface
|
||||||
uint8_t itf = 0;
|
uint8_t const itf = 0;
|
||||||
hidd_interface_t * p_hid = &_hidd_itf[itf];
|
hidd_interface_t * p_hid = &_hidd_itf[itf];
|
||||||
|
|
||||||
//------------- HID descriptor -------------//
|
//------------- HID descriptor -------------//
|
||||||
@ -179,6 +179,9 @@ bool hidd_open(uint8_t rhport, tusb_desc_interface_t const * desc_itf, uint16_t
|
|||||||
|
|
||||||
*p_len = sizeof(tusb_desc_interface_t) + sizeof(tusb_hid_descriptor_hid_t) + desc_itf->bNumEndpoints*sizeof(tusb_desc_endpoint_t);
|
*p_len = sizeof(tusb_desc_interface_t) + sizeof(tusb_hid_descriptor_hid_t) + desc_itf->bNumEndpoints*sizeof(tusb_desc_endpoint_t);
|
||||||
|
|
||||||
|
// Prepare for output endpoint
|
||||||
|
if (p_hid->ep_out) TU_ASSERT(dcd_edpt_xfer(rhport, p_hid->ep_out, p_hid->epout_buf, sizeof(p_hid->epout_buf)));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,13 +291,20 @@ bool hidd_control_request_complete(uint8_t rhport, tusb_control_request_t const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hidd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes)
|
bool hidd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes)
|
||||||
{
|
{
|
||||||
// nothing to do
|
(void) result;
|
||||||
(void) rhport;
|
|
||||||
(void) ep_addr;
|
// TODO support multiple HID interface
|
||||||
(void) event;
|
uint8_t const itf = 0;
|
||||||
(void) xferred_bytes;
|
hidd_interface_t * p_hid = &_hidd_itf[itf];
|
||||||
|
|
||||||
|
if (ep_addr == p_hid->ep_out)
|
||||||
|
{
|
||||||
|
if (tud_hid_out_report_cb) tud_hid_out_report_cb(p_hid->epout_buf, xferred_bytes);
|
||||||
|
|
||||||
|
TU_ASSERT(dcd_edpt_xfer(rhport, p_hid->ep_out, p_hid->epout_buf, sizeof(p_hid->epout_buf)));
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -68,18 +68,21 @@ bool tud_hid_mouse_report(uint8_t report_id, uint8_t buttons, int8_t x, int8_t y
|
|||||||
// Callbacks (Weak is optional)
|
// Callbacks (Weak is optional)
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
// Invoked when receiving GET_REPORT control request
|
// Invoked when received GET_REPORT control request
|
||||||
// Application must fill buffer report's content and return its length.
|
// Application must fill buffer report's content and return its length.
|
||||||
// Return zero will cause the stack to STALL request
|
// Return zero will cause the stack to STALL request
|
||||||
uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen);
|
uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen);
|
||||||
|
|
||||||
// Invoked when receiving SET_REPORT control request
|
// Invoked when received SET_REPORT control request
|
||||||
void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize);
|
void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize);
|
||||||
|
|
||||||
// Invoked when host switch mode Boot <-> Report via SET_PROTOCOL request
|
// Invoked when received data on OUT endpoint
|
||||||
|
ATTR_WEAK void tud_hid_out_report_cb(uint8_t const* buffer, uint16_t bufsize);
|
||||||
|
|
||||||
|
// Invoked when received SET_PROTOCOL request ( mode switch Boot <-> Report )
|
||||||
ATTR_WEAK void tud_hid_boot_mode_cb(uint8_t boot_mode);
|
ATTR_WEAK void tud_hid_boot_mode_cb(uint8_t boot_mode);
|
||||||
|
|
||||||
// Invoked when host send SET_IDLE request. return false will stall the request
|
// Invoked when received SET_IDLE request. return false will stall the request
|
||||||
// - Idle Rate = 0 : only send report if there is changes, i.e skip duplication
|
// - Idle Rate = 0 : only send report if there is changes, i.e skip duplication
|
||||||
// - Idle Rate > 0 : skip duplication, but send at least 1 report every idle rate (in unit of 4 ms).
|
// - Idle Rate > 0 : skip duplication, but send at least 1 report every idle rate (in unit of 4 ms).
|
||||||
ATTR_WEAK bool tud_hid_set_idle_cb(uint8_t idle_rate);
|
ATTR_WEAK bool tud_hid_set_idle_cb(uint8_t idle_rate);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user