summaryrefslogtreecommitdiff
path: root/src/class/hid/hid_device.h
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2020-10-09 21:25:17 +0700
committerGitHub <[email protected]>2020-10-09 21:25:17 +0700
commit8a07b9b9c02248fa2bcb809ee6f7949fcd38e217 (patch)
treec5f21fda499641a7ac7315bfb5a47e0346d5dfcf /src/class/hid/hid_device.h
parent6f8d0d2c34c61adc7c5202a67eaad69bb7c0f727 (diff)
parent3fd38ddf0493f84eb3124aacf9ccd7c76643a2c9 (diff)
Merge pull request #532 from hathach/house-keeping
House keeping
Diffstat (limited to 'src/class/hid/hid_device.h')
-rw-r--r--src/class/hid/hid_device.h35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/class/hid/hid_device.h b/src/class/hid/hid_device.h
index 4b8cb17d5..d5b5b7296 100644
--- a/src/class/hid/hid_device.h
+++ b/src/class/hid/hid_device.h
@@ -84,39 +84,42 @@ static inline bool tud_hid_mouse_report(uint8_t report_id, uint8_t buttons, int8
// Callbacks (Weak is optional)
//--------------------------------------------------------------------+
+#if CFG_TUD_HID > 1
+
// Invoked when received GET HID REPORT DESCRIPTOR request
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
-#if CFG_TUD_HID>1
-uint8_t const * tud_hid_n_descriptor_report_cb(uint8_t itf);
-#else
-uint8_t const * tud_hid_descriptor_report_cb(void);
-#endif
+uint8_t const * tud_hid_descriptor_report_cb(uint8_t itf);
// Invoked when received GET_REPORT control request
// Application must fill buffer report's content and return its length.
// Return zero will cause the stack to STALL request
-#if CFG_TUD_HID>1
-uint16_t tud_hid_n_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen);
-#else
-uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen);
-#endif
+uint16_t tud_hid_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen);
// Invoked when received SET_REPORT control request or
// received data on OUT endpoint ( Report ID = 0, Type = 0 )
-#if CFG_TUD_HID>1
-void tud_hid_n_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize);
-#else
-void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize);
-#endif
+void tud_hid_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize);
// Invoked when received SET_PROTOCOL request ( mode switch Boot <-> Report )
-TU_ATTR_WEAK void tud_hid_boot_mode_cb(uint8_t boot_mode);
+TU_ATTR_WEAK void tud_hid_boot_mode_cb(uint8_t itf, uint8_t boot_mode);
// Invoked when received SET_IDLE request. return false will stall the request
// - Idle Rate = 0 : only send report if there is changes, i.e skip duplication
// - Idle Rate > 0 : skip duplication, but send at least 1 report every idle rate (in unit of 4 ms).
+TU_ATTR_WEAK bool tud_hid_set_idle_cb(uint8_t itf, uint8_t idle_rate);
+
+#else
+
+// TODO for backward compatible callback, remove later when appropriate
+uint8_t const * tud_hid_descriptor_report_cb(void);
+uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen);
+void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize);
+
+TU_ATTR_WEAK void tud_hid_boot_mode_cb(uint8_t boot_mode);
TU_ATTR_WEAK bool tud_hid_set_idle_cb(uint8_t idle_rate);
+#endif
+
+
//--------------------------------------------------------------------+
// Inline Functions
//--------------------------------------------------------------------+