diff options
Diffstat (limited to 'keyboards/ploopyco/trackball_nano/trackball_nano.c')
| -rw-r--r-- | keyboards/ploopyco/trackball_nano/trackball_nano.c | 41 |
1 files changed, 13 insertions, 28 deletions
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 | |||
| 70 | uint8_t OptLowPin = OPT_ENC1; | 70 | uint8_t OptLowPin = OPT_ENC1; |
| 71 | bool debug_encoder = false; | 71 | bool 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 | ||
| 183 | void pointing_device_task(void) { | 169 | void 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(); |
