mirror of
https://github.com/hathach/tinyusb.git
synced 2025-04-18 02:42:37 +00:00
upgrade hid device to match new dcd API
This commit is contained in:
parent
a77cccb33a
commit
a55fcece4c
@ -66,7 +66,7 @@ void mouse_app_umount(uint8_t port)
|
||||
|
||||
}
|
||||
|
||||
void tusbd_hid_mouse_cb(uint8_t port, tusb_event_t event, uint32_t xferred_bytes)
|
||||
void tud_hid_mouse_cb(uint8_t port, tusb_event_t event, uint32_t xferred_bytes)
|
||||
{
|
||||
switch(event)
|
||||
{
|
||||
@ -77,7 +77,7 @@ void tusbd_hid_mouse_cb(uint8_t port, tusb_event_t event, uint32_t xferred_bytes
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t tusbd_hid_mouse_get_report_cb(uint8_t port, hid_request_report_type_t report_type, void** pp_report, uint16_t requested_length)
|
||||
uint16_t tud_hid_mouse_get_report_cb(uint8_t port, hid_request_report_type_t report_type, void** pp_report, uint16_t requested_length)
|
||||
{
|
||||
if ( report_type != HID_REQUEST_REPORT_INPUT ) return 0; // not support other report type for this mouse demo
|
||||
|
||||
@ -85,7 +85,7 @@ uint16_t tusbd_hid_mouse_get_report_cb(uint8_t port, hid_request_report_type_t r
|
||||
return requested_length;
|
||||
}
|
||||
|
||||
void tusbd_hid_mouse_set_report_cb(uint8_t port, hid_request_report_type_t report_type, uint8_t report_data[], uint16_t length)
|
||||
void tud_hid_mouse_set_report_cb(uint8_t port, hid_request_report_type_t report_type, uint8_t report_data[], uint16_t length)
|
||||
{
|
||||
// mouse demo does not support set report --> do nothing
|
||||
}
|
||||
@ -102,7 +102,7 @@ void mouse_app_subtask(void);
|
||||
|
||||
void mouse_app_task(void * param)
|
||||
{
|
||||
(void) para;
|
||||
(void) param;
|
||||
OSAL_TASK_BEGIN
|
||||
mouse_app_subtask();
|
||||
OSAL_TASK_END
|
||||
@ -114,7 +114,7 @@ void mouse_app_subtask(void)
|
||||
|
||||
osal_task_delay(20);
|
||||
|
||||
if ( tusbd_is_configured(0) && !tusbd_hid_mouse_is_busy(0) )
|
||||
if ( tud_mounted(0) && !tud_hid_mouse_is_busy(0) )
|
||||
{
|
||||
static uint8_t prev_mouse_buttons = 0;
|
||||
|
||||
@ -147,7 +147,7 @@ void mouse_app_subtask(void)
|
||||
{ // send report if clicked buttons are changed or there is any movement x, y, wheel
|
||||
prev_mouse_buttons = mouse_report.buttons;
|
||||
|
||||
tusbd_hid_mouse_send(0, &mouse_report);
|
||||
tud_hid_mouse_send(0, &mouse_report);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@
|
||||
|
||||
//------------- CLASS -------------//
|
||||
#define TUSB_CFG_DEVICE_HID_KEYBOARD 1
|
||||
#define TUSB_CFG_DEVICE_HID_MOUSE 0
|
||||
#define TUSB_CFG_DEVICE_HID_MOUSE 1
|
||||
#define TUSB_CFG_DEVICE_HID_GENERIC 0 // not supported yet
|
||||
#define TUSB_CFG_DEVICE_MSC 1
|
||||
#define TUSB_CFG_DEVICE_CDC 1
|
||||
|
@ -59,7 +59,7 @@ typedef struct {
|
||||
uint8_t const * p_report_desc;
|
||||
uint16_t report_length;
|
||||
|
||||
edpt_hdl_t ept_handle;
|
||||
uint8_t edpt_addr;
|
||||
uint8_t interface_number;
|
||||
}hidd_interface_t;
|
||||
|
||||
@ -91,9 +91,9 @@ static hidd_class_driver_t const hidd_class_driver[HIDD_NUMBER_OF_SUBCLASS] =
|
||||
[HID_PROTOCOL_MOUSE] =
|
||||
{
|
||||
.p_interface = &moused_data,
|
||||
.xfer_cb = tusbd_hid_mouse_cb,
|
||||
.get_report_cb = tusbd_hid_mouse_get_report_cb,
|
||||
.set_report_cb = tusbd_hid_mouse_set_report_cb
|
||||
.xfer_cb = tud_hid_mouse_cb,
|
||||
.get_report_cb = tud_hid_mouse_get_report_cb,
|
||||
.set_report_cb = tud_hid_mouse_set_report_cb
|
||||
}
|
||||
#endif
|
||||
};
|
||||
@ -109,7 +109,7 @@ STATIC_VAR hidd_interface_t keyboardd_data;
|
||||
|
||||
bool tud_hid_keyboard_busy(uint8_t port)
|
||||
{
|
||||
return tusb_dcd_edpt_busy(keyboardd_data.ept_handle);
|
||||
return tusb_dcd_edpt_busy(port, keyboardd_data.edpt_addr);
|
||||
}
|
||||
|
||||
tusb_error_t tud_hid_keyboard_send(uint8_t port, hid_keyboard_report_t const *p_report)
|
||||
@ -118,7 +118,7 @@ tusb_error_t tud_hid_keyboard_send(uint8_t port, hid_keyboard_report_t const *p_
|
||||
|
||||
hidd_interface_t * p_kbd = &keyboardd_data; // TODO &keyboardd_data[port];
|
||||
|
||||
ASSERT_STATUS( tusb_dcd_edpt_xfer(p_kbd->ept_handle, (void*) p_report, sizeof(hid_keyboard_report_t), true) ) ;
|
||||
ASSERT_STATUS( tusb_dcd_edpt_xfer(port, p_kbd->edpt_addr, (void*) p_report, sizeof(hid_keyboard_report_t), true) ) ;
|
||||
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
@ -130,18 +130,18 @@ tusb_error_t tud_hid_keyboard_send(uint8_t port, hid_keyboard_report_t const *p_
|
||||
#if TUSB_CFG_DEVICE_HID_MOUSE
|
||||
STATIC_VAR hidd_interface_t moused_data;
|
||||
|
||||
bool tusbd_hid_mouse_is_busy(uint8_t port)
|
||||
bool tud_hid_mouse_is_busy(uint8_t port)
|
||||
{
|
||||
return tusb_dcd_edpt_busy(moused_data.ept_handle);
|
||||
return tusb_dcd_edpt_busy(port, moused_data.edpt_addr);
|
||||
}
|
||||
|
||||
tusb_error_t tusbd_hid_mouse_send(uint8_t port, hid_mouse_report_t const *p_report)
|
||||
tusb_error_t tud_hid_mouse_send(uint8_t port, hid_mouse_report_t const *p_report)
|
||||
{
|
||||
ASSERT(tud_mounted(port), TUSB_ERROR_USBD_DEVICE_NOT_CONFIGURED);
|
||||
|
||||
hidd_interface_t * p_mouse = &moused_data; // TODO &keyboardd_data[port];
|
||||
|
||||
ASSERT_STATUS( tusb_dcd_edpt_xfer(p_mouse->ept_handle, (void*) p_report, sizeof(hid_mouse_report_t), true) ) ;
|
||||
ASSERT_STATUS( tusb_dcd_edpt_xfer(port, p_mouse->edpt_addr, (void*) p_report, sizeof(hid_mouse_report_t), true) ) ;
|
||||
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
@ -280,7 +280,9 @@ tusb_error_t hidd_open(uint8_t port, tusb_descriptor_interface_t const * p_inter
|
||||
|
||||
VERIFY(p_hid, TUSB_ERROR_FAILED);
|
||||
|
||||
VERIFY( tusb_dcd_edpt_open(port, p_desc_endpoint, &p_hid->ept_handle), TUSB_ERROR_DCD_FAILED );
|
||||
VERIFY( tusb_dcd_edpt_open(port, p_desc_endpoint), TUSB_ERROR_DCD_FAILED );
|
||||
|
||||
p_hid->edpt_addr = p_desc_endpoint->bEndpointAddress;
|
||||
|
||||
p_hid->interface_number = p_interface_desc->bInterfaceNumber;
|
||||
p_hid->p_report_desc = (p_interface_desc->bInterfaceProtocol == HID_PROTOCOL_KEYBOARD) ? tusbd_descriptor_pointers.p_hid_keyboard_report : tusbd_descriptor_pointers.p_hid_mouse_report;
|
||||
@ -303,14 +305,14 @@ tusb_error_t hidd_open(uint8_t port, tusb_descriptor_interface_t const * p_inter
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
|
||||
tusb_error_t hidd_xfer_cb(edpt_hdl_t edpt_hdl, tusb_event_t event, uint32_t xferred_bytes)
|
||||
tusb_error_t hidd_xfer_cb(uint8_t port, uint8_t edpt_addr, tusb_event_t event, uint32_t xferred_bytes)
|
||||
{
|
||||
for(uint8_t i=0; i<HIDD_NUMBER_OF_SUBCLASS; i++)
|
||||
{
|
||||
hidd_interface_t * const p_interface = hidd_class_driver[i].p_interface;
|
||||
if ( (p_interface != NULL) && edpt_equal(edpt_hdl, p_interface->ept_handle) )
|
||||
if ( (p_interface != NULL) && (edpt_addr == p_interface->edpt_addr) )
|
||||
{
|
||||
hidd_class_driver[i].xfer_cb(edpt_hdl.port, event, xferred_bytes);
|
||||
hidd_class_driver[i].xfer_cb(port, event, xferred_bytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,7 +203,7 @@ void tud_hid_mouse_set_report_cb(uint8_t port, hid_request_report_type_t report_
|
||||
void hidd_init(void);
|
||||
tusb_error_t hidd_open(uint8_t port, tusb_descriptor_interface_t const * p_interface_desc, uint16_t *p_length);
|
||||
tusb_error_t hidd_control_request_subtask(uint8_t port, tusb_control_request_t const * p_request);
|
||||
tusb_error_t hidd_xfer_cb(edpt_hdl_t edpt_hdl, tusb_event_t event, uint32_t xferred_bytes);
|
||||
tusb_error_t hidd_xfer_cb(uint8_t port, uint8_t edpt_addr, tusb_event_t event, uint32_t xferred_bytes);
|
||||
void hidd_close(uint8_t port);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user