remove CFG_TUH_HID_KEYBOARD and CFG_TUH_HID_MOUSE

This commit is contained in:
hathach 2021-05-13 15:44:00 +07:00
parent cc1b83412a
commit 641f55f1f1
4 changed files with 7 additions and 38 deletions

View File

@ -51,14 +51,13 @@ int main(void)
{
// tinyusb host task
tuh_task();
led_blinking_task();
#if CFG_TUH_CDC
cdc_task();
#endif
#if CFG_TUH_HID_KEYBOARD || CFG_TUH_HID_MOUSE
#if CFG_TUH_HID
hid_task();
#endif
}
@ -109,8 +108,6 @@ void cdc_task(void)
//--------------------------------------------------------------------+
// USB HID
//--------------------------------------------------------------------+
#if CFG_TUH_HID_KEYBOARD
CFG_TUSB_MEM_SECTION static hid_keyboard_report_t usb_keyboard_report;
uint8_t const keycode2ascii[128][2] = { HID_KEYCODE_TO_ASCII };
@ -158,6 +155,7 @@ void tuh_hid_mounted_cb(uint8_t dev_addr, uint8_t instance)
{
printf("HID device address = %d, instance = %d is mounted\r\n", dev_addr, instance);
// printf("A Keyboard device (address %d) is mounted\r\n", dev_addr);
// printf("A Mouse device (address %d) is mounted\r\n", dev_addr);
if (instance == 0) {
tuh_n_hid_n_get_report(dev_addr, instance, &usb_keyboard_report, sizeof(usb_keyboard_report));
@ -168,11 +166,9 @@ void tuh_hid_unmounted_cb(uint8_t dev_addr, uint8_t instance)
{
printf("HID device address = %d, instance = %d is unmounted\r\n", dev_addr, instance);
// printf("A Keyboard device (address %d) is unmounted\r\n", dev_addr);
// printf("A Mouse device (address %d) is unmounted\r\n", dev_addr);
}
#endif
#if CFG_TUH_HID_MOUSE
CFG_TUSB_MEM_SECTION static hid_mouse_report_t usb_mouse_report;
@ -225,28 +221,12 @@ static inline void process_mouse_report(hid_mouse_report_t const * p_report)
}
void tuh_hid_mouse_mounted_cb(uint8_t dev_addr)
{
// application set-up
printf("A Mouse device (address %d) is mounted\r\n", dev_addr);
}
void tuh_hid_mouse_unmounted_cb(uint8_t dev_addr)
{
// application tear-down
printf("A Mouse device (address %d) is unmounted\r\n", dev_addr);
}
#endif
void hid_task(void)
{
uint8_t const daddr = 1;
uint8_t const instance = 0;
#if CFG_TUH_HID_KEYBOARD
if ( tuh_n_hid_n_keyboard_mounted(daddr, instance) )
{
if ( tuh_n_hid_n_ready(daddr, instance) )
@ -255,9 +235,8 @@ void hid_task(void)
tuh_n_hid_n_get_report(daddr, instance, &usb_keyboard_report, sizeof(usb_keyboard_report));
}
}
#endif
#if CFG_TUH_HID_MOUSE
// #if CFG_TUH_HID_MOUSE
(void) usb_mouse_report;
// if ( tuh_n_hid_n_mouse_mounted(daddr, instance) )
// {
@ -267,7 +246,6 @@ void hid_task(void)
// tuh_n_hid_n_get_report(daddr, instance, &usb_mouse_report, sizeof(usb_mouse_report));
// }
// }
#endif
}
//--------------------------------------------------------------------+

View File

@ -76,13 +76,7 @@
#define CFG_TUH_HUB 1
#define CFG_TUH_CDC 1
#define CFG_TUH_HID 2
#define CFG_TUH_HID_KEYBOARD 1
#define CFG_TUH_HID_MOUSE 1
#define CFG_TUSB_HOST_HID_GENERIC 0 // (not yet supported)
#define CFG_TUH_MSC 1
#define CFG_TUH_VENDOR 0

View File

@ -140,8 +140,8 @@ bool tuh_n_hid_n_keyboard_mounted(uint8_t dev_addr, uint8_t instance)
//--------------------------------------------------------------------+
// MOUSE
//--------------------------------------------------------------------+
#if CFG_TUH_HID_MOUSE
// TODO remove
static hidh_interface_t mouseh_data[CFG_TUSB_HOST_DEVICE_MAX]; // does not have addr0, index = dev_address-1
//------------- Public API -------------//
@ -151,8 +151,6 @@ bool tuh_n_hid_n_mouse_mounted(uint8_t dev_addr, uint8_t instance)
return tuh_device_ready(dev_addr) && (mouseh_data[dev_addr-1].ep_in != 0);
}
#endif
//--------------------------------------------------------------------+
// USBH API
//--------------------------------------------------------------------+

View File

@ -85,9 +85,8 @@ typedef struct
#if TUSB_OPT_HOST_ENABLED
// Max number of endpoints per device
enum {
HCD_MAX_ENDPOINT = CFG_TUSB_HOST_DEVICE_MAX*(CFG_TUH_HUB + CFG_TUH_HID_KEYBOARD + CFG_TUH_HID_MOUSE + CFG_TUSB_HOST_HID_GENERIC +
CFG_TUH_MSC*2 + CFG_TUH_CDC*3),
// TODO better computation
HCD_MAX_ENDPOINT = CFG_TUSB_HOST_DEVICE_MAX*(CFG_TUH_HUB + CFG_TUH_HID*2 + CFG_TUH_MSC*2 + CFG_TUH_CDC*3),
HCD_MAX_XFER = HCD_MAX_ENDPOINT*2,
};