aboutsummaryrefslogtreecommitdiff
path: root/keyboards/ploopyco
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2021-05-13 19:20:31 -0700
committerGitHub <noreply@github.com>2021-05-13 19:20:31 -0700
commita6807d18222295a9a8016d21466f1ec71d73a34a (patch)
tree13a0dc9a8ea94f3cad825180ac3ae8b2b4021199 /keyboards/ploopyco
parentf594b22332dfb9bc0ead6b4604a050bf8674a800 (diff)
downloadqmk_firmware-a6807d18222295a9a8016d21466f1ec71d73a34a.tar.gz
qmk_firmware-a6807d18222295a9a8016d21466f1ec71d73a34a.zip
[Keyboard][PloopyCo] Fix code for Mini and Nano Trackballs (#12889)
Diffstat (limited to 'keyboards/ploopyco')
-rw-r--r--keyboards/ploopyco/trackball_mini/trackball_mini.c30
-rw-r--r--keyboards/ploopyco/trackball_nano/trackball_nano.c41
-rw-r--r--keyboards/ploopyco/trackball_nano/trackball_nano.h2
3 files changed, 26 insertions, 47 deletions
diff --git a/keyboards/ploopyco/trackball_mini/trackball_mini.c b/keyboards/ploopyco/trackball_mini/trackball_mini.c
index 4ae5df083..d6eb61a2b 100644
--- a/keyboards/ploopyco/trackball_mini/trackball_mini.c
+++ b/keyboards/ploopyco/trackball_mini/trackball_mini.c
@@ -105,22 +105,8 @@ __attribute__((weak)) void process_wheel(report_mouse_t* mouse_report) {
105} 105}
106 106
107__attribute__((weak)) void process_mouse_user(report_mouse_t* mouse_report, int16_t x, int16_t y) { 107__attribute__((weak)) void process_mouse_user(report_mouse_t* mouse_report, int16_t x, int16_t y) {
108 // x and y are swapped 108 mouse_report->x = x;
109 // the sensor is rotated 109 mouse_report->y = y;
110 // by 90 degrees
111 int16_t temp = x;
112 x = y;
113 y = temp;
114
115 // Apply delta-X and delta-Y transformations.
116 float xt = (float) x * ADNS_X_TRANSFORM;
117 float yt = (float) y * ADNS_Y_TRANSFORM;
118
119 int16_t xti = xt;
120 int16_t yti = yt;
121
122 mouse_report->x = xti;
123 mouse_report->y = yti;
124} 110}
125 111
126__attribute__((weak)) void process_mouse(report_mouse_t* mouse_report) { 112__attribute__((weak)) void process_mouse(report_mouse_t* mouse_report) {
@@ -130,7 +116,17 @@ __attribute__((weak)) void process_mouse(report_mouse_t* mouse_report) {
130 if (debug_mouse) 116 if (debug_mouse)
131 dprintf("Raw ] X: %d, Y: %d\n", data.dx, data.dy); 117 dprintf("Raw ] X: %d, Y: %d\n", data.dx, data.dy);
132 118
133 process_mouse_user(mouse_report, data.dx, data.dy); 119 // Apply delta-X and delta-Y transformations.
120 // x and y are swapped
121 // the sensor is rotated
122 // by 90 degrees
123 float xt = (float) data.dy * ADNS_X_TRANSFORM;
124 float yt = (float) data.dx * ADNS_Y_TRANSFORM;
125
126 int16_t xti = (int16_t)xt;
127 int16_t yti = (int16_t)yt;
128
129 process_mouse_user(mouse_report, xti, yti);
134 } 130 }
135} 131}
136 132
diff --git a/keyboards/ploopyco/trackball_nano/trackball_nano.c b/keyboards/ploopyco/trackball_nano/trackball_nano.c
index 93cb60bd4..17cdedac7 100644
--- a/keyboards/ploopyco/trackball_nano/trackball_nano.c
+++ b/keyboards/ploopyco/trackball_nano/trackball_nano.c
@@ -70,33 +70,9 @@ uint16_t lastMidClick = 0; // Stops scrollwheel from being read if it was press
70uint8_t OptLowPin = OPT_ENC1; 70uint8_t OptLowPin = OPT_ENC1;
71bool debug_encoder = false; 71bool debug_encoder = false;
72 72
73__attribute__((weak)) void process_wheel_user(report_mouse_t* mouse_report, int16_t h, int16_t v) {
74 // There's no scroller on this device.
75 return;
76}
77
78__attribute__((weak)) void process_wheel(report_mouse_t* mouse_report) {
79 // There's no scroller on this device.
80 return;
81}
82
83__attribute__((weak)) void process_mouse_user(report_mouse_t* mouse_report, int16_t x, int16_t y) { 73__attribute__((weak)) void process_mouse_user(report_mouse_t* mouse_report, int16_t x, int16_t y) {
84 // x and y are swapped 74 mouse_report->x = x;
85 // the sensor is rotated 75 mouse_report->y = y;
86 // by 90 degrees
87 int16_t temp = x;
88 x = y;
89 y = temp;
90
91 // Apply delta-X and delta-Y transformations.
92 float xt = (float) x * ADNS_X_TRANSFORM;
93 float yt = (float) y * ADNS_Y_TRANSFORM;
94
95 int16_t xti = xt;
96 int16_t yti = yt;
97
98 mouse_report->x = xti;
99 mouse_report->y = yti;
100} 76}
101 77
102__attribute__((weak)) void process_mouse(report_mouse_t* mouse_report) { 78__attribute__((weak)) void process_mouse(report_mouse_t* mouse_report) {
@@ -106,7 +82,17 @@ __attribute__((weak)) void process_mouse(report_mouse_t* mouse_report) {
106 if (debug_mouse) 82 if (debug_mouse)
107 dprintf("Raw ] X: %d, Y: %d\n", data.dx, data.dy); 83 dprintf("Raw ] X: %d, Y: %d\n", data.dx, data.dy);
108 84
109 process_mouse_user(mouse_report, data.dx, data.dy); 85 // Apply delta-X and delta-Y transformations.
86 // x and y are swapped
87 // the sensor is rotated
88 // by 90 degrees
89 float xt = (float) data.dy * ADNS_X_TRANSFORM;
90 float yt = (float) data.dx * ADNS_Y_TRANSFORM;
91
92 int16_t xti = (int16_t)xt;
93 int16_t yti = (int16_t)yt;
94
95 process_mouse_user(mouse_report, xti, yti);
110 } 96 }
111} 97}
112 98
@@ -182,7 +168,6 @@ void pointing_device_init(void) {
182 168
183void pointing_device_task(void) { 169void pointing_device_task(void) {
184 report_mouse_t mouse_report = pointing_device_get_report(); 170 report_mouse_t mouse_report = pointing_device_get_report();
185 process_wheel(&mouse_report);
186 process_mouse(&mouse_report); 171 process_mouse(&mouse_report);
187 pointing_device_set_report(mouse_report); 172 pointing_device_set_report(mouse_report);
188 pointing_device_send(); 173 pointing_device_send();
diff --git a/keyboards/ploopyco/trackball_nano/trackball_nano.h b/keyboards/ploopyco/trackball_nano/trackball_nano.h
index 4bffb0460..5692383b1 100644
--- a/keyboards/ploopyco/trackball_nano/trackball_nano.h
+++ b/keyboards/ploopyco/trackball_nano/trackball_nano.h
@@ -33,8 +33,6 @@
33 33
34void process_mouse(report_mouse_t* mouse_report); 34void process_mouse(report_mouse_t* mouse_report);
35void process_mouse_user(report_mouse_t* mouse_report, int16_t x, int16_t y); 35void process_mouse_user(report_mouse_t* mouse_report, int16_t x, int16_t y);
36void process_wheel(report_mouse_t* mouse_report);
37void process_wheel_user(report_mouse_t* mouse_report, int16_t h, int16_t v);
38 36
39#define LAYOUT(k00) {{ KC_NO }} 37#define LAYOUT(k00) {{ KC_NO }}
40 38