diff --git a/keyboards/scda/promicro_trackball/config.h b/keyboards/scda/promicro_trackball/config.h index 48438e6adf6..707535f215a 100644 --- a/keyboards/scda/promicro_trackball/config.h +++ b/keyboards/scda/promicro_trackball/config.h @@ -19,6 +19,9 @@ along with this program. If not, see . #define POINTING_DEVICE_ROTATION_90 +#define POINTING_DEVICE_INVERT_Y // remove for normal pointer usage +#define PIMORONI_TRACKBALL_SCALE 1 // default 5 + #ifndef PIMORONI_TRACKBALL_ADDRESS # define PIMORONI_TRACKBALL_ADDRESS 0x0A #endif diff --git a/keyboards/scda/promicro_trackball/keymaps/default/keymap.c b/keyboards/scda/promicro_trackball/keymaps/default/keymap.c index ad369c58367..717e7fbc6c1 100644 --- a/keyboards/scda/promicro_trackball/keymaps/default/keymap.c +++ b/keyboards/scda/promicro_trackball/keymaps/default/keymap.c @@ -1,12 +1,36 @@ #include QMK_KEYBOARD_H bool set_scrolling = true; + +// Modify these values to adjust the scrolling speed +#define SCROLL_DIVISOR_H 2.0 +#define SCROLL_DIVISOR_V 2.0 + +// Variables to store accumulated scroll values +float scroll_accumulated_h = 0; +float scroll_accumulated_v = 0; + +// Function to handle mouse reports and perform (smoothed) drag scrolling report_mouse_t pointing_device_task_user(report_mouse_t mouse_report) { - if (set_scrolling) { - mouse_report.h = mouse_report.x; - mouse_report.v = mouse_report.y; - mouse_report.x = mouse_report.y = 0; + if (!set_scrolling){ + return mouse_report; } + + // Calculate and accumulate scroll values based on mouse movement and divisors + scroll_accumulated_h += (float)mouse_report.x / SCROLL_DIVISOR_H; + scroll_accumulated_v += (float)mouse_report.y / SCROLL_DIVISOR_V; + + // Assign integer parts of accumulated scroll values to the mouse report + mouse_report.h = (int8_t)scroll_accumulated_h; + mouse_report.v = (int8_t)scroll_accumulated_v; + + // Update accumulated scroll values by subtracting the integer parts + scroll_accumulated_h -= (int8_t)scroll_accumulated_h; + scroll_accumulated_v -= (int8_t)scroll_accumulated_v; + + // Clear the X and Y values of the mouse report + mouse_report.x = mouse_report.y = 0; + return mouse_report; }