diff options
author | Dasky <[email protected]> | 2024-10-25 18:11:51 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2024-10-25 18:11:51 +0100 |
commit | f5b495e06e257796a9be845f47bfc375fece81f8 (patch) | |
tree | 3772da6b18ad610df774269d3542c6fb660b812c /drivers/sensors/analog_joystick.c | |
parent | 5c85271e48b4f2be7da47d1728ad1ddb95364ad7 (diff) | |
download | qmk_firmware-f5b495e06e257796a9be845f47bfc375fece81f8.tar.gz qmk_firmware-f5b495e06e257796a9be845f47bfc375fece81f8.zip |
Move pointing device driver code (#24445)
Co-authored-by: Drashna Jaelre <[email protected]>
Diffstat (limited to 'drivers/sensors/analog_joystick.c')
-rw-r--r-- | drivers/sensors/analog_joystick.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/sensors/analog_joystick.c b/drivers/sensors/analog_joystick.c index 15b35a45f2..93bbaa1b51 100644 --- a/drivers/sensors/analog_joystick.c +++ b/drivers/sensors/analog_joystick.c @@ -20,6 +20,14 @@ #include "wait.h" #include "timer.h" #include <stdlib.h> +#include "pointing_device_internal.h" + +const pointing_device_driver_t analog_joystick_pointing_device_driver = { + .init = analog_joystick_init, + .get_report = analog_joystick_get_report, + .set_cpi = NULL, + .get_cpi = NULL, +}; // Set Parameters #ifndef ANALOG_JOYSTICK_AUTO_AXIS @@ -145,3 +153,16 @@ void analog_joystick_init(void) { maxAxisValues[1] = yOrigin + 100; #endif } + +report_mouse_t analog_joystick_get_report(report_mouse_t mouse_report) { + report_analog_joystick_t data = analog_joystick_read(); + + pd_dprintf("Raw ] X: %d, Y: %d\n", data.x, data.y); + + mouse_report.x = data.x; + mouse_report.y = data.y; + + mouse_report.buttons = pointing_device_handle_buttons(mouse_report.buttons, data.button, POINTING_DEVICE_BUTTON1); + + return mouse_report; +} |