diff --git a/quantum/pointing_device/pointing_device.h b/quantum/pointing_device/pointing_device.h index 828b24a6419b..604931c3328a 100644 --- a/quantum/pointing_device/pointing_device.h +++ b/quantum/pointing_device/pointing_device.h @@ -31,6 +31,51 @@ along with this program. If not, see . # define POINTING_DEVICE_COUNT 1 #endif +typedef enum { + ROTATE_0, + ROTATE_90, + ROTATE_180, + ROTATE_270, +} pointing_device_rotations_t; +typedef enum { + UNKNOWN, + LEFT, + RIGHT, +} pointing_device_side_t; +typedef enum { + NONE, + INVERT_X, + INVERT_Y, + INVERT_XY, +} pointing_device_invert_t; + +typedef struct { + pin_t cs; + uint8_t mode; + uint16_t divisor; +} pointing_device_spi_config_t; + +typedef struct { + uint16_t address; + uint16_t timeout; +} pointing_device_i2c_config_t; + +typedef struct { + pin_t data_pin; + pin_t clock_pin; +} pointing_device_ps2_config_t; + +typedef struct { + pin_t sdio; + pin_t sclk; + pin_t cs; +} pointing_device_3wire_spi_config_t; + +typedef struct { + pin_t pin; + bool active_low; +} pointing_device_motion_t; + typedef struct { void (*init)(const void *); report_mouse_t (*get_report)(const void *); @@ -66,6 +111,43 @@ typedef enum { POINTING_DEVICE_BUTTON8, } pointing_device_buttons_t; +typedef struct { + report_mouse_t report; + uint8_t counter; +} pointing_device_shared_report_t; + + +#if defined(POINTING_DEVICE_DRIVER_ADNS5050) +# include "adns5050.h" +#endif +#if defined(POINTING_DEVICE_DRIVER_ADNS9800) +# include "adns9800.h" +#endif +#if defined(POINTING_DEVICE_DRIVER_ANALOG_JOYSTICK) +# include "analog_joystick.h" +#endif +#if defined(POINTING_DEVICE_DRIVER_AZOTEQ_IQS5XX) +# include "azoteq_iqs5xx.h" +#endif +#if defined(POINTING_DEVICE_DRIVER_CIRQUE_PINNACLE_I2C) || defined(POINTING_DEVICE_DRIVER_CIRQUE_PINNACLE_SPI) +# include "cirque_pinnacle.h" +#endif +#if defined(POINTING_DEVICE_DRIVER_PAW3204) +# include "paw3204.h" +#endif +#if defined(POINTING_DEVICE_DRIVER_PIMORONI_TRACKBALL) +# include "pimoroni_trackball.h" +#endif +#if defined(POINTING_DEVICE_DRIVER_PMW3320) +# include "pmw3320.h" +#endif +#if defined(POINTING_DEVICE_DRIVER_PMW3360) +# include "pmw3360.h" +#endif +#if defined(POINTING_DEVICE_DRIVER_PMW3389) +# include "pmw3389.h" +#endif + #ifdef MOUSE_EXTENDED_REPORT # define XY_REPORT_MIN INT16_MIN # define XY_REPORT_MAX INT16_MAX @@ -76,6 +158,13 @@ typedef int32_t clamp_range_t; typedef int16_t clamp_range_t; #endif +#define POINTING_DEVICE_NO_MOTION_PIN \ + { 0 } +#define POINTING_DEVICE_THIS_SIDE(index) (pointing_device_configs[index].side == (is_keyboard_left() ? LEFT : RIGHT)) + +#define CONSTRAIN_HID(amt) ((amt) < INT8_MIN ? INT8_MIN : ((amt) > INT8_MAX ? INT8_MAX : (amt))) +#define CONSTRAIN_HID_XY(amt) ((amt) < XY_REPORT_MIN ? XY_REPORT_MIN : ((amt) > XY_REPORT_MAX ? XY_REPORT_MAX : (amt))) + void pointing_device_init(void); bool pointing_device_task(void); void pointing_device_send(report_mouse_t *sending_report); @@ -84,6 +173,12 @@ void pointing_device_set_report(report_mouse_t mouse_report); uint16_t pointing_device_get_cpi(void); void pointing_device_set_cpi(uint16_t cpi); +uint16_t pointing_device_get_cpi_by_index(uint8_t index); +void pointing_device_set_cpi_by_index(uint16_t cpi, uint8_t index); + + +void pointing_device_init_kb_by_index(uint8_t index); +void pointing_device_init_user_by_index(uint8_t index); void pointing_device_init_kb(void); void pointing_device_init_user(void); report_mouse_t pointing_device_task_kb_by_index(report_mouse_t mouse_report, uint8_t index); @@ -91,23 +186,11 @@ report_mouse_t pointing_device_task_user_by_index(report_mouse_t mouse_report, u report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report); report_mouse_t pointing_device_task_user(report_mouse_t mouse_report); uint8_t pointing_device_handle_buttons(uint8_t buttons, bool pressed, pointing_device_buttons_t button); -report_mouse_t pointing_device_adjust_by_defines(report_mouse_t mouse_report); void pointing_device_keycode_handler(uint16_t keycode, bool pressed); +bool pointing_deivce_task_get_pointing_reports(report_mouse_t *report); +void pointing_device_add_and_clamp_report(report_mouse_t* report, report_mouse_t* additional_report); +bool pointing_device_report_ready(report_mouse_t* last_report, report_mouse_t* new_report, bool* device_was_ready); -#if defined(SPLIT_POINTING_ENABLE) -void pointing_device_set_shared_report(report_mouse_t report); -uint16_t pointing_device_get_shared_cpi(void); -# if !defined(POINTING_DEVICE_TASK_THROTTLE_MS) -# define POINTING_DEVICE_TASK_THROTTLE_MS 1 -# endif -# if defined(POINTING_DEVICE_COMBINED) -void pointing_device_set_cpi_on_side(bool left, uint16_t cpi); -report_mouse_t pointing_device_combine_reports(report_mouse_t left_report, report_mouse_t right_report); -report_mouse_t pointing_device_task_combined_kb(report_mouse_t left_report, report_mouse_t right_report); -report_mouse_t pointing_device_task_combined_user(report_mouse_t left_report, report_mouse_t right_report); -report_mouse_t pointing_device_adjust_by_defines_right(report_mouse_t mouse_report); -# endif // defined(POINTING_DEVICE_COMBINED) -#endif // defined(SPLIT_POINTING_ENABLE) void pointing_device_set_shared_report(pointing_device_shared_report_t report); pointing_device_shared_report_t pointing_device_get_shared_report(void);