27#ifndef _TUSB_HID_DEVICE_H_
28#define _TUSB_HID_DEVICE_H_
40#if !defined(CFG_TUD_HID_EP_BUFSIZE) & defined(CFG_TUD_HID_BUFSIZE)
43 #define CFG_TUD_HID_EP_BUFSIZE CFG_TUD_HID_BUFSIZE
46#ifndef CFG_TUD_HID_EP_BUFSIZE
47 #define CFG_TUD_HID_EP_BUFSIZE 64
56bool tud_hid_n_ready(uint8_t instance);
59uint8_t tud_hid_n_interface_protocol(uint8_t instance);
62uint8_t tud_hid_n_get_protocol(uint8_t instance);
65bool tud_hid_n_report(uint8_t instance, uint8_t report_id,
void const* report, uint16_t len);
69bool tud_hid_n_keyboard_report(uint8_t instance, uint8_t report_id, uint8_t modifier, uint8_t keycode[6]);
73bool tud_hid_n_mouse_report(uint8_t instance, uint8_t report_id, uint8_t buttons, int8_t x, int8_t y, int8_t vertical, int8_t horizontal);
77bool tud_hid_n_gamepad_report(uint8_t instance, uint8_t report_id, int8_t x, int8_t y, int8_t z, int8_t rz, int8_t rx, int8_t ry, uint8_t hat, uint32_t buttons);
82static inline bool tud_hid_ready(
void);
83static inline uint8_t tud_hid_interface_protocol(
void);
84static inline uint8_t tud_hid_get_protocol(
void);
85static inline bool tud_hid_report(uint8_t report_id,
void const* report, uint16_t len);
86static inline bool tud_hid_keyboard_report(uint8_t report_id, uint8_t modifier, uint8_t keycode[6]);
87static inline bool tud_hid_mouse_report(uint8_t report_id, uint8_t buttons, int8_t x, int8_t y, int8_t vertical, int8_t horizontal);
88static inline bool tud_hid_gamepad_report(uint8_t report_id, int8_t x, int8_t y, int8_t z, int8_t rz, int8_t rx, int8_t ry, uint8_t hat, uint32_t buttons);
96uint8_t
const * tud_hid_descriptor_report_cb(uint8_t instance);
101uint16_t tud_hid_get_report_cb(uint8_t instance, uint8_t report_id,
hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen);
105void tud_hid_set_report_cb(uint8_t instance, uint8_t report_id,
hid_report_type_t report_type, uint8_t
const* buffer, uint16_t bufsize);
109TU_ATTR_WEAK
void tud_hid_set_protocol_cb(uint8_t instance, uint8_t protocol);
114TU_ATTR_WEAK
bool tud_hid_set_idle_cb(uint8_t instance, uint8_t idle_rate);
119TU_ATTR_WEAK
void tud_hid_report_complete_cb(uint8_t instance, uint8_t
const* report, uint16_t len);
125static inline bool tud_hid_ready(
void)
127 return tud_hid_n_ready(0);
130static inline uint8_t tud_hid_interface_protocol(
void)
132 return tud_hid_n_interface_protocol(0);
135static inline uint8_t tud_hid_get_protocol(
void)
137 return tud_hid_n_get_protocol(0);
140static inline bool tud_hid_report(uint8_t report_id,
void const* report, uint16_t len)
142 return tud_hid_n_report(0, report_id, report, len);
145static inline bool tud_hid_keyboard_report(uint8_t report_id, uint8_t modifier, uint8_t keycode[6])
147 return tud_hid_n_keyboard_report(0, report_id, modifier, keycode);
150static inline bool tud_hid_mouse_report(uint8_t report_id, uint8_t buttons, int8_t x, int8_t y, int8_t vertical, int8_t horizontal)
152 return tud_hid_n_mouse_report(0, report_id, buttons, x, y, vertical, horizontal);
155static inline bool tud_hid_gamepad_report(uint8_t report_id, int8_t x, int8_t y, int8_t z, int8_t rz, int8_t rx, int8_t ry, uint8_t hat, uint32_t buttons)
157 return tud_hid_n_gamepad_report(0, report_id, x, y, z, rz, rx, ry, hat, buttons);
179#define TUD_HID_REPORT_DESC_KEYBOARD(...) \
180 HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
181 HID_USAGE ( HID_USAGE_DESKTOP_KEYBOARD ) ,\
182 HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
186 HID_USAGE_PAGE ( HID_USAGE_PAGE_KEYBOARD ) ,\
187 HID_USAGE_MIN ( 224 ) ,\
188 HID_USAGE_MAX ( 231 ) ,\
189 HID_LOGICAL_MIN ( 0 ) ,\
190 HID_LOGICAL_MAX ( 1 ) ,\
191 HID_REPORT_COUNT ( 8 ) ,\
192 HID_REPORT_SIZE ( 1 ) ,\
193 HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,\
195 HID_REPORT_COUNT ( 1 ) ,\
196 HID_REPORT_SIZE ( 8 ) ,\
197 HID_INPUT ( HID_CONSTANT ) ,\
199 HID_USAGE_PAGE ( HID_USAGE_PAGE_LED ) ,\
200 HID_USAGE_MIN ( 1 ) ,\
201 HID_USAGE_MAX ( 5 ) ,\
202 HID_REPORT_COUNT ( 5 ) ,\
203 HID_REPORT_SIZE ( 1 ) ,\
204 HID_OUTPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,\
206 HID_REPORT_COUNT ( 1 ) ,\
207 HID_REPORT_SIZE ( 3 ) ,\
208 HID_OUTPUT ( HID_CONSTANT ) ,\
210 HID_USAGE_PAGE ( HID_USAGE_PAGE_KEYBOARD ) ,\
211 HID_USAGE_MIN ( 0 ) ,\
212 HID_USAGE_MAX_N ( 255, 2 ) ,\
213 HID_LOGICAL_MIN ( 0 ) ,\
214 HID_LOGICAL_MAX_N( 255, 2 ) ,\
215 HID_REPORT_COUNT ( 6 ) ,\
216 HID_REPORT_SIZE ( 8 ) ,\
217 HID_INPUT ( HID_DATA | HID_ARRAY | HID_ABSOLUTE ) ,\
221#define TUD_HID_REPORT_DESC_MOUSE(...) \
222 HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
223 HID_USAGE ( HID_USAGE_DESKTOP_MOUSE ) ,\
224 HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
227 HID_USAGE ( HID_USAGE_DESKTOP_POINTER ) ,\
228 HID_COLLECTION ( HID_COLLECTION_PHYSICAL ) ,\
229 HID_USAGE_PAGE ( HID_USAGE_PAGE_BUTTON ) ,\
230 HID_USAGE_MIN ( 1 ) ,\
231 HID_USAGE_MAX ( 5 ) ,\
232 HID_LOGICAL_MIN ( 0 ) ,\
233 HID_LOGICAL_MAX ( 1 ) ,\
235 HID_REPORT_COUNT( 5 ) ,\
236 HID_REPORT_SIZE ( 1 ) ,\
237 HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,\
239 HID_REPORT_COUNT( 1 ) ,\
240 HID_REPORT_SIZE ( 3 ) ,\
241 HID_INPUT ( HID_CONSTANT ) ,\
242 HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
244 HID_USAGE ( HID_USAGE_DESKTOP_X ) ,\
245 HID_USAGE ( HID_USAGE_DESKTOP_Y ) ,\
246 HID_LOGICAL_MIN ( 0x81 ) ,\
247 HID_LOGICAL_MAX ( 0x7f ) ,\
248 HID_REPORT_COUNT( 2 ) ,\
249 HID_REPORT_SIZE ( 8 ) ,\
250 HID_INPUT ( HID_DATA | HID_VARIABLE | HID_RELATIVE ) ,\
252 HID_USAGE ( HID_USAGE_DESKTOP_WHEEL ) ,\
253 HID_LOGICAL_MIN ( 0x81 ) ,\
254 HID_LOGICAL_MAX ( 0x7f ) ,\
255 HID_REPORT_COUNT( 1 ) ,\
256 HID_REPORT_SIZE ( 8 ) ,\
257 HID_INPUT ( HID_DATA | HID_VARIABLE | HID_RELATIVE ) ,\
258 HID_USAGE_PAGE ( HID_USAGE_PAGE_CONSUMER ), \
260 HID_USAGE_N ( HID_USAGE_CONSUMER_AC_PAN, 2 ), \
261 HID_LOGICAL_MIN ( 0x81 ), \
262 HID_LOGICAL_MAX ( 0x7f ), \
263 HID_REPORT_COUNT( 1 ), \
264 HID_REPORT_SIZE ( 8 ), \
265 HID_INPUT ( HID_DATA | HID_VARIABLE | HID_RELATIVE ), \
266 HID_COLLECTION_END , \
270#define TUD_HID_REPORT_DESC_CONSUMER(...) \
271 HID_USAGE_PAGE ( HID_USAGE_PAGE_CONSUMER ) ,\
272 HID_USAGE ( HID_USAGE_CONSUMER_CONTROL ) ,\
273 HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
276 HID_LOGICAL_MIN ( 0x00 ) ,\
277 HID_LOGICAL_MAX_N( 0x03FF, 2 ) ,\
278 HID_USAGE_MIN ( 0x00 ) ,\
279 HID_USAGE_MAX_N ( 0x03FF, 2 ) ,\
280 HID_REPORT_COUNT ( 1 ) ,\
281 HID_REPORT_SIZE ( 16 ) ,\
282 HID_INPUT ( HID_DATA | HID_ARRAY | HID_ABSOLUTE ) ,\
291#define TUD_HID_REPORT_DESC_SYSTEM_CONTROL(...) \
292 HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
293 HID_USAGE ( HID_USAGE_DESKTOP_SYSTEM_CONTROL ) ,\
294 HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
298 HID_LOGICAL_MIN ( 1 ) ,\
299 HID_LOGICAL_MAX ( 3 ) ,\
300 HID_REPORT_COUNT ( 1 ) ,\
301 HID_REPORT_SIZE ( 2 ) ,\
302 HID_USAGE ( HID_USAGE_DESKTOP_SYSTEM_POWER_DOWN ) ,\
303 HID_USAGE ( HID_USAGE_DESKTOP_SYSTEM_SLEEP ) ,\
304 HID_USAGE ( HID_USAGE_DESKTOP_SYSTEM_WAKE_UP ) ,\
305 HID_INPUT ( HID_DATA | HID_ARRAY | HID_ABSOLUTE ) ,\
307 HID_REPORT_COUNT ( 1 ) ,\
308 HID_REPORT_SIZE ( 6 ) ,\
309 HID_INPUT ( HID_CONSTANT ) ,\
315#define TUD_HID_REPORT_DESC_GAMEPAD(...) \
316 HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
317 HID_USAGE ( HID_USAGE_DESKTOP_GAMEPAD ) ,\
318 HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
322 HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
323 HID_USAGE ( HID_USAGE_DESKTOP_X ) ,\
324 HID_USAGE ( HID_USAGE_DESKTOP_Y ) ,\
325 HID_USAGE ( HID_USAGE_DESKTOP_Z ) ,\
326 HID_USAGE ( HID_USAGE_DESKTOP_RZ ) ,\
327 HID_USAGE ( HID_USAGE_DESKTOP_RX ) ,\
328 HID_USAGE ( HID_USAGE_DESKTOP_RY ) ,\
329 HID_LOGICAL_MIN ( 0x81 ) ,\
330 HID_LOGICAL_MAX ( 0x7f ) ,\
331 HID_REPORT_COUNT ( 6 ) ,\
332 HID_REPORT_SIZE ( 8 ) ,\
333 HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,\
335 HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
336 HID_USAGE ( HID_USAGE_DESKTOP_HAT_SWITCH ) ,\
337 HID_LOGICAL_MIN ( 1 ) ,\
338 HID_LOGICAL_MAX ( 8 ) ,\
339 HID_PHYSICAL_MIN ( 0 ) ,\
340 HID_PHYSICAL_MAX_N ( 315, 2 ) ,\
341 HID_REPORT_COUNT ( 1 ) ,\
342 HID_REPORT_SIZE ( 8 ) ,\
343 HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,\
345 HID_USAGE_PAGE ( HID_USAGE_PAGE_BUTTON ) ,\
346 HID_USAGE_MIN ( 1 ) ,\
347 HID_USAGE_MAX ( 32 ) ,\
348 HID_LOGICAL_MIN ( 0 ) ,\
349 HID_LOGICAL_MAX ( 1 ) ,\
350 HID_REPORT_COUNT ( 32 ) ,\
351 HID_REPORT_SIZE ( 1 ) ,\
352 HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,\
358#define TUD_HID_REPORT_DESC_FIDO_U2F(report_size, ...) \
359 HID_USAGE_PAGE_N ( HID_USAGE_PAGE_FIDO, 2 ) ,\
360 HID_USAGE ( HID_USAGE_FIDO_U2FHID ) ,\
361 HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
365 HID_USAGE ( HID_USAGE_FIDO_DATA_IN ) ,\
366 HID_LOGICAL_MIN ( 0 ) ,\
367 HID_LOGICAL_MAX_N ( 0xff, 2 ) ,\
368 HID_REPORT_SIZE ( 8 ) ,\
369 HID_REPORT_COUNT ( report_size ) ,\
370 HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,\
372 HID_USAGE ( HID_USAGE_FIDO_DATA_OUT ) ,\
373 HID_LOGICAL_MIN ( 0 ) ,\
374 HID_LOGICAL_MAX_N ( 0xff, 2 ) ,\
375 HID_REPORT_SIZE ( 8 ) ,\
376 HID_REPORT_COUNT ( report_size ) ,\
377 HID_OUTPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,\
383#define TUD_HID_REPORT_DESC_GENERIC_INOUT(report_size, ...) \
384 HID_USAGE_PAGE_N ( HID_USAGE_PAGE_VENDOR, 2 ),\
386 HID_COLLECTION ( HID_COLLECTION_APPLICATION ),\
391 HID_LOGICAL_MIN ( 0x00 ),\
392 HID_LOGICAL_MAX_N ( 0xff, 2 ),\
393 HID_REPORT_SIZE ( 8 ),\
394 HID_REPORT_COUNT( report_size ),\
395 HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ),\
398 HID_LOGICAL_MIN ( 0x00 ),\
399 HID_LOGICAL_MAX_N ( 0xff, 2 ),\
400 HID_REPORT_SIZE ( 8 ),\
401 HID_REPORT_COUNT( report_size ),\
402 HID_OUTPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ),\
408void hidd_init (
void);
409void hidd_reset (uint8_t rhport);
412bool hidd_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes);
hid_report_type_t
HID Request Report Type.
Definition hid.h:85
AUDIO Channel Cluster Descriptor (4.1)
Definition audio.h:647