diff options
| author | hathach <[email protected]> | 2021-05-12 21:40:17 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2021-05-18 12:58:24 +0700 |
| commit | b7a8b278c83b9b8e03a328e17f4b833f925226a2 (patch) | |
| tree | 34616a149b0d4d8a0d4ffb8649a2c8ccacb6d980 /src/class | |
| parent | 69defb5edc34979c9476533ba3bb49e070879ceb (diff) | |
rename tuh_device_is_configured() to tuh_device_configured()
- remove tuh_device_get_state()
- more hid mouse clean up
Diffstat (limited to 'src/class')
| -rw-r--r-- | src/class/hid/hid_host.c | 38 | ||||
| -rw-r--r-- | src/class/hid/hid_host.h | 19 |
2 files changed, 32 insertions, 25 deletions
diff --git a/src/class/hid/hid_host.c b/src/class/hid/hid_host.c index 80680894f..72cecb8d1 100644 --- a/src/class/hid/hid_host.c +++ b/src/class/hid/hid_host.c @@ -104,7 +104,7 @@ tusb_error_t hidh_interface_get_report(uint8_t dev_addr, void * report, hidh_int { //------------- parameters validation -------------// // TODO change to use is configured function - TU_ASSERT(TUSB_DEVICE_STATE_CONFIGURED == tuh_device_get_state(dev_addr), TUSB_ERROR_DEVICE_NOT_READY); + TU_ASSERT(tuh_device_configured(dev_addr), TUSB_ERROR_DEVICE_NOT_READY); TU_VERIFY(report, TUSB_ERROR_INVALID_PARA); TU_VERIFY(!hcd_edpt_busy(dev_addr, p_hid->ep_in), TUSB_ERROR_INTERFACE_IS_BUSY); @@ -113,32 +113,45 @@ tusb_error_t hidh_interface_get_report(uint8_t dev_addr, void * report, hidh_int return TUSB_ERROR_NONE; } +//bool tuh_n_hid_n_mounted(uint8_t daddr, uint8_t instance) +//{ +// +//} + //--------------------------------------------------------------------+ // KEYBOARD //--------------------------------------------------------------------+ -bool tuh_n_hid_n_keyboard_mounted(uint8_t dev_addr, uint8_t instance) +bool tuh_n_hid_n_mounted(uint8_t daddr, uint8_t instance) +{ + hidh_interface_t* hid_itf = get_instance(daddr, instance); + + // TODO check rid_keyboard + return tuh_device_configured(daddr) && (hid_itf->ep_in != 0); +} + +bool tuh_n_hid_n_keyboard_mounted(uint8_t daddr, uint8_t instance) { - hidh_interface_t* hid_itf = get_instance(dev_addr, instance); + hidh_interface_t* hid_itf = get_instance(daddr, instance); // TODO check rid_keyboard - return tuh_device_is_configured(dev_addr) && (hid_itf->ep_in != 0); + return tuh_device_configured(daddr) && (hid_itf->ep_in != 0); } tusb_error_t tuh_hid_keyboard_get_report(uint8_t dev_addr, void* buffer) { - uint8_t itf = 0; - hidh_interface_t* hid_itf = get_instance(dev_addr, itf); + uint8_t inst = 0; + hidh_interface_t* hid_itf = get_instance(dev_addr, inst); return hidh_interface_get_report(dev_addr, buffer, hid_itf); } bool tuh_hid_keyboard_is_busy(uint8_t dev_addr) { - uint8_t instance = 0; - hidh_interface_t* hid_itf = get_instance(dev_addr, instance); + uint8_t inst = 0; + hidh_interface_t* hid_itf = get_instance(dev_addr, inst); - return tuh_n_hid_n_keyboard_mounted(dev_addr, instance) && hcd_edpt_busy(dev_addr, hid_itf->ep_in); + return tuh_n_hid_n_keyboard_mounted(dev_addr, inst) && hcd_edpt_busy(dev_addr, hid_itf->ep_in); } //--------------------------------------------------------------------+ @@ -149,14 +162,15 @@ bool tuh_hid_keyboard_is_busy(uint8_t dev_addr) static hidh_interface_t mouseh_data[CFG_TUSB_HOST_DEVICE_MAX]; // does not have addr0, index = dev_address-1 //------------- Public API -------------// -bool tuh_hid_mouse_mounted(uint8_t dev_addr) +bool tuh_n_hid_n_mouse_mounted(uint8_t dev_addr, uint8_t instance) { - return tuh_device_is_configured(dev_addr) && (mouseh_data[dev_addr-1].ep_in != 0); +// hidh_interface_t* hid_itf = get_instance(dev_addr, instance); + return tuh_device_configured(dev_addr) && (mouseh_data[dev_addr-1].ep_in != 0); } bool tuh_hid_mouse_is_busy(uint8_t dev_addr) { - return tuh_hid_mouse_mounted(dev_addr) && hcd_edpt_busy(dev_addr, mouseh_data[dev_addr-1].ep_in); + return tuh_n_hid_n_mouse_mounted(dev_addr, 0) && hcd_edpt_busy(dev_addr, mouseh_data[dev_addr-1].ep_in); } tusb_error_t tuh_hid_mouse_get_report(uint8_t dev_addr, void * report) diff --git a/src/class/hid/hid_host.h b/src/class/hid/hid_host.h index c45ca9bd4..0052a2b0c 100644 --- a/src/class/hid/hid_host.h +++ b/src/class/hid/hid_host.h @@ -60,10 +60,14 @@ // Get the number of HID instances uint8_t tuh_n_hid_instance_count(uint8_t daddr); -// Check if HID instance has keyboard -bool tuh_n_hid_n_keyboard_mounted(uint8_t daddr, uint8_t instance); +// Check if HID instance is mounted +//bool tuh_n_hid_n_mounted(uint8_t daddr, uint8_t instance); +// Check if HID instance with Keyboard is mounted +bool tuh_n_hid_n_keyboard_mounted(uint8_t daddr, uint8_t instance); +// Check if HID instance with Mouse is mounted +bool tuh_n_hid_n_mouse_mounted(uint8_t dev_addr, uint8_t instance); //--------------------------------------------------------------------+ // Application API (Single device) @@ -101,10 +105,6 @@ TU_ATTR_WEAK void tuh_hid_unmounted_cb(uint8_t dev_addr, uint8_t instance); * The interface API includes status checking function, data transferring function and callback functions * @{ */ -// TODO used weak attr if build failed without KEYBOARD enabled -// TODO remove -extern uint8_t const hid_keycode_to_ascii_tbl[2][128]; - /** \brief Check if device supports Keyboard interface or not * \param[in] dev_addr device address * \retval true if device supports Keyboard interface @@ -170,13 +170,6 @@ void tuh_hid_keyboard_unmounted_cb(uint8_t dev_addr); * The interface API includes status checking function, data transferring function and callback functions * @{ */ -/** \brief Check if device supports Mouse interface or not - * \param[in] dev_addr device address - * \retval true if device supports Mouse interface - * \retval false if device does not support Mouse interface or is not mounted - */ -bool tuh_hid_mouse_mounted(uint8_t dev_addr); - /** \brief Check if the interface is currently busy or not * \param[in] dev_addr device address * \retval true if the interface is busy meaning the stack is still transferring/waiting data from/to device |
