Macro to keep mouse descriptors in sync

This commit is contained in:
Ellie T 2024-11-22 23:38:19 +11:00
parent 70f4991fba
commit 19de554505
1 changed files with 63 additions and 110 deletions

View File

@ -55,12 +55,12 @@
.iSerialNumber = 0x03,\ .iSerialNumber = 0x03,\
.bNumConfigurations = 0x01}\ .bNumConfigurations = 0x01}\
/* Common mouse descriptor. Use HID_RELATIVE or HID_ABSOLUTE for ABS_OR_REL. */
#define TUD_HID_REPORT_DESC_ABS_MOUSE(...) \ #define TUD_HID_REPORT_DESC_MOUSE_COMMON(ABS_OR_REL, MOUSE_MIN, ...)\
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\ HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
HID_USAGE ( HID_USAGE_DESKTOP_MOUSE ) ,\ HID_USAGE ( HID_USAGE_DESKTOP_MOUSE ) ,\
HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\ HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
/* Report ID */\ /* Report ID if any */\
__VA_ARGS__ \ __VA_ARGS__ \
HID_USAGE ( HID_USAGE_DESKTOP_POINTER ) ,\ HID_USAGE ( HID_USAGE_DESKTOP_POINTER ) ,\
HID_COLLECTION ( HID_COLLECTION_PHYSICAL ) ,\ HID_COLLECTION ( HID_COLLECTION_PHYSICAL ) ,\
@ -81,14 +81,14 @@ HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
HID_INPUT ( HID_CONSTANT ) ,\ HID_INPUT ( HID_CONSTANT ) ,\
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\ HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
\ \
/* X, Y absolute position [0, 32767] */ \ /* X, Y position [MOUSE_MIN, 32767] */ \
HID_USAGE ( HID_USAGE_DESKTOP_X ) ,\ HID_USAGE ( HID_USAGE_DESKTOP_X ) ,\
HID_USAGE ( HID_USAGE_DESKTOP_Y ) ,\ HID_USAGE ( HID_USAGE_DESKTOP_Y ) ,\
HID_LOGICAL_MIN ( 0x00 ) ,\ MOUSE_MIN ,\
HID_LOGICAL_MAX_N( 0x7FFF, 2 ) ,\ HID_LOGICAL_MAX_N( 0x7FFF, 2 ) ,\
HID_REPORT_SIZE ( 16 ) ,\ HID_REPORT_SIZE ( 16 ) ,\
HID_REPORT_COUNT ( 2 ) ,\ HID_REPORT_COUNT ( 2 ) ,\
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,\ HID_INPUT ( HID_DATA | HID_VARIABLE | ABS_OR_REL ) ,\
\ \
/* Vertical wheel scroll [-127, 127] */ \ /* Vertical wheel scroll [-127, 127] */ \
HID_USAGE ( HID_USAGE_DESKTOP_WHEEL ) ,\ HID_USAGE ( HID_USAGE_DESKTOP_WHEEL ) ,\
@ -114,6 +114,12 @@ HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
HID_COLLECTION_END , \ HID_COLLECTION_END , \
HID_COLLECTION_END \ HID_COLLECTION_END \
/* Absolute mouse, range=[0..32767] */
#define TUD_HID_REPORT_DESC_ABS_MOUSE(...) TUD_HID_REPORT_DESC_MOUSE_COMMON(HID_ABSOLUTE, HID_LOGICAL_MIN(0), __VA_ARGS__)
/* Relative mouse, range=[-32767..32767] */
#define TUD_HID_REPORT_DESC_MOUSEHELP(...) TUD_HID_REPORT_DESC_MOUSE_COMMON(HID_RELATIVE, HID_LOGICAL_MIN_N(-32767, 2), __VA_ARGS__)
// Consumer Control Report Descriptor Template // Consumer Control Report Descriptor Template
#define TUD_HID_REPORT_DESC_CONSUMER_CTRL(...) \ #define TUD_HID_REPORT_DESC_CONSUMER_CTRL(...) \
HID_USAGE_PAGE ( HID_USAGE_PAGE_CONSUMER ) ,\ HID_USAGE_PAGE ( HID_USAGE_PAGE_CONSUMER ) ,\
@ -161,59 +167,6 @@ HID_COLLECTION_END \
HID_OUTPUT ( HID_DATA | HID_ARRAY | HID_ABSOLUTE ) ,\ HID_OUTPUT ( HID_DATA | HID_ARRAY | HID_ABSOLUTE ) ,\
HID_COLLECTION_END \ HID_COLLECTION_END \
#define TUD_HID_REPORT_DESC_MOUSEHELP(...) \
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
HID_USAGE ( HID_USAGE_DESKTOP_MOUSE ) ,\
HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
/* Report ID if any */\
__VA_ARGS__ \
HID_USAGE ( HID_USAGE_DESKTOP_POINTER ) ,\
HID_COLLECTION ( HID_COLLECTION_PHYSICAL ) ,\
HID_USAGE_PAGE ( HID_USAGE_PAGE_BUTTON ) ,\
HID_USAGE_MIN ( 1 ) ,\
HID_USAGE_MAX ( 5 ) ,\
HID_LOGICAL_MIN ( 0 ) ,\
HID_LOGICAL_MAX ( 1 ) ,\
/* Left, Right, Middle, Backward, Forward buttons */ \
HID_REPORT_COUNT( 5 ) ,\
HID_REPORT_SIZE ( 1 ) ,\
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,\
/* 3 bit padding */ \
HID_REPORT_COUNT( 1 ) ,\
HID_REPORT_SIZE ( 3 ) ,\
HID_INPUT ( HID_CONSTANT ) ,\
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ) ,\
/* X, Y position [-32767, 32767] */ \
HID_USAGE ( HID_USAGE_DESKTOP_X ) ,\
HID_USAGE ( HID_USAGE_DESKTOP_Y ) ,\
HID_LOGICAL_MIN_N ( 0x8000, 2 ) ,\
HID_LOGICAL_MAX_N ( 0x7fff, 2 ) ,\
HID_REPORT_SIZE ( 16 ) ,\
HID_REPORT_COUNT( 2 ) ,\
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_RELATIVE ) ,\
/* Vertical wheel scroll [-127, 127] */ \
HID_USAGE ( HID_USAGE_DESKTOP_WHEEL ) ,\
HID_LOGICAL_MIN ( 0x81 ) ,\
HID_LOGICAL_MAX ( 0x7f ) ,\
HID_REPORT_COUNT( 1 ) ,\
HID_REPORT_SIZE ( 8 ) ,\
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_RELATIVE ) ,\
/* Horizontal wheel (AC Pan) */ \
HID_USAGE_PAGE ( HID_USAGE_PAGE_CONSUMER ) ,\
HID_LOGICAL_MIN ( 0x81 ) ,\
HID_LOGICAL_MAX ( 0x7f ) ,\
HID_REPORT_COUNT( 1 ) ,\
HID_REPORT_SIZE ( 8 ) ,\
HID_USAGE_N ( HID_USAGE_CONSUMER_AC_PAN, 2 ) ,\
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_RELATIVE ) ,\
\
/* Mouse mode (0 = absolute, 1 = relative) */ \
HID_REPORT_COUNT( 1 ), \
HID_REPORT_SIZE ( 8 ), \
HID_INPUT ( HID_CONSTANT ), \
HID_COLLECTION_END , \
HID_COLLECTION_END \
#define HID_USAGE_DIGITIZER 0x01 #define HID_USAGE_DIGITIZER 0x01
#define TUD_HID_REPORT_DESC_DIGITIZER_PEN(...) \ #define TUD_HID_REPORT_DESC_DIGITIZER_PEN(...) \