add TUD_ to HID_REPORT_DESC_* template
This commit is contained in:
@@ -78,5 +78,6 @@ TinyUSB is currently used by these other projects:
|
|||||||
* [Adafruit nRF52 Arduino](https://github.com/adafruit/Adafruit_nRF52_Arduino)
|
* [Adafruit nRF52 Arduino](https://github.com/adafruit/Adafruit_nRF52_Arduino)
|
||||||
* [Adafruit nRF52 Bootloader](https://github.com/adafruit/Adafruit_nRF52_Bootloader)
|
* [Adafruit nRF52 Bootloader](https://github.com/adafruit/Adafruit_nRF52_Bootloader)
|
||||||
* [CircuitPython](https://github.com/adafruit/circuitpython)
|
* [CircuitPython](https://github.com/adafruit/circuitpython)
|
||||||
|
* [TinyUSB Arduino Library](https://github.com/adafruit/Adafruit_TinyUSB_Arduino)
|
||||||
|
|
||||||
If your project also uses TinyUSB and want to share, feel free to create a pull request.
|
If your project also uses TinyUSB and want to share, feel free to create a pull request.
|
||||||
|
@@ -76,8 +76,8 @@ enum
|
|||||||
|
|
||||||
uint8_t const desc_hid_report[] =
|
uint8_t const desc_hid_report[] =
|
||||||
{
|
{
|
||||||
HID_REPORT_DESC_KEYBOARD( HID_REPORT_ID(REPORT_ID_KEYBOARD), ),
|
TUD_HID_REPORT_DESC_KEYBOARD( HID_REPORT_ID(REPORT_ID_KEYBOARD), ),
|
||||||
HID_REPORT_DESC_MOUSE ( HID_REPORT_ID(REPORT_ID_MOUSE), )
|
TUD_HID_REPORT_DESC_MOUSE ( HID_REPORT_ID(REPORT_ID_MOUSE), )
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -76,8 +76,8 @@ enum
|
|||||||
|
|
||||||
uint8_t const desc_hid_report[] =
|
uint8_t const desc_hid_report[] =
|
||||||
{
|
{
|
||||||
HID_REPORT_DESC_KEYBOARD( HID_REPORT_ID(REPORT_ID_KEYBOARD), ),
|
TUD_HID_REPORT_DESC_KEYBOARD( HID_REPORT_ID(REPORT_ID_KEYBOARD), ),
|
||||||
HID_REPORT_DESC_MOUSE ( HID_REPORT_ID(REPORT_ID_MOUSE), )
|
TUD_HID_REPORT_DESC_MOUSE ( HID_REPORT_ID(REPORT_ID_MOUSE), )
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -64,7 +64,7 @@ uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type,
|
|||||||
void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize);
|
void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize);
|
||||||
|
|
||||||
// Invoked when host switch mode Boot <-> Report via SET_PROTOCOL request
|
// Invoked when host switch mode Boot <-> Report via SET_PROTOCOL request
|
||||||
void tud_hid_mode_changed_cb(uint8_t boot_mode) ATTR_WEAK;
|
ATTR_WEAK void tud_hid_mode_changed_cb(uint8_t boot_mode);
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// KEYBOARD API
|
// KEYBOARD API
|
||||||
@@ -107,18 +107,18 @@ static inline bool tud_hid_mouse_button_release(uint8_t report_id)
|
|||||||
* empty if multiple reports is not used
|
* empty if multiple reports is not used
|
||||||
*
|
*
|
||||||
* - Only 1 report: no parameter
|
* - Only 1 report: no parameter
|
||||||
* uint8_t const report_desc[] = { HID_REPORT_DESC_KEYBOARD() };
|
* uint8_t const report_desc[] = { TUD_HID_REPORT_DESC_KEYBOARD() };
|
||||||
*
|
*
|
||||||
* - Multiple Reports: "HID_REPORT_ID(ID)," must be passed to template
|
* - Multiple Reports: "HID_REPORT_ID(ID)," must be passed to template
|
||||||
* uint8_t const report_desc[] =
|
* uint8_t const report_desc[] =
|
||||||
* {
|
* {
|
||||||
* HID_REPORT_DESC_KEYBOARD( HID_REPORT_ID(1), ) ,
|
* TUD_HID_REPORT_DESC_KEYBOARD( HID_REPORT_ID(1), ) ,
|
||||||
* HID_REPORT_DESC_MOUSE ( HID_REPORT_ID(2), )
|
* TUD_HID_REPORT_DESC_MOUSE ( HID_REPORT_ID(2), )
|
||||||
* };
|
* };
|
||||||
*--------------------------------------------------------------------*/
|
*--------------------------------------------------------------------*/
|
||||||
|
|
||||||
// Keyboard Report Descriptor Template
|
// Keyboard Report Descriptor Template
|
||||||
#define HID_REPORT_DESC_KEYBOARD(...) \
|
#define TUD_HID_REPORT_DESC_KEYBOARD(...) \
|
||||||
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
|
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
|
||||||
HID_USAGE ( HID_USAGE_DESKTOP_KEYBOARD ) ,\
|
HID_USAGE ( HID_USAGE_DESKTOP_KEYBOARD ) ,\
|
||||||
HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
|
HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
|
||||||
@@ -159,7 +159,7 @@ static inline bool tud_hid_mouse_button_release(uint8_t report_id)
|
|||||||
HID_COLLECTION_END \
|
HID_COLLECTION_END \
|
||||||
|
|
||||||
// Mouse Report Descriptor Template
|
// Mouse Report Descriptor Template
|
||||||
#define HID_REPORT_DESC_MOUSE(...) \
|
#define TUD_HID_REPORT_DESC_MOUSE(...) \
|
||||||
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
|
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
|
||||||
HID_USAGE ( HID_USAGE_DESKTOP_MOUSE ) ,\
|
HID_USAGE ( HID_USAGE_DESKTOP_MOUSE ) ,\
|
||||||
HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
|
HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
|
||||||
@@ -199,7 +199,7 @@ static inline bool tud_hid_mouse_button_release(uint8_t report_id)
|
|||||||
HID_COLLECTION_END \
|
HID_COLLECTION_END \
|
||||||
|
|
||||||
// Consumer Control Report Descriptor Template
|
// Consumer Control Report Descriptor Template
|
||||||
#define HID_REPORT_DESC_CONSUMER(...) \
|
#define TUD_HID_REPORT_DESC_CONSUMER(...) \
|
||||||
HID_USAGE_PAGE ( HID_USAGE_PAGE_CONSUMER ) ,\
|
HID_USAGE_PAGE ( HID_USAGE_PAGE_CONSUMER ) ,\
|
||||||
HID_USAGE ( HID_USAGE_CONSUMER_CONTROL ) ,\
|
HID_USAGE ( HID_USAGE_CONSUMER_CONTROL ) ,\
|
||||||
HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
|
HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
|
||||||
@@ -219,7 +219,7 @@ static inline bool tud_hid_mouse_button_release(uint8_t report_id)
|
|||||||
* 0x02 - Standby
|
* 0x02 - Standby
|
||||||
* 0x04 - Wake Host
|
* 0x04 - Wake Host
|
||||||
*/
|
*/
|
||||||
#define HID_REPORT_DESC_SYSTEM_CONTROL(...) \
|
#define TUD_HID_REPORT_DESC_SYSTEM_CONTROL(...) \
|
||||||
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
|
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
|
||||||
HID_USAGE ( HID_USAGE_DESKTOP_SYSTEM_CONTROL ) ,\
|
HID_USAGE ( HID_USAGE_DESKTOP_SYSTEM_CONTROL ) ,\
|
||||||
HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
|
HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
|
||||||
@@ -242,7 +242,7 @@ static inline bool tud_hid_mouse_button_release(uint8_t report_id)
|
|||||||
// Gamepad Report Descriptor Template
|
// Gamepad Report Descriptor Template
|
||||||
// with 16 buttons and 2 joysticks with following layout
|
// with 16 buttons and 2 joysticks with following layout
|
||||||
// | Button Map (2 bytes) | X | Y | Z | Rz
|
// | Button Map (2 bytes) | X | Y | Z | Rz
|
||||||
#define HID_REPORT_DESC_GAMEPAD(...) \
|
#define TUD_HID_REPORT_DESC_GAMEPAD(...) \
|
||||||
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
|
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
|
||||||
HID_USAGE ( HID_USAGE_DESKTOP_GAMEPAD ) ,\
|
HID_USAGE ( HID_USAGE_DESKTOP_GAMEPAD ) ,\
|
||||||
HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
|
HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
|
||||||
|
@@ -163,9 +163,12 @@ bool mscd_control_request(uint8_t rhport, tusb_control_request_t const * p_reque
|
|||||||
|
|
||||||
case MSC_REQ_GET_MAX_LUN:
|
case MSC_REQ_GET_MAX_LUN:
|
||||||
{
|
{
|
||||||
|
uint8_t maxlun = 1;
|
||||||
|
if (tud_msc_maxlun_cb) maxlun = tud_msc_maxlun_cb();
|
||||||
|
TU_VERIFY(maxlun);
|
||||||
|
|
||||||
// MAX LUN is minus 1 by specs
|
// MAX LUN is minus 1 by specs
|
||||||
uint8_t maxlun = 0;
|
maxlun--;
|
||||||
if (tud_msc_maxlun_cb) maxlun = tud_msc_maxlun_cb() -1;
|
|
||||||
|
|
||||||
usbd_control_xfer(rhport, p_request, &maxlun, 1);
|
usbd_control_xfer(rhport, p_request, &maxlun, 1);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user