This commit is contained in:
Marcelo Bezerra 2021-06-07 20:16:05 +02:00 committed by hathach
parent d5f8da44d1
commit 3842c806a6
3 changed files with 21 additions and 16 deletions

View File

@ -152,20 +152,16 @@ typedef enum
/** @} */
#ifndef CFG_TUD_HID_EP_BUFSIZE
#define CFG_TUD_HID_EP_BUFSIZE 64
#ifndef CFG_TUD_MAX_BUTTONS
#define CFG_TUD_MAX_BUTTONS 16
#endif
#ifndef CFG_TUSB_MAX_BUTTONS
#define CFG_TUSB_MAX_BUTTONS 16
#endif
#if (CFG_TUSB_MAX_BUTTONS == 16)
#if (CFG_TUD_MAX_BUTTONS == 16)
typedef uint16_t hid_gamepad_buttons_t;
#elif (CFG_TUSB_MAX_BUTTONS == 32)
#elif (CFG_TUD_MAX_BUTTONS == 32)
typedef uint32_t hid_gamepad_buttons_t;
#else
#error "Invalid CFG_TUSB_MAX_BUTTONS value."
#error "Invalid CFG_TUD_MAX_BUTTONS value."
#endif
//--------------------------------------------------------------------+
@ -241,7 +237,7 @@ typedef enum
GAMEPAD_BUTTON_THUMBL = TU_BIT(13), ///< L3 button
GAMEPAD_BUTTON_THUMBR = TU_BIT(14), ///< R3 button
GAMEPAD_BUTTON_15 = TU_BIT(15), ///< Button 15
#ifdef CFG_TUSB_MAX_BUTTONS_32
#if (CFG_TUD_MAX_BUTTONS > 16)
GAMEPAD_BUTTON_17 = TU_BIT(16), ///< Button 17
GAMEPAD_BUTTON_18 = TU_BIT(17), ///< Button 16
GAMEPAD_BUTTON_19 = TU_BIT(18), ///< Button 16

View File

@ -343,10 +343,10 @@ static inline bool tud_hid_gamepad_report(uint8_t report_id, int8_t x, int8_t y
/* 16 bit Button Map */ \
HID_USAGE_PAGE ( HID_USAGE_PAGE_BUTTON ) ,\
HID_USAGE_MIN ( 1 ) ,\
HID_USAGE_MAX ( CFG_TUSB_MAX_BUTTONS ) ,\
HID_USAGE_MAX ( CFG_TUD_MAX_BUTTONS ) ,\
HID_LOGICAL_MIN ( 0 ) ,\
HID_LOGICAL_MAX ( 1 ) ,\
HID_REPORT_COUNT ( CFG_TUSB_MAX_BUTTONS ) ,\
HID_REPORT_COUNT ( CFG_TUD_MAX_BUTTONS ) ,\
HID_REPORT_SIZE ( 1 ) ,\
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,\
HID_COLLECTION_END \

View File

@ -309,6 +309,16 @@
#define TUP_MCU_STRICT_ALIGN 0
#endif
//--------------------------------------------------------------------+
// HID Gamepad options
//--------------------------------------------------------------------+
// CFG_TUD_MAX_BUTTONS lets you choose if you want 16 or 32 buttons on you HID gamepad
#ifndef CFG_TUD_MAX_BUTTONS
#define CFG_TUD_MAX_BUTTONS 16
#endif
//------------------------------------------------------------------
// Configuration Validation
//------------------------------------------------------------------
@ -316,10 +326,9 @@
#error Control Endpoint Max Packet Size cannot be larger than 64
#endif
#ifndef TUD_OPT_GAMEPAD_32_BUTTONS
#define CFG_TUSB_MAX_BUTTONS 16
#else
#define CFG_TUSB_MAX_BUTTONS 32
#if (CFG_TUD_MAX_BUTTONS != 16 && CFG_TUD_MAX_BUTTONS != 32)
#error "Unsupported CFG_TUD_MAX_BUTTONS"
#endif
#endif /* _TUSB_OPTION_H_ */