f5b495e06e257796a9be845f47bfc375fece81f8

Author
Dasky <32983009+daskygit@users.noreply.github.com>
Committer
GitHub <noreply@github.com>
Date

Message

Move pointing device driver code (#24445)

Co-authored-by: Drashna Jaelre <drashna@live.com>

Diff

This diff is truncated to protect this page.

   1diff --git a/builddefs/common_features.mk b/builddefs/common_features.mk
   2index cc13fbd3f7392104c7679089f5316b3ccde3507b..2eb7056b6f6e3637e6ee28b50f92a4c2952a61fe 100644
   3--- a/builddefs/common_features.mk
   4+++ b/builddefs/common_features.mk
   5@@ -129,13 +129,13 @@ ifeq ($(strip $(POINTING_DEVICE_ENABLE)), yes)
   6         MOUSE_ENABLE := yes
   7         VPATH += $(QUANTUM_DIR)/pointing_device
   8         SRC += $(QUANTUM_DIR)/pointing_device/pointing_device.c
   9-        SRC += $(QUANTUM_DIR)/pointing_device/pointing_device_drivers.c
  10         SRC += $(QUANTUM_DIR)/pointing_device/pointing_device_auto_mouse.c
  11         ifneq ($(strip $(POINTING_DEVICE_DRIVER)), custom)
  12             SRC += drivers/sensors/$(strip $(POINTING_DEVICE_DRIVER)).c
  13             OPT_DEFS += -DPOINTING_DEVICE_DRIVER_$(strip $(shell echo $(POINTING_DEVICE_DRIVER) | tr '[:lower:]' '[:upper:]'))
  14         endif
  15         OPT_DEFS += -DPOINTING_DEVICE_DRIVER_$(strip $(POINTING_DEVICE_DRIVER))
  16+        OPT_DEFS += -DPOINTING_DEVICE_DRIVER_NAME=$(strip $(POINTING_DEVICE_DRIVER))
  17         ifeq ($(strip $(POINTING_DEVICE_DRIVER)), adns9800)
  18             SPI_DRIVER_REQUIRED = yes
  19         else ifeq ($(strip $(POINTING_DEVICE_DRIVER)), analog_joystick)
  20diff --git a/drivers/sensors/adns5050.c b/drivers/sensors/adns5050.c
  21index f28a5dcc455a038da3663f04ccfa09b3f350b87a..1768c9f3b4a276e2c5d35c334ad9ea2fc70bd6cf 100644
  22--- a/drivers/sensors/adns5050.c
  23+++ b/drivers/sensors/adns5050.c
  24@@ -21,6 +21,7 @@
  25 #include "wait.h"
  26 #include "debug.h"
  27 #include "gpio.h"
  28+#include "pointing_device_internal.h"
  29 
  30 // Registers
  31 // clang-format off
  32@@ -45,6 +46,13 @@
  33 #define REG_MOTION_BURST   0x63
  34 // clang-format on
  35 
  36+const pointing_device_driver_t adns5050_pointing_device_driver = {
  37+    .init       = adns5050_init,
  38+    .get_report = adns5050_get_report,
  39+    .set_cpi    = adns5050_set_cpi,
  40+    .get_cpi    = adns5050_get_cpi,
  41+};
  42+
  43 static bool powered_down = false;
  44 
  45 void adns5050_init(void) {
  46@@ -226,3 +234,15 @@ void adns5050_power_down(void) {
  47         adns5050_write_reg(REG_MOUSE_CONTROL, 0b10);
  48     }
  49 }
  50+
  51+report_mouse_t adns5050_get_report(report_mouse_t mouse_report) {
  52+    report_adns5050_t data = adns5050_read_burst();
  53+
  54+    if (data.dx != 0 || data.dy != 0) {
  55+        pd_dprintf("Raw ] X: %d, Y: %d\n", data.dx, data.dy);
  56+        mouse_report.x = (mouse_xy_report_t)data.dx;
  57+        mouse_report.y = (mouse_xy_report_t)data.dy;
  58+    }
  59+
  60+    return mouse_report;
  61+}
  62diff --git a/drivers/sensors/adns5050.h b/drivers/sensors/adns5050.h
  63index 586f16b590b010815298dc65327deb1d787c23e5..4dfcbc3c70d8506c98042b9e4ea802bf19626a2b 100644
  64--- a/drivers/sensors/adns5050.h
  65+++ b/drivers/sensors/adns5050.h
  66@@ -21,6 +21,7 @@
  67 
  68 #include <stdbool.h>
  69 #include <stdint.h>
  70+#include "pointing_device.h"
  71 
  72 // CPI values
  73 // clang-format off
  74@@ -69,6 +70,8 @@ typedef struct {
  75     int8_t dy;
  76 } report_adns5050_t;
  77 
  78+const pointing_device_driver_t adns5050_pointing_device_driver;
  79+
  80 // A bunch of functions to implement the ADNS5050-specific serial protocol.
  81 // Note that the "serial.h" driver is insufficient, because it does not
  82 // manually manipulate a serial clock signal.
  83@@ -84,3 +87,4 @@ uint16_t          adns5050_get_cpi(void);
  84 int8_t            convert_twoscomp(uint8_t data);
  85 bool              adns5050_check_signature(void);
  86 void              adns5050_power_down(void);
  87+report_mouse_t    adns5050_get_report(report_mouse_t mouse_report);
  88diff --git a/drivers/sensors/adns9800.c b/drivers/sensors/adns9800.c
  89index f4abdb508745aa3c04078113b3531c72aafa891a..0dbc528351c2c2d4a18b9a2ea6c57b24d00dd8b2 100644
  90--- a/drivers/sensors/adns9800.c
  91+++ b/drivers/sensors/adns9800.c
  92@@ -77,6 +77,13 @@
  93 #define MSB1                0x80
  94 // clang-format on
  95 
  96+const pointing_device_driver_t adns9800_pointing_device_driver = {
  97+    .init       = adns9800_init,
  98+    .get_report = adns9800_get_report_driver,
  99+    .set_cpi    = adns9800_set_cpi,
 100+    .get_cpi    = adns9800_get_cpi,
 101+};
 102+
 103 uint16_t __attribute__((weak)) adns9800_srom_get_length(void) {
 104     return 0;
 105 }
 106@@ -236,3 +243,12 @@ report_adns9800_t adns9800_get_report(void) {
 107 
 108     return report;
 109 }
 110+
 111+report_mouse_t adns9800_get_report_driver(report_mouse_t mouse_report) {
 112+    report_adns9800_t sensor_report = adns9800_get_report();
 113+
 114+    mouse_report.x = CONSTRAIN_HID_XY(sensor_report.x);
 115+    mouse_report.y = CONSTRAIN_HID_XY(sensor_report.y);
 116+
 117+    return mouse_report;
 118+}
 119diff --git a/drivers/sensors/adns9800.h b/drivers/sensors/adns9800.h
 120index 3f1a005789f1760e1d5de1d4b9bc5e804180ae42..023f31b132356215a55851c4d1a92cf0159d2853 100644
 121--- a/drivers/sensors/adns9800.h
 122+++ b/drivers/sensors/adns9800.h
 123@@ -17,6 +17,7 @@
 124 #pragma once
 125 
 126 #include <stdint.h>
 127+#include "pointing_device.h"
 128 
 129 #ifndef ADNS9800_CPI
 130 #    define ADNS9800_CPI 1600
 131@@ -60,6 +61,8 @@ typedef struct {
 132     int16_t y;
 133 } report_adns9800_t;
 134 
 135+const pointing_device_driver_t adns9800_pointing_device_driver;
 136+
 137 void              adns9800_init(void);
 138 config_adns9800_t adns9800_get_config(void);
 139 void              adns9800_set_config(config_adns9800_t);
 140@@ -67,3 +70,4 @@ uint16_t          adns9800_get_cpi(void);
 141 void              adns9800_set_cpi(uint16_t cpi);
 142 /* Reads and clears the current delta values on the ADNS sensor */
 143 report_adns9800_t adns9800_get_report(void);
 144+report_mouse_t    adns9800_get_report_driver(report_mouse_t mouse_report);
 145diff --git a/drivers/sensors/analog_joystick.c b/drivers/sensors/analog_joystick.c
 146index 15b35a45f25a5969e036c9d4fc28a6d7663f51ba..93bbaa1b51bc077c25cb795c07b8fcb5ee7fbfaa 100644
 147--- a/drivers/sensors/analog_joystick.c
 148+++ b/drivers/sensors/analog_joystick.c
 149@@ -20,6 +20,14 @@
 150 #include "wait.h"
 151 #include "timer.h"
 152 #include <stdlib.h>
 153+#include "pointing_device_internal.h"
 154+
 155+const pointing_device_driver_t analog_joystick_pointing_device_driver = {
 156+    .init       = analog_joystick_init,
 157+    .get_report = analog_joystick_get_report,
 158+    .set_cpi    = NULL,
 159+    .get_cpi    = NULL,
 160+};
 161 
 162 // Set Parameters
 163 #ifndef ANALOG_JOYSTICK_AUTO_AXIS
 164@@ -145,3 +153,16 @@ void analog_joystick_init(void) {
 165     maxAxisValues[1] = yOrigin + 100;
 166 #endif
 167 }
 168+
 169+report_mouse_t analog_joystick_get_report(report_mouse_t mouse_report) {
 170+    report_analog_joystick_t data = analog_joystick_read();
 171+
 172+    pd_dprintf("Raw ] X: %d, Y: %d\n", data.x, data.y);
 173+
 174+    mouse_report.x = data.x;
 175+    mouse_report.y = data.y;
 176+
 177+    mouse_report.buttons = pointing_device_handle_buttons(mouse_report.buttons, data.button, POINTING_DEVICE_BUTTON1);
 178+
 179+    return mouse_report;
 180+}
 181diff --git a/drivers/sensors/analog_joystick.h b/drivers/sensors/analog_joystick.h
 182index 6892a08817f24427c66fc2a60488ac3df7c25c3e..c84da83db13b95254b6fc81f05e10413453d0c56 100644
 183--- a/drivers/sensors/analog_joystick.h
 184+++ b/drivers/sensors/analog_joystick.h
 185@@ -18,6 +18,7 @@
 186 
 187 #include <stdbool.h>
 188 #include <stdint.h>
 189+#include "pointing_device.h"
 190 
 191 #ifndef ANALOG_JOYSTICK_X_AXIS_PIN
 192 #    error No pin specified for X Axis
 193@@ -42,6 +43,8 @@
 194 #    define ANALOG_JOYSTICK_SPEED_MAX 2
 195 #endif
 196 
 197+const pointing_device_driver_t analog_joystick_pointing_device_driver;
 198+
 199 typedef struct {
 200     int8_t x;
 201     int8_t y;
 202@@ -49,3 +52,4 @@ typedef struct {
 203 } report_analog_joystick_t;
 204 report_analog_joystick_t analog_joystick_read(void);
 205 void                     analog_joystick_init(void);
 206+report_mouse_t           analog_joystick_get_report(report_mouse_t mouse_report);
 207diff --git a/drivers/sensors/azoteq_iqs5xx.c b/drivers/sensors/azoteq_iqs5xx.c
 208index 367873eb0624a010935dd6e26ca080897577cc23..1bb64f1984467819a6da44cc1ba9197428560082 100644
 209--- a/drivers/sensors/azoteq_iqs5xx.c
 210+++ b/drivers/sensors/azoteq_iqs5xx.c
 211@@ -98,6 +98,13 @@
 212 #define AZOTEQ_IQS5XX_INCH_TO_RESOLUTION_Y(inch) (DIVIDE_UNSIGNED_ROUND((inch) * (uint32_t)AZOTEQ_IQS5XX_HEIGHT_MM * 10, 254))
 213 #define AZOTEQ_IQS5XX_RESOLUTION_Y_TO_INCH(px) (DIVIDE_UNSIGNED_ROUND((px) * (uint32_t)254, AZOTEQ_IQS5XX_HEIGHT_MM * 10))
 214 
 215+const pointing_device_driver_t azoteq_iqs5xx_pointing_device_driver = {
 216+    .init       = azoteq_iqs5xx_init,
 217+    .get_report = azoteq_iqs5xx_get_report,
 218+    .set_cpi    = azoteq_iqs5xx_set_cpi,
 219+    .get_cpi    = azoteq_iqs5xx_get_cpi,
 220+};
 221+
 222 static uint16_t azoteq_iqs5xx_product_number = AZOTEQ_IQS5XX_UNKNOWN;
 223 
 224 static struct {
 225@@ -312,3 +319,105 @@ void azoteq_iqs5xx_setup_resolution(void) {
 226     azoteq_iqs5xx_device_resolution_t.resolution_y = AZOTEQ_IQS5XX_RESOLUTION_Y;
 227 #endif
 228 }
 229+
 230+static i2c_status_t azoteq_iqs5xx_init_status = 1;
 231+
 232+void azoteq_iqs5xx_init(void) {
 233+    i2c_init();
 234+    azoteq_iqs5xx_wake();
 235+    azoteq_iqs5xx_reset_suspend(true, false, true);
 236+    wait_ms(100);
 237+    azoteq_iqs5xx_wake();
 238+    if (azoteq_iqs5xx_get_product() != AZOTEQ_IQS5XX_UNKNOWN) {
 239+        azoteq_iqs5xx_setup_resolution();
 240+        azoteq_iqs5xx_init_status = azoteq_iqs5xx_set_report_rate(AZOTEQ_IQS5XX_REPORT_RATE, AZOTEQ_IQS5XX_ACTIVE, false);
 241+        azoteq_iqs5xx_init_status |= azoteq_iqs5xx_set_event_mode(false, false);
 242+        azoteq_iqs5xx_init_status |= azoteq_iqs5xx_set_reati(true, false);
 243+#if defined(AZOTEQ_IQS5XX_ROTATION_90)
 244+        azoteq_iqs5xx_init_status |= azoteq_iqs5xx_set_xy_config(false, true, true, true, false);
 245+#elif defined(AZOTEQ_IQS5XX_ROTATION_180)
 246+        azoteq_iqs5xx_init_status |= azoteq_iqs5xx_set_xy_config(true, true, false, true, false);
 247+#elif defined(AZOTEQ_IQS5XX_ROTATION_270)
 248+        azoteq_iqs5xx_init_status |= azoteq_iqs5xx_set_xy_config(true, false, true, true, false);
 249+#else
 250+        azoteq_iqs5xx_init_status |= azoteq_iqs5xx_set_xy_config(false, false, false, true, false);
 251+#endif
 252+        azoteq_iqs5xx_init_status |= azoteq_iqs5xx_set_gesture_config(true);
 253+        wait_ms(AZOTEQ_IQS5XX_REPORT_RATE + 1);
 254+    }
 255+};
 256+
 257+report_mouse_t azoteq_iqs5xx_get_report(report_mouse_t mouse_report) {
 258+    report_mouse_t temp_report           = {0};
 259+    static uint8_t previous_button_state = 0;
 260+    static uint8_t read_error_count      = 0;
 261+
 262+    if (azoteq_iqs5xx_init_status == I2C_STATUS_SUCCESS) {
 263+        azoteq_iqs5xx_base_data_t base_data = {0};
 264+#if !defined(POINTING_DEVICE_MOTION_PIN)
 265+        azoteq_iqs5xx_wake();
 266+#endif
 267+        i2c_status_t status          = azoteq_iqs5xx_get_base_data(&base_data);
 268+        bool         ignore_movement = false;
 269+
 270+        if (status == I2C_STATUS_SUCCESS) {
 271+            // pd_dprintf("IQS5XX - previous cycle time: %d \n", base_data.previous_cycle_time);
 272+            read_error_count = 0;
 273+            if (base_data.gesture_events_0.single_tap || base_data.gesture_events_0.press_and_hold) {
 274+                pd_dprintf("IQS5XX - Single tap/hold.\n");
 275+                temp_report.buttons = pointing_device_handle_buttons(temp_report.buttons, true, POINTING_DEVICE_BUTTON1);
 276+            } else if (base_data.gesture_events_1.two_finger_tap) {
 277+                pd_dprintf("IQS5XX - Two finger tap.\n");
 278+                temp_report.buttons = pointing_device_handle_buttons(temp_report.buttons, true, POINTING_DEVICE_BUTTON2);
 279+            } else if (base_data.gesture_events_0.swipe_x_neg) {
 280+                pd_dprintf("IQS5XX - X-.\n");
 281+                temp_report.buttons = pointing_device_handle_buttons(temp_report.buttons, true, POINTING_DEVICE_BUTTON4);
 282+                ignore_movement     = true;
 283+            } else if (base_data.gesture_events_0.swipe_x_pos) {
 284+                pd_dprintf("IQS5XX - X+.\n");
 285+                temp_report.buttons = pointing_device_handle_buttons(temp_report.buttons, true, POINTING_DEVICE_BUTTON5);
 286+                ignore_movement     = true;
 287+            } else if (base_data.gesture_events_0.swipe_y_neg) {
 288+                pd_dprintf("IQS5XX - Y-.\n");
 289+                temp_report.buttons = pointing_device_handle_buttons(temp_report.buttons, true, POINTING_DEVICE_BUTTON6);
 290+                ignore_movement     = true;
 291+            } else if (base_data.gesture_events_0.swipe_y_pos) {
 292+                pd_dprintf("IQS5XX - Y+.\n");
 293+                temp_report.buttons = pointing_device_handle_buttons(temp_report.buttons, true, POINTING_DEVICE_BUTTON3);
 294+                ignore_movement     = true;
 295+            } else if (base_data.gesture_events_1.zoom) {
 296+                if (AZOTEQ_IQS5XX_COMBINE_H_L_BYTES(base_data.x.h, base_data.x.l) < 0) {
 297+                    pd_dprintf("IQS5XX - Zoom out.\n");
 298+                    temp_report.buttons = pointing_device_handle_buttons(temp_report.buttons, true, POINTING_DEVICE_BUTTON7);
 299+                } else if (AZOTEQ_IQS5XX_COMBINE_H_L_BYTES(base_data.x.h, base_data.x.l) > 0) {
 300+                    pd_dprintf("IQS5XX - Zoom in.\n");
 301+                    temp_report.buttons = pointing_device_handle_buttons(temp_report.buttons, true, POINTING_DEVICE_BUTTON8);
 302+                }
 303+            } else if (base_data.gesture_events_1.scroll) {
 304+                pd_dprintf("IQS5XX - Scroll.\n");
 305+                temp_report.h = CONSTRAIN_HID(AZOTEQ_IQS5XX_COMBINE_H_L_BYTES(base_data.x.h, base_data.x.l));
 306+                temp_report.v = CONSTRAIN_HID(AZOTEQ_IQS5XX_COMBINE_H_L_BYTES(base_data.y.h, base_data.y.l));
 307+            }
 308+            if (base_data.number_of_fingers == 1 && !ignore_movement) {
 309+                temp_report.x = CONSTRAIN_HID_XY(AZOTEQ_IQS5XX_COMBINE_H_L_BYTES(base_data.x.h, base_data.x.l));
 310+                temp_report.y = CONSTRAIN_HID_XY(AZOTEQ_IQS5XX_COMBINE_H_L_BYTES(base_data.y.h, base_data.y.l));
 311diff --git a/drivers/sensors/azoteq_iqs5xx.h b/drivers/sensors/azoteq_iqs5xx.h
 312index 704ec2bab3bd7b691457a01edb03b544c8ae9b76..4190fe470c77806a5ac66ab8c7fa1cb1f9ff62d0 100644
 313--- a/drivers/sensors/azoteq_iqs5xx.h
 314+++ b/drivers/sensors/azoteq_iqs5xx.h
 315@@ -176,6 +176,8 @@ typedef struct {
 316 #    define POINTING_DEVICE_TASK_THROTTLE_MS AZOTEQ_IQS5XX_REPORT_RATE
 317 #endif
 318 
 319+const pointing_device_driver_t azoteq_iqs5xx_pointing_device_driver;
 320+
 321 void           azoteq_iqs5xx_init(void);
 322 i2c_status_t   azoteq_iqs5xx_wake(void);
 323 report_mouse_t azoteq_iqs5xx_get_report(report_mouse_t mouse_report);
 324diff --git a/drivers/sensors/cirque_pinnacle.c b/drivers/sensors/cirque_pinnacle.c
 325index 9afc9df804449ba404d88847388e5b20be4840a4..893cb98bf058d8efca7fbae4dc07e737b756a887 100644
 326--- a/drivers/sensors/cirque_pinnacle.c
 327+++ b/drivers/sensors/cirque_pinnacle.c
 328@@ -4,6 +4,7 @@
 329 // refer to documentation: Gen2 and Gen3 (Pinnacle ASIC) at https://www.cirque.com/documentation
 330 
 331 #include "cirque_pinnacle.h"
 332+#include "cirque_pinnacle_gestures.h"
 333 #include "wait.h"
 334 #include "timer.h"
 335 
 336@@ -350,3 +351,144 @@ pinnacle_data_t cirque_pinnacle_read_data(void) {
 337     result.valid = true;
 338     return result;
 339 }
 340+
 341+#ifdef POINTING_DEVICE_GESTURES_CURSOR_GLIDE_ENABLE
 342+static bool cursor_glide_enable = true;
 343+
 344+static cursor_glide_context_t glide = {.config = {
 345+                                           .coef       = 102, /* Good default friction coef */
 346+                                           .interval   = 10,  /* 100sps */
 347+                                           .trigger_px = 10,  /* Default threshold in case of hover, set to 0 if you'd like */
 348+                                       }};
 349+
 350+void cirque_pinnacle_enable_cursor_glide(bool enable) {
 351+    cursor_glide_enable = enable;
 352+}
 353+
 354+void cirque_pinnacle_configure_cursor_glide(float trigger_px) {
 355+    glide.config.trigger_px = trigger_px;
 356+}
 357+#endif
 358+
 359+#if CIRQUE_PINNACLE_POSITION_MODE
 360+
 361+#    ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE
 362+static bool is_touch_down;
 363+
 364+bool auto_mouse_activation(report_mouse_t mouse_report) {
 365+    return is_touch_down || mouse_report.x != 0 || mouse_report.y != 0 || mouse_report.h != 0 || mouse_report.v != 0 || mouse_report.buttons;
 366+}
 367+#    endif
 368+
 369+report_mouse_t cirque_pinnacle_get_report(report_mouse_t mouse_report) {
 370+    uint16_t          scale     = cirque_pinnacle_get_scale();
 371+    pinnacle_data_t   touchData = cirque_pinnacle_read_data();
 372+    mouse_xy_report_t report_x = 0, report_y = 0;
 373+    static uint16_t   x = 0, y = 0, last_scale = 0;
 374+
 375+#    if defined(CIRQUE_PINNACLE_TAP_ENABLE)
 376+    mouse_report.buttons = pointing_device_handle_buttons(mouse_report.buttons, false, POINTING_DEVICE_BUTTON1);
 377+#    endif
 378+#    ifdef POINTING_DEVICE_GESTURES_CURSOR_GLIDE_ENABLE
 379+    cursor_glide_t glide_report = {0};
 380+
 381+    if (cursor_glide_enable) {
 382+        glide_report = cursor_glide_check(&glide);
 383+    }
 384+#    endif
 385+
 386+    if (!touchData.valid) {
 387+#    ifdef POINTING_DEVICE_GESTURES_CURSOR_GLIDE_ENABLE
 388+        if (cursor_glide_enable && glide_report.valid) {
 389+            report_x = glide_report.dx;
 390+            report_y = glide_report.dy;
 391+            goto mouse_report_update;
 392+        }
 393+#    endif
 394+        return mouse_report;
 395+    }
 396+
 397+    if (touchData.touchDown) {
 398+        pd_dprintf("cirque_pinnacle touchData x=%4d y=%4d z=%2d\n", touchData.xValue, touchData.yValue, touchData.zValue);
 399+    }
 400+
 401+#    ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE
 402+    is_touch_down = touchData.touchDown;
 403+#    endif
 404+
 405+    // Scale coordinates to arbitrary X, Y resolution
 406+    cirque_pinnacle_scale_data(&touchData, scale, scale);
 407+
 408+    if (!cirque_pinnacle_gestures(&mouse_report, touchData)) {
 409+        if (last_scale && scale == last_scale && x && y && touchData.xValue && touchData.yValue) {
 410+            report_x = CONSTRAIN_HID_XY((int16_t)(touchData.xValue - x));
 411+            report_y = CONSTRAIN_HID_XY((int16_t)(touchData.yValue - y));
 412+        }
 413+        x          = touchData.xValue;
 414+        y          = touchData.yValue;
 415+        last_scale = scale;
 416+
 417+#    ifdef POINTING_DEVICE_GESTURES_CURSOR_GLIDE_ENABLE
 418+        if (cursor_glide_enable) {
 419+            if (touchData.touchDown) {
 420+                cursor_glide_update(&glide, report_x, report_y, touchData.zValue);
 421+            } else if (!glide_report.valid) {
 422+                glide_report = cursor_glide_start(&glide);
 423+                if (glide_report.valid) {
 424+                    report_x = glide_report.dx;
 425+                    report_y = glide_report.dy;
 426+                }
 427+            }
 428diff --git a/drivers/sensors/cirque_pinnacle.h b/drivers/sensors/cirque_pinnacle.h
 429index 8717b32991113f7ad71b2338e4971569be388947..1a17e539a402ba9b6d3ab4429cdd61ec41829a46 100644
 430--- a/drivers/sensors/cirque_pinnacle.h
 431+++ b/drivers/sensors/cirque_pinnacle.h
 432@@ -6,6 +6,7 @@
 433 #include <stdint.h>
 434 #include <stdbool.h>
 435 #include "pointing_device_internal.h"
 436+#include "pointing_device.h"
 437 
 438 #ifndef CIRQUE_PINNACLE_TIMEOUT
 439 #    define CIRQUE_PINNACLE_TIMEOUT 20 // I2C timeout in milliseconds
 440@@ -109,6 +110,10 @@ typedef struct {
 441 #endif
 442 } pinnacle_data_t;
 443 
 444+#define cirque_pinnacle_i2c_pointing_device_driver cirque_pinnacle_pointing_device_driver
 445+#define cirque_pinnacle_spi_pointing_device_driver cirque_pinnacle_pointing_device_driver
 446+const pointing_device_driver_t cirque_pinnacle_pointing_device_driver;
 447+
 448 void            cirque_pinnacle_init(void);
 449 void            cirque_pinnacle_calibrate(void);
 450 void            cirque_pinnacle_cursor_smoothing(bool enable);
 451@@ -116,3 +121,6 @@ pinnacle_data_t cirque_pinnacle_read_data(void);
 452 void            cirque_pinnacle_scale_data(pinnacle_data_t* coordinates, uint16_t xResolution, uint16_t yResolution);
 453 uint16_t        cirque_pinnacle_get_scale(void);
 454 void            cirque_pinnacle_set_scale(uint16_t scale);
 455+uint16_t        cirque_pinnacle_get_cpi(void);
 456+void            cirque_pinnacle_set_cpi(uint16_t cpi);
 457+report_mouse_t  cirque_pinnacle_get_report(report_mouse_t mouse_report);
 458diff --git a/drivers/sensors/paw3204.c b/drivers/sensors/paw3204.c
 459index 28c47522ed55e4bf4f59d5d591ad7cbb3565a6ea..475821f175c06d0808cc00b18659edb66947f88c 100644
 460--- a/drivers/sensors/paw3204.c
 461+++ b/drivers/sensors/paw3204.c
 462@@ -20,6 +20,7 @@
 463 #include "wait.h"
 464 #include "debug.h"
 465 #include "gpio.h"
 466+#include "pointing_device_internal.h"
 467 
 468 #define REG_PID1 0x00
 469 #define REG_PID2 0x01
 470@@ -50,6 +51,13 @@ void    paw3204_serial_write(uint8_t reg_addr);
 471 uint8_t paw3204_read_reg(uint8_t reg_addr);
 472 void    paw3204_write_reg(uint8_t reg_addr, uint8_t data);
 473 
 474+const pointing_device_driver_t paw3204_pointing_device_driver = {
 475+    .init       = paw3204_init,
 476+    .get_report = paw3204_get_report,
 477+    .set_cpi    = paw3204_set_cpi,
 478+    .get_cpi    = paw3204_get_cpi,
 479+};
 480+
 481 void paw3204_init(void) {
 482     gpio_set_pin_output(PAW3204_SCLK_PIN);     // setclockpin to output
 483     gpio_set_pin_input_high(PAW3204_SDIO_PIN); // set datapin input high
 484@@ -170,3 +178,15 @@ uint16_t paw3204_get_cpi(void) {
 485 uint8_t read_pid_paw3204(void) {
 486     return paw3204_read_reg(REG_PID1);
 487 }
 488+
 489+report_mouse_t paw3204_get_report(report_mouse_t mouse_report) {
 490+    report_paw3204_t data = paw3204_read();
 491+    if (data.isMotion) {
 492+        pd_dprintf("Raw ] X: %d, Y: %d\n", data.x, data.y);
 493+
 494+        mouse_report.x = data.x;
 495+        mouse_report.y = data.y;
 496+    }
 497+
 498+    return mouse_report;
 499+}
 500diff --git a/drivers/sensors/paw3204.h b/drivers/sensors/paw3204.h
 501index 7f487d90dcea3475352fe5d746fe6b2b695ebf84..a4bb8e16a67678bf19c3daaa8cfcffab7c2199d2 100644
 502--- a/drivers/sensors/paw3204.h
 503+++ b/drivers/sensors/paw3204.h
 504@@ -18,6 +18,7 @@
 505 
 506 #include <stdint.h>
 507 #include <stdbool.h>
 508+#include "pointing_device.h"
 509 
 510 #ifndef PAW3204_SCLK_PIN
 511 #    ifdef POINTING_DEVICE_SCLK_PIN
 512@@ -40,6 +41,8 @@ typedef struct {
 513     bool    isMotion;
 514 } report_paw3204_t;
 515 
 516+const pointing_device_driver_t paw3204_pointing_device_driver;
 517+
 518 /**
 519  * @brief Initializes the sensor so it is in a working state and ready to
 520  * be polled for data.
 521@@ -74,3 +77,5 @@ void paw3204_set_cpi(uint16_t cpi);
 522  * @return uint16_t Current CPI value of the sensor
 523  */
 524 uint16_t paw3204_get_cpi(void);
 525+
 526+report_mouse_t paw3204_get_report(report_mouse_t mouse_report);
 527diff --git a/drivers/sensors/pimoroni_trackball.c b/drivers/sensors/pimoroni_trackball.c
 528index 9c6d26d73de7de7850718759f11a1067e66ab34f..afbe3d5b77fc966a435281d91d1e860a940d7230 100644
 529--- a/drivers/sensors/pimoroni_trackball.c
 530+++ b/drivers/sensors/pimoroni_trackball.c
 531@@ -33,6 +33,13 @@
 532 
 533 static uint16_t precision = 128;
 534 
 535+const pointing_device_driver_t pimoroni_trackball_pointing_device_driver = {
 536+    .init       = pimoroni_trackball_device_init,
 537+    .get_report = pimoroni_trackball_get_report,
 538+    .set_cpi    = pimoroni_trackball_set_cpi,
 539+    .get_cpi    = pimoroni_trackball_get_cpi,
 540+};
 541+
 542 uint16_t pimoroni_trackball_get_cpi(void) {
 543     return (precision * 125);
 544 }
 545@@ -61,8 +68,8 @@ void pimoroni_trackball_set_rgbw(uint8_t r, uint8_t g, uint8_t b, uint8_t w) {
 546     pd_dprintf("Trackball RGBW i2c_status_t: %d\n", status);
 547 }
 548 
 549-i2c_status_t read_pimoroni_trackball(pimoroni_data_t* data) {
 550-    i2c_status_t status = i2c_read_register(PIMORONI_TRACKBALL_ADDRESS << 1, PIMORONI_TRACKBALL_REG_LEFT, (uint8_t*)data, sizeof(*data), PIMORONI_TRACKBALL_TIMEOUT);
 551+i2c_status_t read_pimoroni_trackball(pimoroni_data_t *data) {
 552+    i2c_status_t status = i2c_read_register(PIMORONI_TRACKBALL_ADDRESS << 1, PIMORONI_TRACKBALL_REG_LEFT, (uint8_t *)data, sizeof(*data), PIMORONI_TRACKBALL_TIMEOUT);
 553 
 554 #ifdef POINTING_DEVICE_DEBUG
 555     static uint16_t d_timer;
 556@@ -92,3 +99,50 @@ int16_t pimoroni_trackball_get_offsets(uint8_t negative_dir, uint8_t positive_di
 557     uint16_t magnitude = (scale * offset * offset * precision) >> 7;
 558     return isnegative ? -(int16_t)(magnitude) : (int16_t)(magnitude);
 559 }
 560+
 561+mouse_xy_report_t pimoroni_trackball_adapt_values(xy_clamp_range_t *offset) {
 562+    if (*offset > XY_REPORT_MAX) {
 563+        *offset -= XY_REPORT_MAX;
 564+        return (mouse_xy_report_t)XY_REPORT_MAX;
 565+    } else if (*offset < XY_REPORT_MIN) {
 566+        *offset += XY_REPORT_MAX;
 567+        return (mouse_xy_report_t)XY_REPORT_MIN;
 568+    } else {
 569+        mouse_xy_report_t temp_return = *offset;
 570+        *offset                       = 0;
 571+        return temp_return;
 572+    }
 573+}
 574+
 575+report_mouse_t pimoroni_trackball_get_report(report_mouse_t mouse_report) {
 576+    static uint16_t         debounce      = 0;
 577+    static uint8_t          error_count   = 0;
 578+    pimoroni_data_t         pimoroni_data = {0};
 579+    static xy_clamp_range_t x_offset = 0, y_offset = 0;
 580+
 581+    if (error_count < PIMORONI_TRACKBALL_ERROR_COUNT) {
 582+        i2c_status_t status = read_pimoroni_trackball(&pimoroni_data);
 583+
 584+        if (status == I2C_STATUS_SUCCESS) {
 585+            error_count = 0;
 586+
 587+            if (!(pimoroni_data.click & 128)) {
 588+                mouse_report.buttons = pointing_device_handle_buttons(mouse_report.buttons, false, POINTING_DEVICE_BUTTON1);
 589+                if (!debounce) {
 590+                    x_offset += pimoroni_trackball_get_offsets(pimoroni_data.right, pimoroni_data.left, PIMORONI_TRACKBALL_SCALE);
 591+                    y_offset += pimoroni_trackball_get_offsets(pimoroni_data.down, pimoroni_data.up, PIMORONI_TRACKBALL_SCALE);
 592+                    mouse_report.x = pimoroni_trackball_adapt_values(&x_offset);
 593+                    mouse_report.y = pimoroni_trackball_adapt_values(&y_offset);
 594+                } else {
 595+                    debounce--;
 596+                }
 597+            } else {
 598+                mouse_report.buttons = pointing_device_handle_buttons(mouse_report.buttons, true, POINTING_DEVICE_BUTTON1);
 599+                debounce             = PIMORONI_TRACKBALL_DEBOUNCE_CYCLES;
 600+            }
 601+        } else {
 602+            error_count++;
 603+        }
 604+    }
 605+    return mouse_report;
 606+}
 607diff --git a/drivers/sensors/pimoroni_trackball.h b/drivers/sensors/pimoroni_trackball.h
 608index 749f381bbd6ca085c28a83ddb7ff4e495793eed0..1904214a74a797349ad67ac51d9d7b4d4b652de8 100644
 609--- a/drivers/sensors/pimoroni_trackball.h
 610+++ b/drivers/sensors/pimoroni_trackball.h
 611@@ -19,6 +19,7 @@
 612 #include <stdint.h>
 613 #include "report.h"
 614 #include "i2c_master.h"
 615+#include "pointing_device.h"
 616 
 617 #ifndef PIMORONI_TRACKBALL_ADDRESS
 618 #    define PIMORONI_TRACKBALL_ADDRESS 0x0A
 619@@ -49,9 +50,12 @@ typedef struct {
 620     uint8_t click;
 621 } pimoroni_data_t;
 622 
 623-void         pimoroni_trackball_device_init(void);
 624-void         pimoroni_trackball_set_rgbw(uint8_t red, uint8_t green, uint8_t blue, uint8_t white);
 625-int16_t      pimoroni_trackball_get_offsets(uint8_t negative_dir, uint8_t positive_dir, uint8_t scale);
 626-uint16_t     pimoroni_trackball_get_cpi(void);
 627-void         pimoroni_trackball_set_cpi(uint16_t cpi);
 628-i2c_status_t read_pimoroni_trackball(pimoroni_data_t* data);
 629+const pointing_device_driver_t pimoroni_trackball_pointing_device_driver;
 630+
 631+void           pimoroni_trackball_device_init(void);
 632+void           pimoroni_trackball_set_rgbw(uint8_t red, uint8_t green, uint8_t blue, uint8_t white);
 633+int16_t        pimoroni_trackball_get_offsets(uint8_t negative_dir, uint8_t positive_dir, uint8_t scale);
 634+uint16_t       pimoroni_trackball_get_cpi(void);
 635+void           pimoroni_trackball_set_cpi(uint16_t cpi);
 636+i2c_status_t   read_pimoroni_trackball(pimoroni_data_t* data);
 637+report_mouse_t pimoroni_trackball_get_report(report_mouse_t mouse_report);
 638diff --git a/drivers/sensors/pmw3320.c b/drivers/sensors/pmw3320.c
 639index f19fbfd1ab44396e198f130cf840aafe06a67132..74fefd4c53d0dcafc4e44cb529c110257b2905d2 100644
 640--- a/drivers/sensors/pmw3320.c
 641+++ b/drivers/sensors/pmw3320.c
 642@@ -21,6 +21,14 @@
 643 #include "wait.h"
 644 #include "debug.h"
 645 #include "gpio.h"
 646+#include "pointing_device_internal.h"
 647+
 648+const pointing_device_driver_t pmw3320_pointing_device_drivera = {
 649+    .init       = pmw3320_init,
 650+    .get_report = pmw3320_get_report,
 651+    .set_cpi    = pmw3320_set_cpi,
 652+    .get_cpi    = pmw3320_get_cpi,
 653+};
 654 
 655 void pmw3320_init(void) {
 656     // Initialize sensor serial pins.
 657@@ -190,3 +198,15 @@ bool pmw3320_check_signature(void) {
 658 
 659     return (pid == 0x3b && pid2 == 0xc4);
 660 }
 661+
 662+report_mouse_t pmw3320_get_report(report_mouse_t mouse_report) {
 663+    report_pmw3320_t data = pmw3320_read_burst();
 664+
 665+    if (data.dx != 0 || data.dy != 0) {
 666+        pd_dprintf("Raw ] X: %d, Y: %d\n", data.dx, data.dy);
 667+        mouse_report.x = (mouse_xy_report_t)data.dx;
 668+        mouse_report.y = (mouse_xy_report_t)data.dy;
 669+    }
 670+
 671+    return mouse_report;
 672+}
 673diff --git a/drivers/sensors/pmw3320.h b/drivers/sensors/pmw3320.h
 674index a1fd5469196a23b351b4d6310f8978be1a802c72..cfff25bd8a600c3ebc2ff39f1d120ea7dc54e0fd 100644
 675--- a/drivers/sensors/pmw3320.h
 676+++ b/drivers/sensors/pmw3320.h
 677@@ -21,6 +21,7 @@
 678 
 679 #include <stdint.h>
 680 #include <stdbool.h>
 681+#include "pointing_device.h"
 682 
 683 #define constrain(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt)))
 684 
 685@@ -54,6 +55,8 @@ typedef struct {
 686     int8_t dy;
 687 } report_pmw3320_t;
 688 
 689+const pointing_device_driver_t pmw3320_pointing_device_driver;
 690+
 691 // A bunch of functions to implement the PMW3320-specific serial protocol.
 692 // Mostly taken from ADNS5050 driver.
 693 // Note that the "serial.h" driver is insufficient, because it does not
 694@@ -69,6 +72,7 @@ void             pmw3320_set_cpi(uint16_t cpi);
 695 uint16_t         pmw3320_get_cpi(void);
 696 int8_t           convert_twoscomp(uint8_t data);
 697 bool             pmw3320_check_signature(void);
 698+report_mouse_t   pmw3320_get_report(report_mouse_t mouse_report);
 699 
 700 #if !defined(PMW3320_CPI)
 701 #    define PMW3320_CPI 1000
 702diff --git a/drivers/sensors/pmw33xx_common.c b/drivers/sensors/pmw33xx_common.c
 703index b4fa727af9bf21771c3412afc9b596d7f759477b..f3285ec49720153d5fa490560c926ef96e759287 100644
 704--- a/drivers/sensors/pmw33xx_common.c
 705+++ b/drivers/sensors/pmw33xx_common.c
 706@@ -26,6 +26,13 @@ static bool in_burst_right[ARRAY_SIZE(cs_pins_right)] = {0};
 707 bool __attribute__((cold)) pmw33xx_upload_firmware(uint8_t sensor);
 708 bool __attribute__((cold)) pmw33xx_check_signature(uint8_t sensor);
 709 
 710+const pointing_device_driver_t pmw33xx_pointing_device_driver = {
 711+    .init       = pmw33xx_init_wrapper,
 712+    .get_report = pmw33xx_get_report,
 713+    .set_cpi    = pmw33xx_set_cpi_wrapper,
 714+    .get_cpi    = pmw33xx_get_cpi_wrapper,
 715+};
 716+
 717 uint16_t __attribute__((weak)) pmw33xx_srom_get_length(void) {
 718     return 0;
 719 }
 720@@ -228,3 +235,38 @@ pmw33xx_report_t pmw33xx_read_burst(uint8_t sensor) {
 721 
 722     return report;
 723 }
 724+
 725+void pmw33xx_init_wrapper(void) {
 726+    pmw33xx_init(0);
 727+}
 728+
 729+void pmw33xx_set_cpi_wrapper(uint16_t cpi) {
 730+    pmw33xx_set_cpi(0, cpi);
 731+}
 732+
 733+uint16_t pmw33xx_get_cpi_wrapper(void) {
 734+    return pmw33xx_get_cpi(0);
 735+}
 736+
 737+report_mouse_t pmw33xx_get_report(report_mouse_t mouse_report) {
 738+    pmw33xx_report_t report    = pmw33xx_read_burst(0);
 739+    static bool      in_motion = false;
 740+
 741+    if (report.motion.b.is_lifted) {
 742+        return mouse_report;
 743+    }
 744+
 745+    if (!report.motion.b.is_motion) {
 746+        in_motion = false;
 747+        return mouse_report;
 748+    }
 749+
 750+    if (!in_motion) {
 751+        in_motion = true;
 752+        pd_dprintf("PWM3360 (0): starting motion\n");
 753+    }
 754+
 755+    mouse_report.x = CONSTRAIN_HID_XY(report.delta_x);
 756+    mouse_report.y = CONSTRAIN_HID_XY(report.delta_y);
 757+    return mouse_report;
 758+}
 759diff --git a/drivers/sensors/pmw33xx_common.h b/drivers/sensors/pmw33xx_common.h
 760index b30ee3d59667e96332b9cc053c3d8bb74834e96a..22e35c3327503dc1d568c6472ea94662848c878d 100644
 761--- a/drivers/sensors/pmw33xx_common.h
 762+++ b/drivers/sensors/pmw33xx_common.h
 763@@ -14,6 +14,7 @@
 764 #include <stdint.h>
 765 #include "spi_master.h"
 766 #include "util.h"
 767+#include "pointing_device.h"
 768 
 769 #if defined(POINTING_DEVICE_DRIVER_pmw3360)
 770 #    include "pmw3360.h"
 771@@ -102,6 +103,10 @@ _Static_assert(sizeof((pmw33xx_report_t){0}.motion) == 1, "pmw33xx_report_t.moti
 772 
 773 #define CONSTRAIN(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt)))
 774 
 775+#define pmw3360_pointing_device_driver pmw33xx_pointing_device_driver;
 776+#define pmw3389_pointing_device_driver pmw33xx_pointing_device_driver;
 777+const pointing_device_driver_t pmw33xx_pointing_device_driver;
 778+
 779 /**
 780  * @brief Initializes the given sensor so it is in a working state and ready to
 781  * be polled for data.
 782@@ -170,3 +175,8 @@ uint8_t pmw33xx_read(uint8_t sensor, uint8_t reg_addr);
 783  * @return false Write failed, do not proceed operation
 784  */
 785 bool pmw33xx_write(uint8_t sensor, uint8_t reg_addr, uint8_t data);
 786+
 787+void           pmw33xx_init_wrapper(void);
 788+void           pmw33xx_set_cpi_wrapper(uint16_t cpi);
 789+uint16_t       pmw33xx_get_cpi_wrapper(void);
 790+report_mouse_t pmw33xx_get_report(report_mouse_t mouse_report);
 791diff --git a/quantum/pointing_device/pointing_device.c b/quantum/pointing_device/pointing_device.c
 792index 7d3be9e524f06c8d5d0006a83ca243b349a77ea8..cac2875fc8d43874de9ddcdb0acf83c7873ce494 100644
 793--- a/quantum/pointing_device/pointing_device.c
 794+++ b/quantum/pointing_device/pointing_device.c
 795@@ -79,7 +79,28 @@ uint16_t pointing_device_get_shared_cpi(void) {
 796 static report_mouse_t local_mouse_report         = {};
 797 static bool           pointing_device_force_send = false;
 798 
 799-extern const pointing_device_driver_t pointing_device_driver;
 800+#define POINTING_DEVICE_DRIVER_CONCAT(name) name##_pointing_device_driver
 801+#define POINTING_DEVICE_DRIVER(name) POINTING_DEVICE_DRIVER_CONCAT(name)
 802+
 803+#ifdef POINTING_DEVICE_DRIVER_custom
 804+__attribute__((weak)) void           pointing_device_driver_init(void) {}
 805+__attribute__((weak)) report_mouse_t pointing_device_driver_get_report(report_mouse_t mouse_report) {
 806+    return mouse_report;
 807+}
 808+__attribute__((weak)) uint16_t pointing_device_driver_get_cpi(void) {
 809+    return 0;
 810+}
 811+__attribute__((weak)) void pointing_device_driver_set_cpi(uint16_t cpi) {}
 812+
 813+const pointing_device_driver_t custom_pointing_device_driver = {
 814+    .init       = pointing_device_driver_init,
 815+    .get_report = pointing_device_driver_get_report,
 816+    .get_cpi    = pointing_device_driver_get_cpi,
 817+    .set_cpi    = pointing_device_driver_set_cpi,
 818+};
 819+#endif
 820+
 821+const pointing_device_driver_t *pointing_device_driver = &POINTING_DEVICE_DRIVER(POINTING_DEVICE_DRIVER_NAME);
 822 
 823 /**
 824  * @brief Keyboard level code pointing device initialisation
 825@@ -146,7 +167,7 @@ __attribute__((weak)) void pointing_device_init(void) {
 826     if ((POINTING_DEVICE_THIS_SIDE))
 827 #endif
 828     {
 829-        pointing_device_driver.init();
 830+        pointing_device_driver->init();
 831 #ifdef POINTING_DEVICE_MOTION_PIN
 832 #    ifdef POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW
 833         gpio_set_pin_input_high(POINTING_DEVICE_MOTION_PIN);
 834@@ -258,15 +279,15 @@ __attribute__((weak)) bool pointing_device_task(void) {
 835 #    if defined(POINTING_DEVICE_COMBINED)
 836         static uint8_t old_buttons = 0;
 837         local_mouse_report.buttons = old_buttons;
 838-        local_mouse_report         = pointing_device_driver.get_report(local_mouse_report);
 839+        local_mouse_report         = pointing_device_driver->get_report(local_mouse_report);
 840         old_buttons                = local_mouse_report.buttons;
 841 #    elif defined(POINTING_DEVICE_LEFT) || defined(POINTING_DEVICE_RIGHT)
 842-        local_mouse_report = POINTING_DEVICE_THIS_SIDE ? pointing_device_driver.get_report(local_mouse_report) : shared_mouse_report;
 843+        local_mouse_report = POINTING_DEVICE_THIS_SIDE ? pointing_device_driver->get_report(local_mouse_report) : shared_mouse_report;
 844 #    else
 845 #        error "You need to define the side(s) the pointing device is on. POINTING_DEVICE_COMBINED / POINTING_DEVICE_LEFT / POINTING_DEVICE_RIGHT"
 846 #    endif
 847 #else
 848-    local_mouse_report = pointing_device_driver.get_report(local_mouse_report);
 849+    local_mouse_report = pointing_device_driver->get_report(local_mouse_report);
 850 #endif // defined(SPLIT_POINTING_ENABLE)
 851 
 852 #ifdef POINTING_DEVICE_MOTION_PIN
 853@@ -331,9 +352,9 @@ void pointing_device_set_report(report_mouse_t mouse_report) {
 854  */
 855 uint16_t pointing_device_get_cpi(void) {
 856 #if defined(SPLIT_POINTING_ENABLE)
 857-    return POINTING_DEVICE_THIS_SIDE ? pointing_device_driver.get_cpi() : shared_cpi;
 858+    return POINTING_DEVICE_THIS_SIDE ? pointing_device_driver->get_cpi() : shared_cpi;
 859 #else
 860-    return pointing_device_driver.get_cpi();
 861+    return pointing_device_driver->get_cpi();
 862 #endif
 863 }
 864 
 865@@ -347,12 +368,12 @@ uint16_t pointing_device_get_cpi(void) {
 866 void pointing_device_set_cpi(uint16_t cpi) {
 867 #if defined(SPLIT_POINTING_ENABLE)
 868     if (POINTING_DEVICE_THIS_SIDE) {
 869-        pointing_device_driver.set_cpi(cpi);
 870+        pointing_device_driver->set_cpi(cpi);
 871     } else {
 872         shared_cpi = cpi;
 873     }
 874 #else
 875-    pointing_device_driver.set_cpi(cpi);
 876+    pointing_device_driver->set_cpi(cpi);
 877 #endif
 878 }
 879 
 880@@ -370,7 +391,7 @@ void pointing_device_set_cpi(uint16_t cpi) {
 881 void pointing_device_set_cpi_on_side(bool left, uint16_t cpi) {
 882     bool local = (is_keyboard_left() == left);
 883     if (local) {
 884-        pointing_device_driver.set_cpi(cpi);
 885+        pointing_device_driver->set_cpi(cpi);
 886     } else {
 887         shared_cpi = cpi;
 888     }
 889diff --git a/quantum/pointing_device/pointing_device.h b/quantum/pointing_device/pointing_device.h
 890index b0f8533d6d0c2c5270061ed4345873fd269478ea..72188c977dd19f9b9df7f99bb83a3a039bb293af 100644
 891--- a/quantum/pointing_device/pointing_device.h
 892+++ b/quantum/pointing_device/pointing_device.h
 893@@ -21,6 +21,13 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 894 #include "host.h"
 895 #include "report.h"
 896 
 897+typedef struct {
 898+    void (*init)(void);
 899+    report_mouse_t (*get_report)(report_mouse_t mouse_report);
 900+    void (*set_cpi)(uint16_t);
 901+    uint16_t (*get_cpi)(void);
 902+} pointing_device_driver_t;
 903+
 904 #ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE
 905 #    include "pointing_device_auto_mouse.h"
 906 #endif
 907@@ -44,7 +51,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 908 #    include "drivers/sensors/azoteq_iqs5xx.h"
 909 #elif defined(POINTING_DEVICE_DRIVER_cirque_pinnacle_i2c) || defined(POINTING_DEVICE_DRIVER_cirque_pinnacle_spi)
 910 #    include "drivers/sensors/cirque_pinnacle.h"
 911-#    include "drivers/sensors/cirque_pinnacle_gestures.h"
 912 #    include "pointing_device_gestures.h"
 913 #elif defined(POINTING_DEVICE_DRIVER_paw3204)
 914 #    include "drivers/sensors/paw3204.h"
 915@@ -74,13 +80,6 @@ uint16_t       pointing_device_driver_get_cpi(void);
 916 void           pointing_device_driver_set_cpi(uint16_t cpi);
 917 #endif
 918 
 919-typedef struct {
 920-    void (*init)(void);
 921-    report_mouse_t (*get_report)(report_mouse_t mouse_report);
 922-    void (*set_cpi)(uint16_t);
 923-    uint16_t (*get_cpi)(void);
 924-} pointing_device_driver_t;
 925-
 926 typedef enum {
 927     POINTING_DEVICE_BUTTON1,
 928     POINTING_DEVICE_BUTTON2,
 929@@ -112,6 +111,9 @@ typedef int32_t hv_clamp_range_t;
 930 typedef int16_t hv_clamp_range_t;
 931 #endif
 932 
 933+#define CONSTRAIN_HID(amt) ((amt) < INT8_MIN ? INT8_MIN : ((amt) > INT8_MAX ? INT8_MAX : (amt)))
 934+#define CONSTRAIN_HID_XY(amt) ((amt) < XY_REPORT_MIN ? XY_REPORT_MIN : ((amt) > XY_REPORT_MAX ? XY_REPORT_MAX : (amt)))
 935+
 936 void           pointing_device_init(void);
 937 bool           pointing_device_task(void);
 938 bool           pointing_device_send(void);
 939diff --git a/quantum/pointing_device/pointing_device_drivers.c b/quantum/pointing_device/pointing_device_drivers.c
 940deleted file mode 100644
 941index 6cbe427401ec54de202e77cac4cfa00707fa47a0..0000000000000000000000000000000000000000
 942--- a/quantum/pointing_device/pointing_device_drivers.c
 943+++ /dev/null
 944@@ -1,514 +0,0 @@
 945-/* Copyright 2017 Joshua Broekhuijsen <snipeye+qmk@gmail.com>
 946- * Copyright 2020 Christopher Courtney, aka Drashna Jael're  (@drashna) <drashna@live.com>
 947- * Copyright 2021 Dasky (@daskygit)
 948- *
 949- * This program is free software: you can redistribute it and/or modify
 950- * it under the terms of the GNU General Public License as published by
 951- * the Free Software Foundation, either version 2 of the License, or
 952- * (at your option) any later version.
 953- *
 954- * This program is distributed in the hope that it will be useful,
 955- * but WITHOUT ANY WARRANTY; without even the implied warranty of
 956- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 957- * GNU General Public License for more details.
 958- *
 959- * You should have received a copy of the GNU General Public License
 960- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 961- */
 962-
 963-#include "pointing_device.h"
 964-#include "pointing_device_internal.h"
 965-#include "debug.h"
 966-#include "wait.h"
 967-#include "timer.h"
 968-#include <stddef.h>
 969-
 970-#define CONSTRAIN_HID(amt) ((amt) < INT8_MIN ? INT8_MIN : ((amt) > INT8_MAX ? INT8_MAX : (amt)))
 971-#define CONSTRAIN_HID_XY(amt) ((amt) < XY_REPORT_MIN ? XY_REPORT_MIN : ((amt) > XY_REPORT_MAX ? XY_REPORT_MAX : (amt)))
 972-
 973-// get_report functions should probably be moved to their respective drivers.
 974-
 975-#if defined(POINTING_DEVICE_DRIVER_adns5050)
 976-report_mouse_t adns5050_get_report(report_mouse_t mouse_report) {
 977-    report_adns5050_t data = adns5050_read_burst();
 978-
 979-    if (data.dx != 0 || data.dy != 0) {
 980-        pd_dprintf("Raw ] X: %d, Y: %d\n", data.dx, data.dy);
 981-        mouse_report.x = (mouse_xy_report_t)data.dx;
 982-        mouse_report.y = (mouse_xy_report_t)data.dy;
 983-    }
 984-
 985-    return mouse_report;
 986-}
 987-
 988-// clang-format off
 989-const pointing_device_driver_t pointing_device_driver = {
 990-    .init         = adns5050_init,
 991-    .get_report   = adns5050_get_report,
 992-    .set_cpi      = adns5050_set_cpi,
 993-    .get_cpi      = adns5050_get_cpi,
 994-};
 995-// clang-format on
 996-
 997-#elif defined(POINTING_DEVICE_DRIVER_pmw3320)
 998-report_mouse_t pmw3320_get_report(report_mouse_t mouse_report) {
 999-    report_pmw3320_t data = pmw3320_read_burst();
1000-
1001-    if (data.dx != 0 || data.dy != 0) {
1002-        pd_dprintf("Raw ] X: %d, Y: %d\n", data.dx, data.dy);
1003-        mouse_report.x = (mouse_xy_report_t)data.dx;
1004-        mouse_report.y = (mouse_xy_report_t)data.dy;
1005-    }
1006-
1007-    return mouse_report;
1008-}
1009-
1010-// clang-format off
1011-const pointing_device_driver_t pointing_device_driver = {
1012-    .init         = pmw3320_init,
1013-    .get_report   = pmw3320_get_report,
1014-    .set_cpi      = pmw3320_set_cpi,
1015-    .get_cpi      = pmw3320_get_cpi,
1016-};
1017-// clang-format on
1018-
1019-#elif defined(POINTING_DEVICE_DRIVER_adns9800)
1020-
1021-report_mouse_t adns9800_get_report_driver(report_mouse_t mouse_report) {
1022-    report_adns9800_t sensor_report = adns9800_get_report();
1023-
1024-    mouse_report.x = CONSTRAIN_HID_XY(sensor_report.x);
1025-    mouse_report.y = CONSTRAIN_HID_XY(sensor_report.y);
1026-
1027-    return mouse_report;
1028-}
1029-
1030-// clang-format off
1031-const pointing_device_driver_t pointing_device_driver = {
1032-    .init       = adns9800_init,
1033-    .get_report = adns9800_get_report_driver,
1034-    .set_cpi    = adns9800_set_cpi,
1035-    .get_cpi    = adns9800_get_cpi
1036-};
1037-// clang-format on
1038-
1039-#elif defined(POINTING_DEVICE_DRIVER_analog_joystick)
1040-report_mouse_t analog_joystick_get_report(report_mouse_t mouse_report) {
1041-    report_analog_joystick_t data = analog_joystick_read();
1042-
1043-    pd_dprintf("Raw ] X: %d, Y: %d\n", data.x, data.y);
1044diff --git a/quantum/split_common/transactions.c b/quantum/split_common/transactions.c
1045index 6c1aeb284d3d944fb3c4c4d1c0604f1a5e9a6164..f66b2ad89fb564b2d127a8c56a6ebcc8fe5e53d0 100644
1046--- a/quantum/split_common/transactions.c
1047+++ b/quantum/split_common/transactions.c
1048@@ -733,7 +733,7 @@ static bool pointing_handlers_master(matrix_row_t master_matrix[], matrix_row_t
1049     return okay;
1050 }
1051 
1052-extern const pointing_device_driver_t pointing_device_driver;
1053+extern const pointing_device_driver_t *pointing_device_driver;
1054 
1055 static void pointing_handlers_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
1056 #    if defined(POINTING_DEVICE_LEFT)
1057@@ -753,18 +753,18 @@ static void pointing_handlers_slave(matrix_row_t master_matrix[], matrix_row_t s
1058     last_exec = timer_read32();
1059 #    endif
1060 
1061-    uint16_t temp_cpi = !pointing_device_driver.get_cpi ? 0 : pointing_device_driver.get_cpi(); // check for NULL
1062+    uint16_t temp_cpi = !pointing_device_driver->get_cpi ? 0 : pointing_device_driver->get_cpi(); // check for NULL
1063 
1064     split_shared_memory_lock();
1065     split_slave_pointing_sync_t pointing;
1066     memcpy(&pointing, &split_shmem->pointing, sizeof(split_slave_pointing_sync_t));
1067     split_shared_memory_unlock();
1068 
1069-    if (pointing.cpi && pointing.cpi != temp_cpi && pointing_device_driver.set_cpi) {
1070-        pointing_device_driver.set_cpi(pointing.cpi);
1071+    if (pointing.cpi && pointing.cpi != temp_cpi && pointing_device_driver->set_cpi) {
1072+        pointing_device_driver->set_cpi(pointing.cpi);
1073     }
1074 
1075-    pointing.report = pointing_device_driver.get_report((report_mouse_t){0});
1076+    pointing.report = pointing_device_driver->get_report((report_mouse_t){0});
1077     // Now update the checksum given that the pointing has been written to
1078     pointing.checksum = crc8(&pointing.report, sizeof(report_mouse_t));
1079