From 9a68472da87bea6eb9e209b8cf90de09211f23c8 Mon Sep 17 00:00:00 2001 From: Vladislav Marchenko Date: Mon, 3 Apr 2023 08:57:19 +0600 Subject: Added PMW3320 driver (#19543) --- quantum/pointing_device/pointing_device.h | 3 +++ quantum/pointing_device/pointing_device_drivers.c | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) (limited to 'quantum') diff --git a/quantum/pointing_device/pointing_device.h b/quantum/pointing_device/pointing_device.h index eacc6418dd..afd653eaee 100644 --- a/quantum/pointing_device/pointing_device.h +++ b/quantum/pointing_device/pointing_device.h @@ -28,6 +28,9 @@ along with this program. If not, see . #if defined(POINTING_DEVICE_DRIVER_adns5050) # include "drivers/sensors/adns5050.h" # define POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW +#elif defined(POINTING_DEVICE_DRIVER_pmw3320) +# include "drivers/sensors/pmw3320.h" +# define POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW #elif defined(POINTING_DEVICE_DRIVER_adns9800) # include "spi_master.h" # include "drivers/sensors/adns9800.h" diff --git a/quantum/pointing_device/pointing_device_drivers.c b/quantum/pointing_device/pointing_device_drivers.c index d6f29c062e..9a4315f76f 100644 --- a/quantum/pointing_device/pointing_device_drivers.c +++ b/quantum/pointing_device/pointing_device_drivers.c @@ -50,6 +50,28 @@ const pointing_device_driver_t pointing_device_driver = { }; // clang-format on +#elif defined(POINTING_DEVICE_DRIVER_pmw3320) +report_mouse_t pmw3320_get_report(report_mouse_t mouse_report) { + report_pmw3320_t data = pmw3320_read_burst(); + + if (data.dx != 0 || data.dy != 0) { + pd_dprintf("Raw ] X: %d, Y: %d\n", data.dx, data.dy); + mouse_report.x = (mouse_xy_report_t)data.dx; + mouse_report.y = (mouse_xy_report_t)data.dy; + } + + return mouse_report; +} + +// clang-format off +const pointing_device_driver_t pointing_device_driver = { + .init = pmw3320_init, + .get_report = pmw3320_get_report, + .set_cpi = pmw3320_set_cpi, + .get_cpi = pmw3320_get_cpi, +}; +// clang-format on + #elif defined(POINTING_DEVICE_DRIVER_adns9800) report_mouse_t adns9800_get_report_driver(report_mouse_t mouse_report) { -- cgit v1.2.3