refractor device mouse main.c & tusbd_hid_mouse_send_report
This commit is contained in:
parent
b527e6ec4a
commit
52f18f3784
|
@ -18,6 +18,7 @@ void print_greeting(void);
|
||||||
|
|
||||||
void led_blinking_task(void * p_para);
|
void led_blinking_task(void * p_para);
|
||||||
void keyboard_device_app_task(void * p_para);
|
void keyboard_device_app_task(void * p_para);
|
||||||
|
void mouse_device_app_task(void * p_para);
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
@ -40,15 +41,7 @@ int main(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if TUSB_CFG_DEVICE_HID_MOUSE
|
#if TUSB_CFG_DEVICE_HID_MOUSE
|
||||||
if (usb_isConfigured())
|
mouse_device_app_task(NULL);
|
||||||
{
|
|
||||||
static uint32_t count =0;
|
|
||||||
if (count < 8)
|
|
||||||
{
|
|
||||||
count++;
|
|
||||||
tusb_hid_mouse_send(0, 20, 20);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,6 +109,24 @@ void keyboard_device_app_task(void * p_para)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if TUSB_CFG_DEVICE_HID_MOUSE
|
||||||
|
void mouse_device_app_task(void * p_para)
|
||||||
|
{
|
||||||
|
if (usb_isConfigured())
|
||||||
|
{
|
||||||
|
static uint32_t count =0;
|
||||||
|
if (count < 8)
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
tusbd_hid_mouse_send_report(
|
||||||
|
&(tusb_mouse_report_t) {
|
||||||
|
.x = 20,
|
||||||
|
.y = 20 } );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// HELPER FUNCTION
|
// HELPER FUNCTION
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
|
@ -200,7 +200,7 @@ tusb_error_t tusbd_hid_keyboard_send_report(tusb_keyboard_report_t *p_kbd_report
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if TUSB_CFG_DEVICE_HID_MOUSE
|
#if TUSB_CFG_DEVICE_HID_MOUSE
|
||||||
tusb_error_t tusb_hid_mouse_send(uint8_t buttons, int8_t x, int8_t y)
|
tusb_error_t tusbd_hid_mouse_send_report(tusb_mouse_report_t *p_mouse_report)
|
||||||
{
|
{
|
||||||
// uint32_t start_time = systickGetSecondsActive();
|
// uint32_t start_time = systickGetSecondsActive();
|
||||||
// while (bMouseChanged) // TODO Block while previous key hasn't been sent - can use fifo to improve this
|
// while (bMouseChanged) // TODO Block while previous key hasn't been sent - can use fifo to improve this
|
||||||
|
@ -213,10 +213,7 @@ tusb_error_t tusb_hid_mouse_send(uint8_t buttons, int8_t x, int8_t y)
|
||||||
return TUSB_ERROR_FAILED;
|
return TUSB_ERROR_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
hid_mouse_report.buttons = buttons;
|
hid_mouse_report = *p_mouse_report;
|
||||||
hid_mouse_report.x = x;
|
|
||||||
hid_mouse_report.y = y;
|
|
||||||
|
|
||||||
bMouseChanged = true;
|
bMouseChanged = true;
|
||||||
|
|
||||||
return TUSB_ERROR_NONE;
|
return TUSB_ERROR_NONE;
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
// KEYBOARD Application API
|
// KEYBOARD Application API
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
tusb_error_t tusbd_hid_keyboard_send_report(tusb_keyboard_report_t *p_kbd_report);
|
tusb_error_t tusbd_hid_keyboard_send_report(tusb_keyboard_report_t *p_kbd_report);
|
||||||
tusb_error_t tusbd_hid_mouse_send_report(uint8_t buttons, int8_t x, int8_t y);
|
tusb_error_t tusbd_hid_mouse_send_report(tusb_mouse_report_t *p_mouse_report);
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// USBD-CLASS DRIVER API
|
// USBD-CLASS DRIVER API
|
||||||
|
|
Loading…
Reference in New Issue