diff options
| author | hathach <[email protected]> | 2019-04-18 13:24:07 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2019-04-18 13:27:06 +0700 |
| commit | a30461b078445ab2d11319fade47789ecc866b7d (patch) | |
| tree | 7008b3b766561ee9aaeb7eabe5fdad6ecb269b11 /src/class/hid/hid_device.h | |
| parent | 8d2db4dd70c37bac426839717f9355da21d30c4c (diff) | |
update tud_hid_keyboard/mouse helper
Diffstat (limited to 'src/class/hid/hid_device.h')
| -rw-r--r-- | src/class/hid/hid_device.h | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/src/class/hid/hid_device.h b/src/class/hid/hid_device.h index b3fd53c1e..07121ab17 100644 --- a/src/class/hid/hid_device.h +++ b/src/class/hid/hid_device.h @@ -66,6 +66,7 @@ bool tud_hid_report(uint8_t report_id, void const* report, uint8_t len); bool tud_hid_boot_mode(void);
/*------------- Callbacks (Weak is optional) -------------*/
+
/** Callback invoked when USB host request \ref HID_REQ_CONTROL_GET_REPORT.
* \param[in] report_type specify which report (INPUT, OUTPUT, FEATURE) that host requests
* \param[out] buffer data that application need to update, value must be accessible by USB controller (see \ref CFG_TUSB_MEM_SECTION)
@@ -90,16 +91,22 @@ void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, ATTR_WEAK void tud_hid_mode_changed_cb(uint8_t boot_mode);
+
//--------------------------------------------------------------------+
// KEYBOARD API
+// Convenient helper to send keyboard report if application use standard/boot
+// layout report as defined by hid_keyboard_report_t
//--------------------------------------------------------------------+
-#if CFG_TUD_HID_KEYBOARD
-bool tud_hid_keyboard_keycode(uint8_t modifier, uint8_t keycode[6]);
-static inline bool tud_hid_keyboard_key_release(void) { return tud_hid_keyboard_keycode(0, NULL); }
+bool tud_hid_keyboard_report(uint8_t report_id, uint8_t modifier, uint8_t keycode[6]);
+
+static inline bool tud_hid_keyboard_key_release(uint8_t report_id)
+{
+ return tud_hid_keyboard_report(report_id, 0, NULL);
+}
#if CFG_TUD_HID_ASCII_TO_KEYCODE_LOOKUP
-bool tud_hid_keyboard_key_press(char ch);
+bool tud_hid_keyboard_key_press(uint8_t report_id, char ch);
typedef struct{
uint8_t shift;
@@ -108,30 +115,26 @@ typedef struct{ extern const hid_ascii_to_keycode_entry_t HID_ASCII_TO_KEYCODE[128];
#endif
-#endif
-
//--------------------------------------------------------------------+
// MOUSE API
+// Convenient helper to send mouse report if application use standard/boot
+// layout report as defined by hid_mouse_report_t
//--------------------------------------------------------------------+
-#if CFG_TUD_HID_MOUSE
-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);
-bool tud_hid_mouse_scroll(int8_t vertical, int8_t horizontal);
+bool tud_hid_mouse_report(uint8_t report_id, uint8_t buttons, int8_t x, int8_t y, int8_t scroll, int8_t pan);
+bool tud_hid_mouse_move(uint8_t report_id, int8_t x, int8_t y);
+bool tud_hid_mouse_scroll(uint8_t report_id, int8_t scroll, int8_t pan);
-static inline bool tud_hid_mouse_button_press(uint8_t buttons)
+static inline bool tud_hid_mouse_button_press(uint8_t report_id, uint8_t buttons)
{
- return tud_hid_mouse_data(buttons, 0, 0, 0, 0);
+ return tud_hid_mouse_report(report_id, buttons, 0, 0, 0, 0);
}
-static inline bool tud_hid_mouse_button_release(void)
+static inline bool tud_hid_mouse_button_release(uint8_t report_id)
{
- return tud_hid_mouse_data(0, 0, 0, 0, 0);
+ return tud_hid_mouse_report(report_id, 0, 0, 0, 0, 0);
}
-#endif
-
-
//--------------------------------------------------------------------+
// HID Report Descriptor Template
//--------------------------------------------------------------------+
|
