diff options
Diffstat (limited to 'quantum/pointing_device/pointing_device.c')
-rw-r--r-- | quantum/pointing_device/pointing_device.c | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/quantum/pointing_device/pointing_device.c b/quantum/pointing_device/pointing_device.c index cac2875fc8..564c2d294c 100644 --- a/quantum/pointing_device/pointing_device.c +++ b/quantum/pointing_device/pointing_device.c @@ -25,6 +25,10 @@ # include "mousekey.h" #endif +#ifdef POINTING_DEVICE_HIRES_SCROLL_ENABLE +# include "usb_descriptor_common.h" +#endif + #if (defined(POINTING_DEVICE_ROTATION_90) + defined(POINTING_DEVICE_ROTATION_180) + defined(POINTING_DEVICE_ROTATION_270)) > 1 # error More than one rotation selected. This is not supported. #endif @@ -78,6 +82,9 @@ uint16_t pointing_device_get_shared_cpi(void) { static report_mouse_t local_mouse_report = {}; static bool pointing_device_force_send = false; +#ifdef POINTING_DEVICE_HIRES_SCROLL_ENABLE +static uint16_t hires_scroll_resolution; +#endif #define POINTING_DEVICE_DRIVER_CONCAT(name) name##_pointing_device_driver #define POINTING_DEVICE_DRIVER(name) POINTING_DEVICE_DRIVER_CONCAT(name) @@ -102,6 +109,11 @@ const pointing_device_driver_t custom_pointing_device_driver = { const pointing_device_driver_t *pointing_device_driver = &POINTING_DEVICE_DRIVER(POINTING_DEVICE_DRIVER_NAME); +__attribute__((weak)) void pointing_device_init_modules(void) {} +__attribute__((weak)) report_mouse_t pointing_device_task_modules(report_mouse_t mouse_report) { + return mouse_report; +} + /** * @brief Keyboard level code pointing device initialisation * @@ -176,7 +188,14 @@ __attribute__((weak)) void pointing_device_init(void) { # endif #endif } +#ifdef POINTING_DEVICE_HIRES_SCROLL_ENABLE + hires_scroll_resolution = POINTING_DEVICE_HIRES_SCROLL_MULTIPLIER; + for (int i = 0; i < POINTING_DEVICE_HIRES_SCROLL_EXPONENT; i++) { + hires_scroll_resolution *= 10; + } +#endif + pointing_device_init_modules(); pointing_device_init_kb(); pointing_device_init_user(); } @@ -306,8 +325,9 @@ __attribute__((weak)) bool pointing_device_task(void) { local_mouse_report = is_keyboard_left() ? pointing_device_task_combined_kb(local_mouse_report, shared_mouse_report) : pointing_device_task_combined_kb(shared_mouse_report, local_mouse_report); #else local_mouse_report = pointing_device_adjust_by_defines(local_mouse_report); - local_mouse_report = pointing_device_task_kb(local_mouse_report); #endif + local_mouse_report = pointing_device_task_modules(local_mouse_report); + local_mouse_report = pointing_device_task_kb(local_mouse_report); // automatic mouse layer function #ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE pointing_device_task_auto_mouse(local_mouse_report); @@ -404,10 +424,10 @@ void pointing_device_set_cpi_on_side(bool left, uint16_t cpi) { * @return mouse_hv_report_t clamped value */ static inline mouse_hv_report_t pointing_device_hv_clamp(hv_clamp_range_t value) { - if (value < HV_REPORT_MIN) { - return HV_REPORT_MIN; - } else if (value > HV_REPORT_MAX) { - return HV_REPORT_MAX; + if (value < MOUSE_REPORT_HV_MIN) { + return MOUSE_REPORT_HV_MIN; + } else if (value > MOUSE_REPORT_HV_MAX) { + return MOUSE_REPORT_HV_MAX; } else { return value; } @@ -420,10 +440,10 @@ static inline mouse_hv_report_t pointing_device_hv_clamp(hv_clamp_range_t value) * @return mouse_xy_report_t clamped value */ static inline mouse_xy_report_t pointing_device_xy_clamp(xy_clamp_range_t value) { - if (value < XY_REPORT_MIN) { - return XY_REPORT_MIN; - } else if (value > XY_REPORT_MAX) { - return XY_REPORT_MAX; + if (value < MOUSE_REPORT_XY_MIN) { + return MOUSE_REPORT_XY_MIN; + } else if (value > MOUSE_REPORT_XY_MAX) { + return MOUSE_REPORT_XY_MAX; } else { return value; } @@ -523,3 +543,9 @@ __attribute__((weak)) void pointing_device_keycode_handler(uint16_t keycode, boo pointing_device_send(); } } + +#ifdef POINTING_DEVICE_HIRES_SCROLL_ENABLE +uint16_t pointing_device_get_hires_scroll_resolution(void) { + return hires_scroll_resolution; +} +#endif
\ No newline at end of file |