@@ -84,35 +84,38 @@ static const uint8_t output_reports[] = {
84
84
REPORT_ID_KEYBOARD_LEDS ,
85
85
};
86
86
87
- /* Internal definitions used to calculate size of the biggest supported HID input report. */
88
- #define _REPORT_BUFFER_SIZE_MOUSE \
89
- (IS_ENABLED(CONFIG_DESKTOP_HID_REPORT_MOUSE_SUPPORT) ? (REPORT_SIZE_MOUSE) : (0))
90
- #define _REPORT_BUFFER_SIZE_KEYBOARD_KEYS \
91
- (IS_ENABLED(CONFIG_DESKTOP_HID_REPORT_KEYBOARD_SUPPORT) ? (REPORT_SIZE_KEYBOARD_KEYS) : (0))
92
- #define _REPORT_BUFFER_SIZE_SYSTEM_CTRL \
93
- (IS_ENABLED(CONFIG_DESKTOP_HID_REPORT_SYSTEM_CTRL_SUPPORT) ? \
94
- (REPORT_SIZE_SYSTEM_CTRL) : (0))
95
- #define _REPORT_BUFFER_SIZE_CONSUMER_CTRL \
96
- (IS_ENABLED(CONFIG_DESKTOP_HID_REPORT_CONSUMER_CTRL_SUPPORT) ? \
97
- (REPORT_SIZE_CONSUMER_CTRL) : (0))
98
- #define _REPORT_BUFFER_SIZE_BOOT_MOUSE \
99
- (IS_ENABLED(CONFIG_DESKTOP_HID_BOOT_INTERFACE_MOUSE) ? (REPORT_SIZE_MOUSE_BOOT) : (0))
100
- #define _REPORT_BUFFER_SIZE_BOOT_KEYBOARD \
101
- (IS_ENABLED(CONFIG_DESKTOP_HID_BOOT_INTERFACE_KEYBOARD) ? (REPORT_SIZE_KEYBOARD_BOOT) : (0))
102
- #define _MAX6 (a , b , c , d , e , f ) MAX(MAX(a, b), MAX(MAX(c, d), MAX(e, f)))
87
+ union _input_report_size_max {
88
+ #if CONFIG_DESKTOP_HID_REPORT_MOUSE_SUPPORT || CONFIG_DESKTOP_HID_BOOT_INTERFACE_MOUSE
89
+ uint8_t _mouse_report [REPORT_SIZE_MOUSE ];
90
+ #endif
91
+ #if CONFIG_DESKTOP_HID_REPORT_KEYBOARD_SUPPORT || CONFIG_DESKTOP_HID_BOOT_INTERFACE_KEYBOARD
92
+ uint8_t _keyboard_report [REPORT_SIZE_KEYBOARD_KEYS ];
93
+ #endif
94
+ #if CONFIG_DESKTOP_HID_REPORT_SYSTEM_CTRL_SUPPORT
95
+ uint8_t _sysctrl_report [REPORT_SIZE_SYSTEM_CTRL ];
96
+ #endif
97
+ #if CONFIG_DESKTOP_HID_REPORT_CONSUMER_CTRL_SUPPORT
98
+ uint8_t _consumerctrl_report [REPORT_SIZE_CONSUMER_CTRL ];
99
+ #endif
100
+ #if CONFIG_DESKTOP_HID_BOOT_INTERFACE_MOUSE
101
+ uint8_t _boot_mouse_report [REPORT_SIZE_MOUSE_BOOT ];
102
+ #endif
103
+ #if CONFIG_DESKTOP_HID_BOOT_INTERFACE_KEYBOARD
104
+ uint8_t _boot_keyboard_report [REPORT_SIZE_KEYBOARD_BOOT ];
105
+ #endif
106
+ };
103
107
104
- /* Size of the biggest supported HID input report that is part of input reports map. */
105
- #define REPORT_BUFFER_SIZE_INPUT_REPORT \
106
- _MAX6(_REPORT_BUFFER_SIZE_MOUSE, _REPORT_BUFFER_SIZE_KEYBOARD_KEYS, \
107
- _REPORT_BUFFER_SIZE_SYSTEM_CTRL, _REPORT_BUFFER_SIZE_CONSUMER_CTRL, \
108
- _REPORT_BUFFER_SIZE_BOOT_MOUSE, _REPORT_BUFFER_SIZE_BOOT_KEYBOARD)
108
+ union _output_report_size_max {
109
+ #if CONFIG_DESKTOP_HID_REPORT_KEYBOARD_SUPPORT
110
+ uint8_t _keyboard_report [ REPORT_SIZE_KEYBOARD_LEDS ];
111
+ #endif
112
+ };
109
113
110
- /* Internal definitions used to calculate size of the biggest supported HID output report. */
111
- #define _REPORT_BUFFER_SIZE_KEYBOARD_LEDS \
112
- (IS_ENABLED(CONFIG_DESKTOP_HID_REPORT_KEYBOARD_SUPPORT) ? (REPORT_SIZE_KEYBOARD_LEDS) : (0))
114
+ /* Size of the biggest supported HID input report that is part of input reports map. */
115
+ #define REPORT_BUFFER_SIZE_INPUT_REPORT sizeof(union _input_report_size_max)
113
116
114
117
/* Size of the biggest supported HID output report that is part of output reports map. */
115
- #define REPORT_BUFFER_SIZE_OUTPUT_REPORT _REPORT_BUFFER_SIZE_KEYBOARD_LEDS
118
+ #define REPORT_BUFFER_SIZE_OUTPUT_REPORT sizeof(union _output_report_size_max)
116
119
117
120
extern const uint8_t hid_report_desc [];
118
121
extern const size_t hid_report_desc_size ;
0 commit comments