Pull request changes

Remove configuration options and just bump number of buttons to 32
Fix button numbereing and comments in
This commit is contained in:
Marcelo Bezerra 2021-06-08 09:24:50 +02:00
parent 89a53457d4
commit 05d30b0c37
4 changed files with 19 additions and 51 deletions

View File

@ -104,10 +104,6 @@
// HID buffer size Should be sufficient to hold ID (if any) + Data
#define CFG_TUD_HID_EP_BUFSIZE 16
// Number of button on the gamepad 16 or 32
#define CFG_TUD_MAX_BUTTONS 16
#ifdef __cplusplus
}
#endif

View File

@ -150,18 +150,6 @@ typedef enum
/** @} */
#ifndef CFG_TUD_MAX_BUTTONS
#define CFG_TUD_MAX_BUTTONS 16
#endif
#if (CFG_TUD_MAX_BUTTONS == 16)
typedef uint16_t hid_gamepad_buttons_t;
#elif (CFG_TUD_MAX_BUTTONS == 32)
typedef uint32_t hid_gamepad_buttons_t;
#else
#error "Invalid CFG_TUD_MAX_BUTTONS value."
#endif
//--------------------------------------------------------------------+
// GAMEPAD
//--------------------------------------------------------------------+
@ -213,7 +201,7 @@ typedef struct TU_ATTR_PACKED
int8_t rx; ///< Delta Rx movement of analog left trigger
int8_t ry; ///< Delta Ry movement of analog right trigger
uint8_t hat; ///< Buttons mask for currently pressed buttons in the DPad/hat
hid_gamepad_buttons_t buttons; ///< Buttons mask for currently pressed buttons
uint32_t buttons; ///< Buttons mask for currently pressed buttons
}hid_gamepad_report_t;
/// Standard Gamepad Buttons Bitmap (from Linux input event codes)
@ -234,25 +222,23 @@ typedef enum
GAMEPAD_BUTTON_MODE = TU_BIT(12), ///< Mode button
GAMEPAD_BUTTON_THUMBL = TU_BIT(13), ///< L3 button
GAMEPAD_BUTTON_THUMBR = TU_BIT(14), ///< R3 button
GAMEPAD_BUTTON_15 = TU_BIT(15), ///< Button 15
#if (CFG_TUD_MAX_BUTTONS > 16)
GAMEPAD_BUTTON_16 = TU_BIT(15), ///< Button 15
GAMEPAD_BUTTON_17 = TU_BIT(16), ///< Button 17
GAMEPAD_BUTTON_18 = TU_BIT(17), ///< Button 16
GAMEPAD_BUTTON_19 = TU_BIT(18), ///< Button 16
GAMEPAD_BUTTON_20 = TU_BIT(19), ///< Button 16
GAMEPAD_BUTTON_21 = TU_BIT(20), ///< Button 16
GAMEPAD_BUTTON_22 = TU_BIT(21), ///< Button 16
GAMEPAD_BUTTON_23 = TU_BIT(22), ///< Button 16
GAMEPAD_BUTTON_24 = TU_BIT(23), ///< Button 16
GAMEPAD_BUTTON_25 = TU_BIT(24), ///< Button 16
GAMEPAD_BUTTON_26 = TU_BIT(25), ///< Button 16
GAMEPAD_BUTTON_27 = TU_BIT(26), ///< Button 16
GAMEPAD_BUTTON_28 = TU_BIT(27), ///< Button 16
GAMEPAD_BUTTON_29 = TU_BIT(28), ///< Button 16
GAMEPAD_BUTTON_30 = TU_BIT(29), ///< Button 16
GAMEPAD_BUTTON_31 = TU_BIT(30), ///< Button 16
GAMEPAD_BUTTON_32 = TU_BIT(31), ///< Button 16
#endif
GAMEPAD_BUTTON_18 = TU_BIT(17), ///< Button 18
GAMEPAD_BUTTON_19 = TU_BIT(18), ///< Button 19
GAMEPAD_BUTTON_20 = TU_BIT(19), ///< Button 20
GAMEPAD_BUTTON_21 = TU_BIT(20), ///< Button 21
GAMEPAD_BUTTON_22 = TU_BIT(21), ///< Button 22
GAMEPAD_BUTTON_23 = TU_BIT(22), ///< Button 23
GAMEPAD_BUTTON_24 = TU_BIT(23), ///< Button 24
GAMEPAD_BUTTON_25 = TU_BIT(24), ///< Button 25
GAMEPAD_BUTTON_26 = TU_BIT(25), ///< Button 26
GAMEPAD_BUTTON_27 = TU_BIT(26), ///< Button 27
GAMEPAD_BUTTON_28 = TU_BIT(27), ///< Button 28
GAMEPAD_BUTTON_29 = TU_BIT(28), ///< Button 29
GAMEPAD_BUTTON_30 = TU_BIT(29), ///< Button 30
GAMEPAD_BUTTON_31 = TU_BIT(30), ///< Button 31
GAMEPAD_BUTTON_32 = TU_BIT(31), ///< Button 32
}hid_gamepad_button_bm_t;
/// Standard Gamepad HAT/DPAD Buttons (from Linux input event codes)

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_TUD_MAX_BUTTONS ) ,\
HID_USAGE_MAX ( 32 ) ,\
HID_LOGICAL_MIN ( 0 ) ,\
HID_LOGICAL_MAX ( 1 ) ,\
HID_REPORT_COUNT ( CFG_TUD_MAX_BUTTONS ) ,\
HID_REPORT_COUNT ( 32 ) ,\
HID_REPORT_SIZE ( 1 ) ,\
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,\
HID_COLLECTION_END \

View File

@ -309,15 +309,6 @@
#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
//------------------------------------------------------------------
@ -325,11 +316,6 @@
#error Control Endpoint Max Packet Size cannot be larger than 64
#endif
#if (CFG_TUD_MAX_BUTTONS != 16 && CFG_TUD_MAX_BUTTONS != 32)
#error "Unsupported CFG_TUD_MAX_BUTTONS"
#endif
#endif /* _TUSB_OPTION_H_ */
/** @} */