From c14127c278979d35d21ac10140c3a44825375479 Mon Sep 17 00:00:00 2001 From: Alabastard-64 Date: Tue, 17 Jan 2023 07:18:10 -0700 Subject: [PATCH] finally fix hscroll fully and add maybe ability to change multiplier at runtime --- .../pointing_device/pointing_device_modes.c | 17 +- tmk_core/protocol/chibios/usb_main.c | 11 +- tmk_core/protocol/lufa/lufa.c | 26 ++- tmk_core/protocol/report.c | 36 +++- tmk_core/protocol/report.h | 56 ++++-- tmk_core/protocol/usb_descriptor.c | 33 ++-- tmk_core/protocol/vusb/vusb.c | 176 ++++++++---------- 7 files changed, 189 insertions(+), 166 deletions(-) diff --git a/quantum/pointing_device/pointing_device_modes.c b/quantum/pointing_device/pointing_device_modes.c index dbe95a08e445..eb91aa6206e2 100644 --- a/quantum/pointing_device/pointing_device_modes.c +++ b/quantum/pointing_device/pointing_device_modes.c @@ -91,7 +91,7 @@ void set_pointing_mode(pointing_mode_t pointing_mode) { // skip if same if (!memcmp(&pointing_mode_context.mode, &pointing_mode, sizeof(pointing_mode_t))) return; memcpy(&pointing_mode_context.mode, &pointing_mode, sizeof(pointing_mode_t)); - dprintf("PM status saved!\n"); + //dprintf("PM status saved!\n"); // Prevent zero divisor if (!pointing_mode_context.mode.divisor) { pointing_mode_context.mode.divisor = POINTING_DEFAULT_DIVISOR; @@ -116,7 +116,7 @@ void set_pointing_mode_id(uint8_t mode_id) { if (pointing_mode_context.mode.id != mode_id) { pointing_mode_reset(); pointing_mode_context.mode.id = mode_id; - dprintf("PMID Set: %d\n", mode_id); + //dprintf("PMID Set: %d\n", mode_id); } } @@ -130,10 +130,10 @@ void set_pointing_mode_id(uint8_t mode_id) { void toggle_pointing_mode_id(uint8_t mode_id) { if (pointing_mode_context.config.tg_mode_id == mode_id) { pointing_mode_context.config.tg_mode_id = POINTING_MODE_DEFAULT; - dprintf("Toggled PMID: %d\n Off", mode_id); + //dprintf("Toggled PMID: %d\n Off", mode_id); } else { pointing_mode_context.config.tg_mode_id = mode_id; - dprintf("Toggled PMID: %d\n On", mode_id); + //dprintf("Toggled PMID: %d\n On", mode_id); } if (pointing_mode_context.mode.id != pointing_mode_context.config.tg_mode_id) pointing_mode_reset(); } @@ -365,8 +365,9 @@ static report_mouse_t process_pointing_mode(pointing_mode_t pointing_mode, repor # ifdef MOUSE_SCROLL_HIRES_ENABLE { uint8_t cur_divisor = pointing_mode.divisor; - uint8_t drag_multiplier = MAX(MOUSE_SCROLL_MULTIPLIER / cur_divisor, 1); - if (RESOLUTION_MULTIPLIER_H) { + if (IS_HIRES_H_ACTIVE) { + int16_t drag_multiplier = MOUSE_SCROLL_MULTIPLIER_H / cur_divisor; + if(!(drag_multiplier >> 1)) drag_multiplier |= 0x0001; pointing_mode.x *= drag_multiplier; pointing_mode.divisor = 1; } @@ -374,7 +375,9 @@ static report_mouse_t process_pointing_mode(pointing_mode_t pointing_mode, repor mouse_report.h = pointing_device_hv_clamp(pointing_mode.x / (int16_t)pointing_mode.divisor); pointing_mode.x -= (int16_t)mouse_report.h * (int16_t)pointing_mode.divisor; # ifdef MOUSE_SCROLL_HIRES_ENABLE - if (RESOLUTION_MULTIPLIER_V) { + if (IS_HIRES_V_ACTIVE) { + int16_t drag_multiplier = MOUSE_SCROLL_MULTIPLIER_V / cur_divisor; + if(!(drag_multiplier >> 1)) drag_multiplier |= 0x0001; pointing_mode.y *= drag_multiplier; pointing_mode.divisor = 1; } else { diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index d52521904ee6..547926971ffa 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -111,7 +111,6 @@ union { #define HID_SET_REPORT 0x09 #define HID_SET_IDLE 0x0A #define HID_SET_PROTOCOL 0x0B -#define HID_FEATURE_REPORT 0x03 /* * Handles the GET_DESCRIPTOR callback @@ -556,7 +555,7 @@ static void usb_event_cb(USBDriver *usbp, usbevent_t event) { } #ifdef MOUSE_SCROLL_HIRES_ENABLE /* Reset multiplier on reset */ - resolution_multiplier = 0; + resolution_multiplier_reset(); #endif return; @@ -615,7 +614,7 @@ static void set_led_transfer_cb(USBDriver *usbp) { #ifdef MOUSE_SCROLL_HIRES_ENABLE static void set_multiplier_cb(USBDriver *usbp) { if (usbp->setup[6] == 2 && set_report_buf[0] == REPORT_ID_MULTIPLIER) { - resolution_multiplier = set_report_buf[1]; + mouse_scroll_res_report.multiplier = set_report_buf[1]; } } #endif @@ -657,7 +656,7 @@ static bool usb_request_hook_cb(USBDriver *usbp) { return TRUE; break; case REPORT_ID_MULTIPLIER: - usbSetupTransfer(usbp, (uint8_t *)&resolution_multiplier, sizeof(resolution_multiplier), NULL); + usbSetupTransfer(usbp, (uint8_t *)&mouse_scroll_res_report, sizeof(report_mouse_scroll_res_t), NULL); return TRUE; break; } @@ -679,7 +678,7 @@ static bool usb_request_hook_cb(USBDriver *usbp) { break; # ifdef MOUSE_SCROLL_HIRES_ENABLE case REPORT_ID_MULTIPLIER: - usbSetupTransfer(usbp, (uint8_t *)&resolution_multiplier, sizeof(resolution_multiplier), NULL); + usbSetupTransfer(usbp, (uint8_t *)&mouse_scroll_res_report, sizeof(report_mouse_scroll_res_t), NULL); return TRUE; break; # endif @@ -724,7 +723,7 @@ static bool usb_request_hook_cb(USBDriver *usbp) { break; #else switch(usbp->setup[2]) { - case REPORT_ID_MOUSE: + case REPORT_ID_KEYBOARD: usbSetupTransfer(usbp, set_report_buf, sizeof(set_report_buf), set_led_transfer_cb); return TRUE; break; diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 201651c42502..63bafe0b5507 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -260,6 +260,10 @@ static void Console_Task(void) { */ void EVENT_USB_Device_Connect(void) { print("[C]"); +#ifdef MOUSE_SCROLL_HIRES_ENABLE + /* Reset multiplier on reset */ + resolution_multiplier_reset(); +#endif /* For battery powered device */ if (!USB_IsInitialized) { USB_Disable(); @@ -292,10 +296,6 @@ void EVENT_USB_Device_Disconnect(void) { void EVENT_USB_Device_Reset(void) { print("[R]"); usb_device_state_set_reset(); -#ifdef MOUSE_SCROLL_HIRES_ENABLE - /* Reset multiplier on reset */ - resolution_multiplier = 0; -#endif } /** \brief Event USB Device Connect @@ -460,8 +460,8 @@ void EVENT_USB_Device_ControlRequest(void) { case MOUSE_INTERFACE: # ifdef MOUSE_SCROLL_HIRES_ENABLE if ((USB_ControlRequest.wValue & 0xff) == REPORT_ID_MULTIPLIER) { - ReportData = &resolution_multiplier; - ReportSize = sizeof(resolution_multiplier); + ReportData = (uint8_t *)&mouse_scroll_res_report; + ReportSize = sizeof(report_mouse_scroll_res_t); break; } # endif @@ -480,8 +480,8 @@ void EVENT_USB_Device_ControlRequest(void) { # endif # if defined(MOUSE_ENABLE) && defined(MOUSE_SCROLL_HIRES_ENABLE) && defined(MOUSE_SHARED_EP) case REPORT_ID_MULTIPLIER: - ReportData = &resolution_multiplier; - ReportSize = sizeof(resolution_multiplier); + ReportData = (uint8_t *)&mouse_scroll_res_report; + ReportSize = sizeof(report_mouse_scroll_res_t); break; # endif } @@ -513,17 +513,16 @@ void EVENT_USB_Device_ControlRequest(void) { uint8_t report_id = USB_ControlRequest.wValue & 0xFF; // Discard report ID byte as we already have it from wValue - if (USB_ControlRequest.wLength == 2) { - Endpoint_Discard_8(); - } + if(USB_ControlRequest.wLength > 1) Endpoint_Discard_8(); switch(report_id) { + case REPORT_ID_KEYBOARD: case REPORT_ID_NKRO: keyboard_led_state = Endpoint_Read_8(); break; #ifdef MOUSE_SCROLL_HIRES_ENABLE case REPORT_ID_MULTIPLIER: - resolution_multiplier = Endpoint_Read_8(); + mouse_scroll_res_report.multiplier = Endpoint_Read_8(); break; #endif } @@ -630,9 +629,6 @@ static void send_keyboard(report_keyboard_t *report) { static void send_mouse(report_mouse_t *report) { #ifdef MOUSE_ENABLE send_report(MOUSE_IN_EPNUM, report, sizeof(report_mouse_t)); -# ifdef MOUSE_HIRES_SCROLL_ENABLE - hires_scroll_reset(); -# endif #endif } diff --git a/tmk_core/protocol/report.c b/tmk_core/protocol/report.c index 934f9f443fba..6acf3c5e5329 100644 --- a/tmk_core/protocol/report.c +++ b/tmk_core/protocol/report.c @@ -32,8 +32,10 @@ static int8_t cb_count = 0; #endif #ifdef MOUSE_SCROLL_HIRES_ENABLE -static uint8_t resolution_multiplier_stored = 0; -uint8_t resolution_multiplier = 0; +report_mouse_scroll_res_t mouse_scroll_res_report = { + .report_id = REPORT_ID_MULTIPLIER, + .multiplier = 0 + }; #endif /** \brief has_anykey @@ -297,12 +299,32 @@ __attribute__((weak)) bool has_mouse_report_changed(report_mouse_t* new_report, } # ifdef MOUSE_SCROLL_HIRES_ENABLE -void hires_scroll_disable_next(uint8_t axis) { - resolution_multiplier_stored |= resolution_multiplier; - resolution_multiplier &= ~(axis); +bool set_hires_scroll_multiplier(uint8_t axis, uint8_t value) { + static uint8_t max_multiplier; + uint8_t multiplier_temp = mouse_scroll_res_report.multiplier; + max_multiplier |= multiplier_temp; + + uint8_t set_value = (value / MOUSE_SCROLL_MULTIPLIER_RESOLUTION) & 0x0F; + + switch(axis) { + case HIRES_V: + mouse_scroll_res_report.axis.v = set_value; + break; + + case HIRES_H: + mouse_scroll_res_report.axis.h = set_value; + break; + + case HIRES_BOTH: + mouse_scroll_res_report.axis.v = set_value; + mouse_scroll_res_report.axis.h = set_value; + } + mouse_scroll_res_report.multiplier &= max_multiplier; + return mouse_scroll_res_report.multiplier != multiplier_temp; } -void hires_scroll_reset(void) { - resolution_multiplier |= resolution_multiplier_stored; + +void resolution_multiplier_reset(void) { + mouse_scroll_res_report.multiplier = 0; } # endif #endif // MOUSE_ENABLE diff --git a/tmk_core/protocol/report.h b/tmk_core/protocol/report.h index 61ee4253a3c5..b6495591d67d 100644 --- a/tmk_core/protocol/report.h +++ b/tmk_core/protocol/report.h @@ -23,19 +23,6 @@ along with this program. If not, see . // clang-format off -#ifdef MOUSE_SCROLL_HIRES_ENABLE -# ifndef MOUSE_SCROLL_MULTIPLIER -# define MOUSE_SCROLL_MULTIPLIER 120 -# elif (MOUSE_SCROLL_MULTIPLIER > 120 || MOUSE_SCROLL_MULTIPLIER < 1) -# error "MOUSE_SCROLL_MULTIPLIER out of bounds must be in range of 1-120" -# endif -enum { - HIRES_V = 0x0F, - HIRES_H = 0xF0, - HIRES_BOTH = HIRES_V | HIRES_H, -}; -#endif - /* HID report IDs */ enum hid_report_ids { REPORT_ID_KEYBOARD = 1, @@ -134,6 +121,12 @@ enum desktop_usages { SYSTEM_DISPLAY_TOGGLE_INT_EXT = 0xB5 }; +enum mouse_scroll_hires_axes { + HIRES_V, + HIRES_H, + HIRES_BOTH +}; + // clang-format on #define NKRO_SHARED_EP @@ -227,11 +220,19 @@ typedef int16_t mouse_hv_report_t; typedef int8_t mouse_hv_report_t; #endif -#ifdef MOUSE_SCROLL_HIRES_ENABLE -extern uint8_t resolution_multiplier; -# define RESOLUTION_MULTIPLIER_V (resolution_multiplier & HIRES_V) -# define RESOLUTION_MULTIPLIER_H (resolution_multiplier & HIRES_H) -#endif +typedef union { + uint8_t raw[2]; + struct { + uint8_t report_id; + union { + uint8_t multiplier; + struct { + uint8_t v : 4; + uint8_t h : 4; + } axis; + }; + }; +} __attribute__((packed)) report_mouse_scroll_res_t; typedef struct { #if defined(MOUSE_SHARED_EP) || defined(MOUSE_SCROLL_HIRES_ENABLE) @@ -369,8 +370,23 @@ bool has_mouse_report_changed(report_mouse_t* new_report, report_mouse_t* old_re #endif #ifdef MOUSE_SCROLL_HIRES_ENABLE -void disable_hires_scroll_on_next(uint8_t axis); -void hires_scroll_reset(void); +extern report_mouse_scroll_res_t mouse_scroll_res_report; + +bool set_hires_scroll_multiplier(uint8_t axis, uint8_t value); +void resolution_multiplier_reset(void); + +# define MOUSE_SCROLL_MULTIPLIER_RESOLUTION (MOUSE_SCROLL_MULTIPLIER_MAX / 15) +# define IS_HIRES_V_ACTIVE (bool)(mouse_scroll_res_report.axis.v) +# define IS_HIRES_H_ACTIVE (bool)(mouse_scroll_res_report.axis.h) +# define MOUSE_SCROLL_MULTIPLIER_V (uint8_t)(mouse_scroll_res_report.axis.v * MOUSE_SCROLL_MULTIPLIER_RESOLUTION) +# define MOUSE_SCROLL_MULTIPLIER_H (uint8_t)(mouse_scroll_res_report.axis.h * MOUSE_SCROLL_MULTIPLIER_RESOLUTION) +# define MOUSE_SCROLL_MULTIPLIER_FULL (mouse_scroll_res_report.multiplier) + +# ifndef MOUSE_SCROLL_MULTIPLIER_MAX +# define MOUSE_SCROLL_MULTIPLIER_MAX 120 +# elif (MOUSE_SCROLL_MULTIPLIER_MAX > 120 || MOUSE_SCROLL_MULTIPLIER_MAX < 1) +# error "MOUSE_SCROLL_MULTIPLIER_MAX out of bounds must be in range of 1-120" +# endif #endif #ifdef __cplusplus diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c index 3beb1c577960..c78369bc6c9b 100644 --- a/tmk_core/protocol/usb_descriptor.c +++ b/tmk_core/protocol/usb_descriptor.c @@ -153,10 +153,11 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = { # endif HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE), - // Vertical/Horizontal Wheel (2 or 4 bytes) + // Vertical/Horizontal Wheel (2 - 5 bytes) + // Vertical wheel (1 - 2.5 bytes) # ifdef MOUSE_SCROLL_HIRES_ENABLE HID_RI_COLLECTION(8, 0x02), // Logical collection - // Resolution Multiplier (2 bits) + // Resolution Multiplier (4 bits) HID_RI_REPORT_ID(8, REPORT_ID_MULTIPLIER), HID_RI_USAGE(8, 0x48), // Resolution Multiplier HID_RI_REPORT_COUNT(8, 0x01), @@ -164,17 +165,15 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = { HID_RI_LOGICAL_MINIMUM(8, 0x00), HID_RI_LOGICAL_MAXIMUM(8, 0x0F), HID_RI_PHYSICAL_MINIMUM(8, 0x01), // Min 1 - HID_RI_PHYSICAL_MAXIMUM(8, MOUSE_SCROLL_MULTIPLIER), // Max 120 + HID_RI_PHYSICAL_MAXIMUM(8, MOUSE_SCROLL_MULTIPLIER_MAX), // Max 120 HID_RI_FEATURE(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), + HID_RI_PHYSICAL_MINIMUM(8, 0x00), // Reset Global Value + HID_RI_PHYSICAL_MAXIMUM(8, 0x00), HID_RI_REPORT_ID(8, REPORT_ID_MOUSE), # endif // MOUSE_SCROLL_HIRES_ENABLE - // Vertical wheel (1-2 bytes) + HID_RI_USAGE(8, 0x38), // Wheel (V) -# ifdef MOUSE_SCROLL_HIRES_ENABLE - HID_RI_PHYSICAL_MINIMUM(8, 0x00), // Reset Global Value - HID_RI_PHYSICAL_MAXIMUM(8, 0x00), -# endif # ifdef MOUSE_SCROLL_EXTENDED_REPORT HID_RI_LOGICAL_MINIMUM(16, -32767), HID_RI_LOGICAL_MAXIMUM(16, 32767), @@ -190,28 +189,28 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = { # ifdef MOUSE_SCROLL_HIRES_ENABLE HID_RI_END_COLLECTION(0), // Logical # endif - // Horizontal Wheel (1 or 2 bytes) + // Horizontal Wheel (1 - 2.5 bytes) # ifdef MOUSE_SCROLL_HIRES_ENABLE HID_RI_COLLECTION(8, 0x02), // Logical collection - // Resolution Multiplier (2 bits) + // Resolution Multiplier (4 bits) HID_RI_REPORT_ID(8, REPORT_ID_MULTIPLIER), + //HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop HID_RI_USAGE(8, 0x48), // Resolution Multiplier HID_RI_REPORT_COUNT(8, 0x01), HID_RI_REPORT_SIZE(8, 0x04), - HID_RI_LOGICAL_MINIMUM(8, 0x00), - HID_RI_LOGICAL_MAXIMUM(8, 0x0F), + HID_RI_LOGICAL_MINIMUM(8, 0x00), // Min 0 + HID_RI_LOGICAL_MAXIMUM(8, 0x0F), // Max 15 HID_RI_PHYSICAL_MINIMUM(8, 0x01), // Min 1 - HID_RI_PHYSICAL_MAXIMUM(8, MOUSE_SCROLL_MULTIPLIER), // Max 120 + HID_RI_PHYSICAL_MAXIMUM(8, MOUSE_SCROLL_MULTIPLIER_MAX), // Max 120 HID_RI_FEATURE(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), + HID_RI_PHYSICAL_MINIMUM(8, 0x00), // Reset Global Value + HID_RI_PHYSICAL_MAXIMUM(8, 0x00), HID_RI_REPORT_ID(8, REPORT_ID_MOUSE), # endif // MOUSE_SCROLL_HIRES_ENABLE HID_RI_USAGE_PAGE(8, 0x0C), // Consumer HID_RI_USAGE(16, 0x0238), // AC Pan (Horizontal Wheel) -# ifdef MOUSE_SCROLL_HIRES_ENABLE - HID_RI_PHYSICAL_MINIMUM(8, 0x00), // Reset Global Value - HID_RI_PHYSICAL_MAXIMUM(8, 0x00), -# endif + # ifdef MOUSE_SCROLL_EXTENDED_REPORT HID_RI_LOGICAL_MINIMUM(16, -32767), HID_RI_LOGICAL_MAXIMUM(16, 32767), diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index 938eeb61d8af..7ec832b7fd47 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c @@ -271,10 +271,6 @@ static void send_mouse(report_mouse_t *report) { #ifdef MOUSE_ENABLE if (usbInterruptIsReadyShared()) { usbSetInterruptShared((void *)report, sizeof(report_mouse_t)); -# ifdef MOUSE_HIRES_SCROLL_ENABLE - /* re-enable_hires_scroll */ - enable_hires_scroll(); -# endif } #endif } @@ -333,8 +329,8 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) { #ifdef MOUSE_SCROLL_HIRES_ENABLE // Report Type: 0x03(feature)/ReportID: REPORT_ID_MULTIPLIER if (rq->wValue.word == 0x0300 | REPORT_ID_MULTIPLIER) { - usbMsgPtr = (usbMsgPtr_t)&resolution_multiplier_report; - return sizeof(resolution_multiplier_report); + usbMsgPtr = (usbMsgPtr_t)&mouse_scroll_res_report; + return sizeof(report_mouse_scroll_res_t); } #endif case USBRQ_HID_GET_IDLE: @@ -385,7 +381,7 @@ uchar usbFunctionWrite(uchar *data, uchar len) { case SET_RES_MULT: if (len == 2 && data[0] == REPORT_ID_MULTIPLIER) { dprintf("SET_RES_MULT: %02X\n", data[1]); - resolution_multiplier = data[1]; + mouse_scroll_res_report.multiplier = data[1]; last_req.len = 0; return 1; } @@ -482,128 +478,120 @@ const PROGMEM uchar shared_hid_report[] = { #ifdef MOUSE_ENABLE // Mouse report descriptor - 0x05, 0x01, // Usage Page (Generic Desktop) - 0x09, 0x02, // Usage (Mouse) - 0xA1, 0x01, // Collection (Application) - 0x85, REPORT_ID_MOUSE, // Report ID (MOUSE) - 0x09, 0x01, // Usage (Pointer) - 0xA1, 0x00, // Collection (Physical) + 0x05, 0x01, // Usage Page (Generic Desktop) + 0x09, 0x02, // Usage (Mouse) + 0xA1, 0x01, // Collection (Application) + 0x85, REPORT_ID_MOUSE, // Report ID (MOUSE) + 0x09, 0x01, // Usage (Pointer) + 0xA1, 0x00, // Collection (Physical) // Buttons (8 bits) - 0x05, 0x09, // Usage Page (Button) - 0x19, 0x01, // Usage Minimum (Button 1) - 0x29, 0x08, // Usage Maximum (Button 8) - 0x15, 0x00, // Logical Minimum (0) - 0x25, 0x01, // Logical Maximum (1) - 0x95, 0x08, // Report Count (8) - 0x75, 0x01, // Report Size (1) - 0x81, 0x02, // Input (Data, Variable, Absolute) + 0x05, 0x09, // Usage Page (Button) + 0x19, 0x01, // Usage Minimum (Button 1) + 0x29, 0x08, // Usage Maximum (Button 8) + 0x15, 0x00, // Logical Minimum (0) + 0x25, 0x01, // Logical Maximum (1) + 0x95, 0x08, // Report Count (8) + 0x75, 0x01, // Report Size (1) + 0x81, 0x02, // Input (Data, Variable, Absolute) # 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) + 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) + 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) + 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) + 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) + 0x81, 0x06, // Input (Data, Variable, Relative) // Vertical Wheel (1-2 bytes) # ifdef MOUSE_SCROLL_HIRES_ENABLE - 0xA1, 0x02, // Collection (Logical) + 0xA1, 0x02, // Collection (Logical) // Resolution Multiplier (2 bits) - 0x85, REPORT_ID_MULTIPLIER, // Report ID (MULTIPLIER) - 0x09, 0x48, // Usage (Resolution Multiplier) - 0x95, 0x01, // Report Count (1) - 0x75, 0x02, // Report Size (2) - 0x15, 0x00, // Logical Minimum (0) - 0x25, 0x01, // Logical Maximum (1) - 0x35, 0x01, // Physical Minimum (1) - 0x45, MOUSE_SCROLL_MULTIPLIER, // Physical Maximum (MOUSE_SCROLL_MULTIPLIER) - 0xB1, 0x02, // Feature (Data, Variable, Absolute) + 0x85, REPORT_ID_MULTIPLIER, // Report ID (MULTIPLIER) + 0x09, 0x48, // Usage (Resolution Multiplier) + 0x95, 0x01, // Report Count (1) + 0x75, 0x04, // Report Size (2) + 0x15, 0x00, // Logical Minimum (0) + 0x25, 0x0F, // Logical Maximum (1) + 0x35, 0x01, // Physical Minimum (1) + 0x45, MOUSE_SCROLL_MULTIPLIER_MAX, // Physical Maximum (MOUSE_SCROLL_MULTIPLIER) + 0xB1, 0x02, // Feature (Data, Variable, Absolute) + 0x35, 0x00, // Physical Minimum (0) + 0x45, 0x00, // Physical Maximum (0) Reset Global Value - 0x85, REPORT_ID_MOUSE, // Report ID (MOUSE) + 0x85, REPORT_ID_MOUSE, // Report ID (MOUSE) # endif // Wheel (1-2 bytes) - 0x09, 0x38, // Usage (Wheel) -# ifdef MOUSE_SCROLL_HIRES_ENABLE - 0x35, 0x00, // Physical Minimum (0) - 0x45, 0x00, // Physical Maximum (0) Reset Global Value -# endif + 0x09, 0x38, // Usage (Wheel) # ifdef MOUSE_SCROLL_EXTENDED_REPORT - 0x16, 0x01, 0x80, // Logical Minimum (-32767) - 0x26, 0xFF, 0x7F, // Logical Maximum (32767) - 0x95, 0x01, // Report Count (1) - 0x75, 0x10, // Report Size (16) + 0x16, 0x01, 0x80, // Logical Minimum (-32767) + 0x26, 0xFF, 0x7F, // Logical Maximum (32767) + 0x95, 0x01, // Report Count (1) + 0x75, 0x10, // Report Size (16) # else - 0x15, 0x81, // Logical Minimum (-127) - 0x25, 0x7F, // Logical Maximum (127) - 0x95, 0x01, // Report Count (1) - 0x75, 0x08, // Report Size (8) + 0x15, 0x81, // Logical Minimum (-127) + 0x25, 0x7F, // Logical Maximum (127) + 0x95, 0x01, // Report Count (1) + 0x75, 0x08, // Report Size (8) # endif - 0x81, 0x06, // Input (Data, Variable, Relative) + 0x81, 0x06, // Input (Data, Variable, Relative) # ifdef MOUSE_SCROLL_HIRES_ENABLE - 0xC0, // End Collection (Logical) + 0xC0, // End Collection (Logical) # endif // Horizontal wheel (1-2 bytes) # ifdef MOUSE_SCROLL_HIRES_ENABLE 0xA1, 0x02, // Collection (Logical) // Resolution Multiplier (2 bits) - 0x85, REPORT_ID_MULTIPLIER, // Report ID (MULTIPLIER) - 0x09, 0x48, // Usage (Resolution Multiplier) - 0x95, 0x01, // Report Count (1) - 0x75, 0x02, // Report Size (2) - 0x15, 0x00, // Logical Minimum (0) - 0x25, 0x01, // Logical Maximum (1) - 0x35, 0x01, // Physical Minimum (1) - 0x45, MOUSE_SCROLL_MULTIPLIER, // Physical Maximum (MOUSE_SCROLL_MULTIPLIER) - 0xB1, 0x02, // Feature (Data, Variable, Absolute) - // Padding (4 bits) - 0x75, 0x04, // Report Size (4) - 0x95, 0x01, // Report Count (1) - 0xB1, 0x03, // Feature (Data, Constant) + 0x85, REPORT_ID_MULTIPLIER, // Report ID (MULTIPLIER) + 0x09, 0x48, // Usage (Resolution Multiplier) + 0x95, 0x01, // Report Count (1) + 0x75, 0x02, // Report Size (2) + 0x15, 0x00, // Logical Minimum (0) + 0x25, 0x01, // Logical Maximum (1) + 0x35, 0x01, // Physical Minimum (1) + 0x45, MOUSE_SCROLL_MULTIPLIER_MAX, // Physical Maximum (MOUSE_SCROLL_MULTIPLIER) + 0xB1, 0x02, // Feature (Data, Variable, Absolute) + 0x35, 0x00, // Physical Minimum (0) + 0x45, 0x00, // Physical Maximum (0) Reset Global Value - 0x85, REPORT_ID_MOUSE, // Report ID (MOUSE) -# endif - 0x05, 0x0C, // Usage Page (Consumer) - 0x0A, 0x38, 0x02, // Usage (AC Pan) -# ifdef MOUSE_SCROLL_HIRES_ENABLE - 0x35, 0x00, // Physical Minimum (0) - 0x45, 0x00, // Physical Maximum (0) Reset Global Value + 0x85, REPORT_ID_MOUSE, // Report ID (MOUSE) # endif + 0x05, 0x0C, // Usage Page (Consumer) + 0x0A, 0x38, 0x02, // Usage (AC Pan) # ifdef MOUSE_SCROLL_EXTENDED_REPORT - 0x16, 0x01, 0x80, // Logical Minimum (-32767) - 0x26, 0xFF, 0x7F, // Logical Maximum (32767) - 0x95, 0x01, // Report Count (1) - 0x75, 0x10, // Report Size (16) + 0x16, 0x01, 0x80, // Logical Minimum (-32767) + 0x26, 0xFF, 0x7F, // Logical Maximum (32767) + 0x95, 0x01, // Report Count (1) + 0x75, 0x10, // Report Size (16) # else - 0x15, 0x81, // Logical Minimum (-127) - 0x25, 0x7F, // Logical Maximum (127) - 0x95, 0x01, // Report Count (1) - 0x75, 0x08, // Report Size (8) + 0x15, 0x81, // Logical Minimum (-127) + 0x25, 0x7F, // Logical Maximum (127) + 0x95, 0x01, // Report Count (1) + 0x75, 0x08, // Report Size (8) # endif - 0x81, 0x06, // Input (Data, Variable, Relative) + 0x81, 0x06, // Input (Data, Variable, Relative) # ifdef MOUSE_SCROLL_HIRES_ENABLE - 0xC0, // End Collection (Logical) + 0xC0, // End Collection (Logical) # endif - 0xC0, // End Collection (Physical) - 0xC0, // End Collection (Application) + 0xC0, // End Collection (Physical) + 0xC0, // End Collection (Application) #endif #ifdef EXTRAKEY_ENABLE