Add support for large Mouse Reports (#16371)
Co-authored-by: Sergey Vlasov <sigprof@gmail.com> Co-authored-by: Ryan <fauxpark@gmail.com>
This commit is contained in:
parent
84944df6a6
commit
0ab51ee29d
10 changed files with 123 additions and 39 deletions
|
@ -93,6 +93,11 @@ void host_mouse_send(report_mouse_t *report) {
|
|||
if (!driver) return;
|
||||
#ifdef MOUSE_SHARED_EP
|
||||
report->report_id = REPORT_ID_MOUSE;
|
||||
#endif
|
||||
#ifdef MOUSE_EXTENDED_REPORT
|
||||
// clip and copy to Boot protocol XY
|
||||
report->boot_x = (report->x > 127) ? 127 : ((report->x < -127) ? -127 : report->x);
|
||||
report->boot_y = (report->y > 127) ? 127 : ((report->y < -127) ? -127 : report->y);
|
||||
#endif
|
||||
(*driver->send_mouse)(report);
|
||||
}
|
||||
|
|
|
@ -201,15 +201,25 @@ typedef struct {
|
|||
uint32_t usage;
|
||||
} __attribute__((packed)) report_programmable_button_t;
|
||||
|
||||
#ifdef MOUSE_EXTENDED_REPORT
|
||||
typedef int16_t mouse_xy_report_t;
|
||||
#else
|
||||
typedef int8_t mouse_xy_report_t;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
#ifdef MOUSE_SHARED_EP
|
||||
uint8_t report_id;
|
||||
#endif
|
||||
uint8_t buttons;
|
||||
int8_t x;
|
||||
int8_t y;
|
||||
int8_t v;
|
||||
int8_t h;
|
||||
#ifdef MOUSE_EXTENDED_REPORT
|
||||
int8_t boot_x;
|
||||
int8_t boot_y;
|
||||
#endif
|
||||
mouse_xy_report_t x;
|
||||
mouse_xy_report_t y;
|
||||
int8_t v;
|
||||
int8_t h;
|
||||
} __attribute__((packed)) report_mouse_t;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -126,14 +126,27 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = {
|
|||
HID_RI_REPORT_SIZE(8, 0x01),
|
||||
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
|
||||
|
||||
// X/Y position (2 bytes)
|
||||
# ifdef MOUSE_EXTENDED_REPORT
|
||||
// Boot protocol XY ignored in Report protocol
|
||||
HID_RI_REPORT_COUNT(8, 0x02),
|
||||
HID_RI_REPORT_SIZE(8, 0x08),
|
||||
HID_RI_INPUT(8, HID_IOF_CONSTANT),
|
||||
# endif
|
||||
// X/Y position (2 or 4 bytes)
|
||||
HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop
|
||||
HID_RI_USAGE(8, 0x30), // X
|
||||
HID_RI_USAGE(8, 0x31), // Y
|
||||
# ifndef MOUSE_EXTENDED_REPORT
|
||||
HID_RI_LOGICAL_MINIMUM(8, -127),
|
||||
HID_RI_LOGICAL_MAXIMUM(8, 127),
|
||||
HID_RI_REPORT_COUNT(8, 0x02),
|
||||
HID_RI_REPORT_SIZE(8, 0x08),
|
||||
# else
|
||||
HID_RI_LOGICAL_MINIMUM(16, -32767),
|
||||
HID_RI_LOGICAL_MAXIMUM(16, 32767),
|
||||
HID_RI_REPORT_COUNT(8, 0x02),
|
||||
HID_RI_REPORT_SIZE(8, 0x10),
|
||||
# endif
|
||||
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
|
||||
|
||||
// Vertical wheel (1 byte)
|
||||
|
|
|
@ -482,14 +482,28 @@ const PROGMEM uchar shared_hid_report[] = {
|
|||
0x75, 0x01, // Report Size (1)
|
||||
0x81, 0x02, // Input (Data, Variable, Absolute)
|
||||
|
||||
// X/Y position (2 bytes)
|
||||
# ifdef MOUSE_EXTENDED_REPORT
|
||||
// Boot protocol XY ignored in Report protocol
|
||||
0x95, 0x02, // Report Count (2)
|
||||
0x75, 0x08, // Report Size (8)
|
||||
0x81, 0x03, // Input (Constant)
|
||||
# endif
|
||||
|
||||
// X/Y position (2 or 4 bytes)
|
||||
0x05, 0x01, // Usage Page (Generic Desktop)
|
||||
0x09, 0x30, // Usage (X)
|
||||
0x09, 0x31, // Usage (Y)
|
||||
# ifndef MOUSE_EXTENDED_REPORT
|
||||
0x15, 0x81, // Logical Minimum (-127)
|
||||
0x25, 0x7F, // Logical Maximum (127)
|
||||
0x95, 0x02, // Report Count (2)
|
||||
0x75, 0x08, // Report Size (8)
|
||||
# else
|
||||
0x16, 0x01, 0x80, // Logical Minimum (-32767)
|
||||
0x26, 0xFF, 0x7F, // Logical Maximum (32767)
|
||||
0x95, 0x02, // Report Count (2)
|
||||
0x75, 0x10, // Report Size (16)
|
||||
# endif
|
||||
0x81, 0x06, // Input (Data, Variable, Relative)
|
||||
|
||||
// Vertical wheel (1 byte)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue