fine-tune scrolling sensitivity

This commit is contained in:
scda 2023-09-05 09:25:58 +02:00
parent bf726d298d
commit e8bc2ea703
2 changed files with 31 additions and 4 deletions

View File

@ -19,6 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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

View File

@ -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;
}