aboutsummaryrefslogtreecommitdiffstats
path: root/tmk_core/protocol
diff options
context:
space:
mode:
authoreynsai2025-04-23 00:04:31 +0200
committerGitHub2025-04-23 00:04:31 +0200
commit7a2cd0fa962eb5e6e18ce8b0213a7171bc823c1f (patch)
treed7c62b67ba4d9402b822768d7013803d99cb9484 /tmk_core/protocol
parent83818d1d6f7d1f590946756ad552e407bf9a2e1f (diff)
High resolution scrolling (without feature report parsing) (#24423)
* hires scrolling without feature report parsing * fix valid range for exponent * fix incorrect minimum exponent value documentation
Diffstat (limited to 'tmk_core/protocol')
-rw-r--r--tmk_core/protocol/usb_descriptor.c24
-rw-r--r--tmk_core/protocol/usb_descriptor_common.h20
-rw-r--r--tmk_core/protocol/vusb/vusb.c28
3 files changed, 70 insertions, 2 deletions
diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c
index c7fb660b65..ceab9eef9a 100644
--- a/tmk_core/protocol/usb_descriptor.c
+++ b/tmk_core/protocol/usb_descriptor.c
@@ -165,6 +165,24 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = {
# endif
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
+# ifdef POINTING_DEVICE_HIRES_SCROLL_ENABLE
+ HID_RI_COLLECTION(8, 0x02),
+ // Feature report and padding (1 byte)
+ HID_RI_USAGE(8, 0x48), // Resolution Multiplier
+ HID_RI_REPORT_COUNT(8, 0x01),
+ HID_RI_REPORT_SIZE(8, 0x02),
+ HID_RI_LOGICAL_MINIMUM(8, 0x00),
+ HID_RI_LOGICAL_MAXIMUM(8, 0x01),
+ HID_RI_PHYSICAL_MINIMUM(8, 1),
+ HID_RI_PHYSICAL_MAXIMUM(8, POINTING_DEVICE_HIRES_SCROLL_MULTIPLIER),
+ HID_RI_UNIT_EXPONENT(8, POINTING_DEVICE_HIRES_SCROLL_EXPONENT),
+ HID_RI_FEATURE(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
+ HID_RI_PHYSICAL_MINIMUM(8, 0x00),
+ HID_RI_PHYSICAL_MAXIMUM(8, 0x00),
+ HID_RI_REPORT_SIZE(8, 0x06),
+ HID_RI_FEATURE(8, HID_IOF_CONSTANT),
+# endif
+
// Vertical wheel (1 or 2 bytes)
HID_RI_USAGE(8, 0x38), // Wheel
# ifndef WHEEL_EXTENDED_REPORT
@@ -179,6 +197,7 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = {
HID_RI_REPORT_SIZE(8, 0x10),
# endif
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
+
// Horizontal wheel (1 or 2 bytes)
HID_RI_USAGE_PAGE(8, 0x0C),// Consumer
HID_RI_USAGE(16, 0x0238), // AC Pan
@@ -194,6 +213,11 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = {
HID_RI_REPORT_SIZE(8, 0x10),
# endif
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
+
+# ifdef POINTING_DEVICE_HIRES_SCROLL_ENABLE
+ HID_RI_END_COLLECTION(0),
+# endif
+
HID_RI_END_COLLECTION(0),
HID_RI_END_COLLECTION(0),
# ifndef MOUSE_SHARED_EP
diff --git a/tmk_core/protocol/usb_descriptor_common.h b/tmk_core/protocol/usb_descriptor_common.h
index 909c230a99..f782d83fbc 100644
--- a/tmk_core/protocol/usb_descriptor_common.h
+++ b/tmk_core/protocol/usb_descriptor_common.h
@@ -32,3 +32,23 @@
#ifndef RAW_USAGE_ID
# define RAW_USAGE_ID 0x61
#endif
+
+/////////////////////
+// Hires Scroll Defaults
+
+#ifdef POINTING_DEVICE_HIRES_SCROLL_ENABLE
+# ifdef POINTING_DEVICE_HIRES_SCROLL_MULTIPLIER
+# if POINTING_DEVICE_HIRES_SCROLL_MULTIPLIER > 127 || POINTING_DEVICE_HIRES_SCROLL_MULTIPLIER < 1
+# error "POINTING_DEVICE_HIRES_SCROLL_MULTIPLIER must be between 1 and 127, inclusive!"
+# endif
+# else
+# define POINTING_DEVICE_HIRES_SCROLL_MULTIPLIER 120
+# endif
+# ifdef POINTING_DEVICE_HIRES_SCROLL_EXPONENT
+# if POINTING_DEVICE_HIRES_SCROLL_EXPONENT > 127 || POINTING_DEVICE_HIRES_SCROLL_EXPONENT < 0
+# error "POINTING_DEVICE_HIRES_SCROLL_EXPONENT must be between 0 and 127, inclusive!"
+# endif
+# else
+# define POINTING_DEVICE_HIRES_SCROLL_EXPONENT 0
+# endif
+#endif \ No newline at end of file
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c
index fdbfcc17dc..56cf82e5a6 100644
--- a/tmk_core/protocol/vusb/vusb.c
+++ b/tmk_core/protocol/vusb/vusb.c
@@ -520,6 +520,24 @@ const PROGMEM uchar shared_hid_report[] = {
# endif
0x81, 0x06, // Input (Data, Variable, Relative)
+# ifdef POINTING_DEVICE_HIRES_SCROLL_ENABLE
+ // Feature report and padding (1 byte)
+ 0xA1, 0x02, // Collection (Logical)
+ 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, POINTING_DEVICE_HIRES_SCROLL_MULTIPLIER, // Physical Maximum (POINTING_DEVICE_HIRES_SCROLL_MULTIPLIER)
+ 0x55, POINTING_DEVICE_HIRES_SCROLL_EXPONENT, // Unit Exponent (POINTING_DEVICE_HIRES_SCROLL_EXPONENT)
+ 0xB1, 0x02, // Feature (Data, Variable, Absolute)
+ 0x35, 0x00, // Physical Minimum (0)
+ 0x45, 0x00, // Physical Maximum (0)
+ 0x75, 0x06, // Report Size (6)
+ 0xB1, 0x03, // Feature (Constant)
+# endif
+
// Vertical wheel (1 or 2 bytes)
0x09, 0x38, // Usage (Wheel)
# ifndef WHEEL_EXTENDED_REPORT
@@ -534,6 +552,7 @@ const PROGMEM uchar shared_hid_report[] = {
0x75, 0x10, // Report Size (16)
# endif
0x81, 0x06, // Input (Data, Variable, Relative)
+
// Horizontal wheel (1 or 2 bytes)
0x05, 0x0C, // Usage Page (Consumer)
0x0A, 0x38, 0x02, // Usage (AC Pan)
@@ -549,8 +568,13 @@ const PROGMEM uchar shared_hid_report[] = {
0x75, 0x10, // Report Size (16)
# endif
0x81, 0x06, // Input (Data, Variable, Relative)
- 0xC0, // End Collection
- 0xC0, // End Collection
+
+# ifdef POINTING_DEVICE_HIRES_SCROLL_ENABLE
+ 0xC0, // End Collection
+# endif
+
+ 0xC0, // End Collection
+ 0xC0, // End Collection
#endif
#ifdef EXTRAKEY_ENABLE