@@ -72,6 +72,16 @@ bool tud_hid_n_keyboard_report(uint8_t instance, uint8_t report_id, uint8_t modi
72
72
// use template layout report as defined by hid_mouse_report_t
73
73
bool 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 );
74
74
75
+ // ABSOLUTE MOUSE: convenient helper to send absolute mouse report if application
76
+ // use template layout report as defined by hid_abs_mouse_report_t
77
+ bool tud_hid_n_abs_mouse_report (uint8_t instance , uint8_t report_id , uint8_t buttons , int16_t x , int16_t y , int8_t vertical , int8_t horizontal );
78
+
79
+
80
+ static inline bool tud_hid_abs_mouse_report (uint8_t report_id , uint8_t buttons , int16_t x , int16_t y , int8_t vertical , int8_t horizontal )
81
+ {
82
+ return tud_hid_n_abs_mouse_report (0 , report_id , buttons , x , y , vertical , horizontal );
83
+ }
84
+
75
85
// Gamepad: convenient helper to send gamepad report if application
76
86
// use template layout report TUD_HID_REPORT_DESC_GAMEPAD
77
87
bool 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 );
@@ -266,6 +276,55 @@ static inline bool tud_hid_gamepad_report(uint8_t report_id, int8_t x, int8_t y
266
276
HID_COLLECTION_END , \
267
277
HID_COLLECTION_END \
268
278
279
+ // Absolute Mouse Report Descriptor Template
280
+ #define TUD_HID_REPORT_DESC_ABSMOUSE (...) \
281
+ HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
282
+ HID_USAGE ( HID_USAGE_DESKTOP_MOUSE ) ,\
283
+ HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
284
+ /* Report ID if any */ \
285
+ __VA_ARGS__ \
286
+ HID_USAGE ( HID_USAGE_DESKTOP_POINTER ) ,\
287
+ HID_COLLECTION ( HID_COLLECTION_PHYSICAL ) ,\
288
+ HID_USAGE_PAGE ( HID_USAGE_PAGE_BUTTON ) ,\
289
+ HID_USAGE_MIN ( 1 ) ,\
290
+ HID_USAGE_MAX ( 5 ) ,\
291
+ HID_LOGICAL_MIN ( 0 ) ,\
292
+ HID_LOGICAL_MAX ( 1 ) ,\
293
+ /* Left, Right, Middle, Backward, Forward buttons */ \
294
+ HID_REPORT_COUNT ( 5 ) ,\
295
+ HID_REPORT_SIZE ( 1 ) ,\
296
+ HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,\
297
+ /* 3 bit padding */ \
298
+ HID_REPORT_COUNT ( 1 ) ,\
299
+ HID_REPORT_SIZE ( 3 ) ,\
300
+ HID_INPUT ( HID_CONSTANT ) ,\
301
+ HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
302
+ /* X, Y absolute position [0, 32767] */ \
303
+ HID_USAGE ( HID_USAGE_DESKTOP_X ) ,\
304
+ HID_USAGE ( HID_USAGE_DESKTOP_Y ) ,\
305
+ HID_LOGICAL_MIN ( 0x00 ) ,\
306
+ HID_LOGICAL_MAX_N ( 0x7FFF , 2 ) ,\
307
+ HID_REPORT_SIZE ( 16 ) ,\
308
+ HID_REPORT_COUNT ( 2 ) ,\
309
+ HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,\
310
+ /* Vertical wheel scroll [-127, 127] */ \
311
+ HID_USAGE ( HID_USAGE_DESKTOP_WHEEL ) ,\
312
+ HID_LOGICAL_MIN ( 0x81 ) ,\
313
+ HID_LOGICAL_MAX ( 0x7f ) ,\
314
+ HID_REPORT_COUNT ( 1 ) ,\
315
+ HID_REPORT_SIZE ( 8 ) ,\
316
+ HID_INPUT ( HID_DATA | HID_VARIABLE | HID_RELATIVE ) ,\
317
+ HID_USAGE_PAGE ( HID_USAGE_PAGE_CONSUMER ), \
318
+ /* Horizontal wheel scroll [-127, 127] */ \
319
+ HID_USAGE_N ( HID_USAGE_CONSUMER_AC_PAN , 2 ), \
320
+ HID_LOGICAL_MIN ( 0x81 ), \
321
+ HID_LOGICAL_MAX ( 0x7f ), \
322
+ HID_REPORT_COUNT ( 1 ), \
323
+ HID_REPORT_SIZE ( 8 ), \
324
+ HID_INPUT ( HID_DATA | HID_VARIABLE | HID_RELATIVE ), \
325
+ HID_COLLECTION_END , \
326
+ HID_COLLECTION_END \
327
+
269
328
// Consumer Control Report Descriptor Template
270
329
#define TUD_HID_REPORT_DESC_CONSUMER (...) \
271
330
HID_USAGE_PAGE ( HID_USAGE_PAGE_CONSUMER ) ,\
0 commit comments