more host hid API

adding hid parser
This commit is contained in:
hathach
2021-05-14 01:02:47 +07:00
parent 641f55f1f1
commit 9ddc3bfd6d
4 changed files with 196 additions and 53 deletions

View File

@@ -46,9 +46,20 @@
#define CFG_TUH_HID_REPORT_MAX 4
#endif
#ifndef CFG_TUH_HID_REPORT_DESCRIPTOR_BUFSIZE
#define CFG_TUH_HID_REPORT_DESCRIPTOR_BUFSIZE 256
#endif
typedef struct
{
uint8_t count; // number of info
struct
{
uint8_t usage_page;
uint8_t usage;
// TODO still use the endpoint size for now
uint8_t in_len; // length of IN report
uint8_t out_len; // length of OUT report
} info[CFG_TUH_HID_REPORT_MAX];
} tuh_hid_report_info_t;
//--------------------------------------------------------------------+
// Application API (Multiple devices)
@@ -63,13 +74,25 @@ uint8_t tuh_n_hid_instance_count(uint8_t dev_addr);
// Check if HID instance is mounted
bool tuh_n_hid_n_mounted(uint8_t dev_addr, uint8_t instance);
// Get boot protocol check out hid_protocol_type_t for possible value
uint8_t tuh_n_hid_n_boot_protocol(uint8_t dev_addr, uint8_t instance);
// Check if current mode is Boot (true) or Report (false)
bool tuh_n_hid_n_boot_mode(uint8_t dev_addr, uint8_t instance);
// Get Report information parsed from report descriptor. Data must not be modified by application
// If report information does not match the actual device descriptor, that is because the built-in parser
// has its limit. Application could use tuh_hid_descriptor_report_cb() callback to parse descriptor by itself.
tuh_hid_report_info_t const* tuh_n_hid_n_get_report_info(uint8_t dev_addr, uint8_t instance);
// Check if the interface is ready to use
bool tuh_n_hid_n_ready(uint8_t dev_addr, uint8_t instance);
// Get Report from device
bool tuh_n_hid_n_get_report(uint8_t dev_addr, uint8_t instance, void* report, uint16_t len);
// Set Report using control endpoint
//bool tuh_n_hid_n_set_report_control(uint8_t dev_addr, uint8_t instance, void* report, uint16_t len);
//------------- -------------//
@@ -93,10 +116,10 @@ TU_ATTR_WEAK void tuh_hid_mounted_cb (uint8_t dev_addr, uint8_t instance);
// Invoked when device with hid interface is un-mounted
TU_ATTR_WEAK void tuh_hid_unmounted_cb(uint8_t dev_addr, uint8_t instance);
// Invoked when received Report from device
// Invoked when received Report from device via either regular or control endpoint
TU_ATTR_WEAK void tuh_hid_get_report_complete_cb(uint8_t dev_addr, uint8_t instance, uint8_t xferred_bytes);
// Invoked when Sent Report to device
// Invoked when Sent Report to device via either regular or control endpoint
TU_ATTR_WEAK void tuh_hid_set_report_complete_cb(uint8_t dev_addr, uint8_t instance, uint8_t xferred_bytes);
//--------------------------------------------------------------------+