aboutsummaryrefslogtreecommitdiff
path: root/keyboards/ploopyco/trackball/trackball.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/ploopyco/trackball/trackball.c')
-rw-r--r--keyboards/ploopyco/trackball/trackball.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/keyboards/ploopyco/trackball/trackball.c b/keyboards/ploopyco/trackball/trackball.c
index da4bbf224..25b36574a 100644
--- a/keyboards/ploopyco/trackball/trackball.c
+++ b/keyboards/ploopyco/trackball/trackball.c
@@ -31,7 +31,8 @@
31# define OPT_SCALE 1 // Multiplier for wheel 31# define OPT_SCALE 1 // Multiplier for wheel
32#endif 32#endif
33#ifndef PLOOPY_DPI_OPTIONS 33#ifndef PLOOPY_DPI_OPTIONS
34# define PLOOPY_DPI_OPTIONS { 1200, 1600, 2400 } 34# define PLOOPY_DPI_OPTIONS \
35 { 1200, 1600, 2400 }
35# ifndef PLOOPY_DPI_DEFAULT 36# ifndef PLOOPY_DPI_DEFAULT
36# define PLOOPY_DPI_DEFAULT 1 37# define PLOOPY_DPI_DEFAULT 1
37# endif 38# endif
@@ -40,10 +41,10 @@
40# define PLOOPY_DPI_DEFAULT 0 41# define PLOOPY_DPI_DEFAULT 0
41#endif 42#endif
42#ifndef PLOOPY_DRAGSCROLL_DPI 43#ifndef PLOOPY_DRAGSCROLL_DPI
43# define PLOOPY_DRAGSCROLL_DPI 100 // Fixed-DPI Drag Scroll 44# define PLOOPY_DRAGSCROLL_DPI 100 // Fixed-DPI Drag Scroll
44#endif 45#endif
45#ifndef PLOOPY_DRAGSCROLL_MULTIPLIER 46#ifndef PLOOPY_DRAGSCROLL_MULTIPLIER
46# define PLOOPY_DRAGSCROLL_MULTIPLIER 0.75 // Variable-DPI Drag Scroll 47# define PLOOPY_DRAGSCROLL_MULTIPLIER 0.75 // Variable-DPI Drag Scroll
47#endif 48#endif
48 49
49keyboard_config_t keyboard_config; 50keyboard_config_t keyboard_config;
@@ -65,7 +66,24 @@ uint8_t OptLowPin = OPT_ENC1;
65bool debug_encoder = false; 66bool debug_encoder = false;
66bool is_drag_scroll = false; 67bool is_drag_scroll = false;
67 68
68void process_wheel(report_mouse_t* mouse_report) { 69__attribute__((weak)) bool encoder_update_user(uint8_t index, bool clockwise) { return true; }
70
71bool encoder_update_kb(uint8_t index, bool clockwise) {
72 if (!encoder_update_user(index, clockwise)) {
73 return false;
74 }
75#ifdef MOUSEKEY_ENABLE
76 tap_code(clockwise ? KC_WH_U : KC_WH_D);
77#else
78 mouse_report_t mouse_report = pointing_device_get_report();
79 mouse_report.v = clockwise ? 1 : -1;
80 pointing_device_set_report(mouse_report);
81 pointing_device_send();
82#endif
83 return true;
84}
85
86void process_wheel(void) {
69 // TODO: Replace this with interrupt driven code, polling is S L O W 87 // TODO: Replace this with interrupt driven code, polling is S L O W
70 // Lovingly ripped from the Ploopy Source 88 // Lovingly ripped from the Ploopy Source
71 89
@@ -94,11 +112,11 @@ void process_wheel(report_mouse_t* mouse_report) {
94 int dir = opt_encoder_handler(p1, p2); 112 int dir = opt_encoder_handler(p1, p2);
95 113
96 if (dir == 0) return; 114 if (dir == 0) return;
97 mouse_report->v = (int8_t)(dir * OPT_SCALE); 115 encoder_update_kb(0, dir == 1);
98} 116}
99 117
100report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) { 118report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) {
101 process_wheel(&mouse_report); 119 process_wheel();
102 120
103 if (is_drag_scroll) { 121 if (is_drag_scroll) {
104 mouse_report.h = mouse_report.x; 122 mouse_report.h = mouse_report.x;