aboutsummaryrefslogtreecommitdiff
path: root/keyboards/ploopyco/trackball_mini/trackball_mini.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/ploopyco/trackball_mini/trackball_mini.c')
-rw-r--r--keyboards/ploopyco/trackball_mini/trackball_mini.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/keyboards/ploopyco/trackball_mini/trackball_mini.c b/keyboards/ploopyco/trackball_mini/trackball_mini.c
index 996c00b22..b50850b54 100644
--- a/keyboards/ploopyco/trackball_mini/trackball_mini.c
+++ b/keyboards/ploopyco/trackball_mini/trackball_mini.c
@@ -40,6 +40,13 @@
40#define PLOOPY_DPI_OPTIONS { CPI375, CPI750, CPI1375 } 40#define PLOOPY_DPI_OPTIONS { CPI375, CPI750, CPI1375 }
41#define PLOOPY_DPI_DEFAULT 2 41#define PLOOPY_DPI_DEFAULT 2
42 42
43#ifndef PLOOPY_DRAGSCROLL_DPI
44# define PLOOPY_DRAGSCROLL_DPI CPI375 // Fixed-DPI Drag Scroll
45#endif
46#ifndef PLOOPY_DRAGSCROLL_MULTIPLIER
47# define PLOOPY_DRAGSCROLL_MULTIPLIER 0.75 // Variable-DPI Drag Scroll
48#endif
49
43// Transformation constants for delta-X and delta-Y 50// Transformation constants for delta-X and delta-Y
44const static float ADNS_X_TRANSFORM = -1.0; 51const static float ADNS_X_TRANSFORM = -1.0;
45const static float ADNS_Y_TRANSFORM = 1.0; 52const static float ADNS_Y_TRANSFORM = 1.0;
@@ -61,6 +68,7 @@ uint16_t lastScroll = 0; // Previous confirmed wheel event
61uint16_t lastMidClick = 0; // Stops scrollwheel from being read if it was pressed 68uint16_t lastMidClick = 0; // Stops scrollwheel from being read if it was pressed
62uint8_t OptLowPin = OPT_ENC1; 69uint8_t OptLowPin = OPT_ENC1;
63bool debug_encoder = false; 70bool debug_encoder = false;
71bool is_drag_scroll = false;
64 72
65__attribute__((weak)) void process_wheel_user(report_mouse_t* mouse_report, int16_t h, int16_t v) { 73__attribute__((weak)) void process_wheel_user(report_mouse_t* mouse_report, int16_t h, int16_t v) {
66 mouse_report->h = h; 74 mouse_report->h = h;
@@ -142,6 +150,16 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
142 adns_set_cpi(dpi_array[keyboard_config.dpi_config]); 150 adns_set_cpi(dpi_array[keyboard_config.dpi_config]);
143 } 151 }
144 152
153 if (keycode == DRAG_SCROLL) {
154#ifndef PLOOPY_DRAGSCROLL_MOMENTARY
155 if (record->event.pressed)
156#endif
157 {
158 is_drag_scroll ^= 1;
159 }
160 adns_set_cpi(is_drag_scroll ? PLOOPY_DRAGSCROLL_DPI : dpi_array[keyboard_config.dpi_config]);
161 }
162
145/* If Mousekeys is disabled, then use handle the mouse button 163/* If Mousekeys is disabled, then use handle the mouse button
146 * keycodes. This makes things simpler, and allows usage of 164 * keycodes. This makes things simpler, and allows usage of
147 * the keycodes in a consistent manner. But only do this if 165 * the keycodes in a consistent manner. But only do this if
@@ -214,6 +232,19 @@ void pointing_device_task(void) {
214 report_mouse_t mouse_report = pointing_device_get_report(); 232 report_mouse_t mouse_report = pointing_device_get_report();
215 process_wheel(&mouse_report); 233 process_wheel(&mouse_report);
216 process_mouse(&mouse_report); 234 process_mouse(&mouse_report);
235
236 if (is_drag_scroll) {
237 mouse_report.h = mouse_report.x;
238#ifdef PLOOPY_DRAGSCROLL_INVERT
239 // Invert vertical scroll direction
240 mouse_report.v = -mouse_report.y;
241#else
242 mouse_report.v = mouse_report.y;
243#endif
244 mouse_report.x = 0;
245 mouse_report.y = 0;
246 }
247
217 pointing_device_set_report(mouse_report); 248 pointing_device_set_report(mouse_report);
218 pointing_device_send(); 249 pointing_device_send();
219} 250}