mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
improve tud_hid_mouse API()
This commit is contained in:
parent
b370283174
commit
a6fede4962
@ -188,6 +188,37 @@ static bool hidd_mouse_report(hid_mouse_report_t const *p_report)
|
||||
|
||||
return dcd_edpt_xfer(TUD_OPT_RHPORT, p_hid->ep_in, p_hid->report_buf, sizeof(hid_mouse_report_t));
|
||||
}
|
||||
|
||||
bool tud_hid_mouse_data(uint8_t buttons, int8_t x, int8_t y, int8_t scroll, int8_t pan)
|
||||
{
|
||||
hid_mouse_report_t report =
|
||||
{
|
||||
.buttons = buttons,
|
||||
.x = x,
|
||||
.y = y,
|
||||
.wheel = scroll,
|
||||
// .pan = pan
|
||||
};
|
||||
|
||||
return hidd_mouse_report( &report );
|
||||
}
|
||||
|
||||
bool tud_hid_mouse_move(int8_t x, int8_t y)
|
||||
{
|
||||
hidd_interface_t * p_hid = &_mse_itf;
|
||||
uint8_t prev_buttons = p_hid->report_buf[0];
|
||||
|
||||
return tud_hid_mouse_data(prev_buttons, x, y, 0, 0);
|
||||
}
|
||||
|
||||
bool tud_hid_mouse_scroll(int8_t vertical, int8_t horizontal)
|
||||
{
|
||||
hidd_interface_t * p_hid = &_mse_itf;
|
||||
uint8_t prev_buttons = p_hid->report_buf[0];
|
||||
|
||||
return tud_hid_mouse_data(prev_buttons, 0, 0, vertical, horizontal);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static inline hidd_interface_t* get_interface_by_edpt(uint8_t ep_addr)
|
||||
|
@ -122,10 +122,19 @@ ATTR_WEAK void tud_hid_keyboard_set_report_cb(hid_report_type_t report_type, uin
|
||||
bool tud_hid_mouse_ready(void);
|
||||
|
||||
bool tud_hid_mouse_data(uint8_t buttons, int8_t x, int8_t y, int8_t scroll, int8_t pan);
|
||||
bool tud_hid_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan);
|
||||
|
||||
bool tud_hid_mouse_button_press(uint8_t buttons);
|
||||
bool tud_hid_mouse_button_release(uint8_t buttons);
|
||||
bool tud_hid_mouse_move(int8_t x, int8_t y);
|
||||
bool tud_hid_mouse_scroll(int8_t vertical, int8_t horizontal);
|
||||
|
||||
static inline bool tud_hid_mouse_button_press(uint8_t buttons)
|
||||
{
|
||||
return tud_hid_mouse_data(buttons, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
static inline bool tud_hid_mouse_button_release(void)
|
||||
{
|
||||
return tud_hid_mouse_data(0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/*------------- Callbacks -------------*/
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user