From 2deb9d0b742ef07136c598f255e967ea9905a815 Mon Sep 17 00:00:00 2001 From: brian cully Date: Fri, 16 Jan 2026 10:00:34 -0500 Subject: stop using ploopy's drag scroll which accumulated large errors --- keyboards/ploopyco/madromys/keymaps/bjc/keymap.c | 43 +++++++++++++++++++----- 1 file changed, 35 insertions(+), 8 deletions(-) (limited to 'keyboards/ploopyco') diff --git a/keyboards/ploopyco/madromys/keymaps/bjc/keymap.c b/keyboards/ploopyco/madromys/keymaps/bjc/keymap.c index db9cd23..3b76c0a 100644 --- a/keyboards/ploopyco/madromys/keymaps/bjc/keymap.c +++ b/keyboards/ploopyco/madromys/keymaps/bjc/keymap.c @@ -40,29 +40,35 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { // probably shouldn't be doing this, but beats trying to keep track of // it myself and getting out of sync. -extern bool is_drag_scroll; +//extern bool is_drag_scroll; + +bool drag_scroll = false; layer_state_t layer_state_set_user(layer_state_t state) { if (IS_LAYER_ON_STATE(state, FN1) || IS_LAYER_ON_STATE(state, FN2)) { - is_drag_scroll = true; + drag_scroll = true; } else { - is_drag_scroll = false; + drag_scroll = false; } return state; } +/* report_mouse_t pointing_device_task_user(report_mouse_t report) { */ +/* return report; */ +/* } */ + /* * use deferred execution to turn on a layer aften n ms of the key * being held down. */ /* -uinst32_t callback(uint32_t trigger_time, void *cb_arg) { + uinst32_t callback(uint32_t trigger_time, void *cb_arg) { return 0; -} -token = defer_exec(layer_hold_timeout, callback, NULL); -cancel_deferred_exec(token); -*/ + } + token = defer_exec(layer_hold_timeout, callback, NULL); + cancel_deferred_exec(token); + */ static bool fn1_up = false; static uint16_t fn1_release_timer = 0; @@ -90,3 +96,24 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } return true; } + +#define DRAGSCROLL_SHIFT_H 0 +#define DRAGSCROLL_SHIFT_V 0 + +// rejiggering ploopyco's version to not use floats +report_mouse_t pointing_device_task_user(report_mouse_t mouse_report) { + if (drag_scroll) { + mouse_report.h = mouse_report.x >> DRAGSCROLL_SHIFT_H; +#ifdef PLOOPY_DRAGSCROLL_INVERT + mouse_report.v = -(mouse_report.y >> DRAGSCROLL_SHIFT_V); +#else + mouse_report.v = mouse_report.y >> DRAGSCROLL_SHIFT_V; +#endif + + // Clear the X and Y values of the mouse report + mouse_report.x = 0; + mouse_report.y = 0; + } + + return mouse_report; +} -- cgit v1.3