diff options
-rw-r--r-- | drivers/sensors/pimoroni_trackball.c | 12 | ||||
-rw-r--r-- | quantum/pointing_device/pointing_device.c | 16 | ||||
-rw-r--r-- | quantum/pointing_device/pointing_device.h | 10 | ||||
-rw-r--r-- | tmk_core/protocol/report.h | 8 |
4 files changed, 23 insertions, 23 deletions
diff --git a/drivers/sensors/pimoroni_trackball.c b/drivers/sensors/pimoroni_trackball.c index afbe3d5b77..06e5042953 100644 --- a/drivers/sensors/pimoroni_trackball.c +++ b/drivers/sensors/pimoroni_trackball.c @@ -101,12 +101,12 @@ int16_t pimoroni_trackball_get_offsets(uint8_t negative_dir, uint8_t positive_di } mouse_xy_report_t pimoroni_trackball_adapt_values(xy_clamp_range_t *offset) { - if (*offset > XY_REPORT_MAX) { - *offset -= XY_REPORT_MAX; - return (mouse_xy_report_t)XY_REPORT_MAX; - } else if (*offset < XY_REPORT_MIN) { - *offset += XY_REPORT_MAX; - return (mouse_xy_report_t)XY_REPORT_MIN; + if (*offset > MOUSE_REPORT_XY_MAX) { + *offset -= MOUSE_REPORT_XY_MAX; + return (mouse_xy_report_t)MOUSE_REPORT_XY_MAX; + } else if (*offset < MOUSE_REPORT_XY_MIN) { + *offset += MOUSE_REPORT_XY_MAX; + return (mouse_xy_report_t)MOUSE_REPORT_XY_MIN; } else { mouse_xy_report_t temp_return = *offset; *offset = 0; diff --git a/quantum/pointing_device/pointing_device.c b/quantum/pointing_device/pointing_device.c index cac2875fc8..e26416f968 100644 --- a/quantum/pointing_device/pointing_device.c +++ b/quantum/pointing_device/pointing_device.c @@ -404,10 +404,10 @@ void pointing_device_set_cpi_on_side(bool left, uint16_t cpi) { * @return mouse_hv_report_t clamped value */ static inline mouse_hv_report_t pointing_device_hv_clamp(hv_clamp_range_t value) { - if (value < HV_REPORT_MIN) { - return HV_REPORT_MIN; - } else if (value > HV_REPORT_MAX) { - return HV_REPORT_MAX; + if (value < MOUSE_REPORT_HV_MIN) { + return MOUSE_REPORT_HV_MIN; + } else if (value > MOUSE_REPORT_HV_MAX) { + return MOUSE_REPORT_HV_MAX; } else { return value; } @@ -420,10 +420,10 @@ static inline mouse_hv_report_t pointing_device_hv_clamp(hv_clamp_range_t value) * @return mouse_xy_report_t clamped value */ static inline mouse_xy_report_t pointing_device_xy_clamp(xy_clamp_range_t value) { - if (value < XY_REPORT_MIN) { - return XY_REPORT_MIN; - } else if (value > XY_REPORT_MAX) { - return XY_REPORT_MAX; + if (value < MOUSE_REPORT_XY_MIN) { + return MOUSE_REPORT_XY_MIN; + } else if (value > MOUSE_REPORT_XY_MAX) { + return MOUSE_REPORT_XY_MAX; } else { return value; } diff --git a/quantum/pointing_device/pointing_device.h b/quantum/pointing_device/pointing_device.h index 72188c977d..7bc059e594 100644 --- a/quantum/pointing_device/pointing_device.h +++ b/quantum/pointing_device/pointing_device.h @@ -92,27 +92,19 @@ typedef enum { } pointing_device_buttons_t; #ifdef MOUSE_EXTENDED_REPORT -# define XY_REPORT_MIN INT16_MIN -# define XY_REPORT_MAX INT16_MAX typedef int32_t xy_clamp_range_t; #else -# define XY_REPORT_MIN INT8_MIN -# define XY_REPORT_MAX INT8_MAX typedef int16_t xy_clamp_range_t; #endif #ifdef WHEEL_EXTENDED_REPORT -# define HV_REPORT_MIN INT16_MIN -# define HV_REPORT_MAX INT16_MAX typedef int32_t hv_clamp_range_t; #else -# define HV_REPORT_MIN INT8_MIN -# define HV_REPORT_MAX INT8_MAX typedef int16_t hv_clamp_range_t; #endif #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))) +#define CONSTRAIN_HID_XY(amt) ((amt) < MOUSE_REPORT_XY_MIN ? MOUSE_REPORT_XY_MIN : ((amt) > MOUSE_REPORT_XY_MAX ? MOUSE_REPORT_XY_MAX : (amt))) void pointing_device_init(void); bool pointing_device_task(void); diff --git a/tmk_core/protocol/report.h b/tmk_core/protocol/report.h index d854f51d5c..9053b0bb3f 100644 --- a/tmk_core/protocol/report.h +++ b/tmk_core/protocol/report.h @@ -194,14 +194,22 @@ typedef struct { } PACKED report_programmable_button_t; #ifdef MOUSE_EXTENDED_REPORT +# define MOUSE_REPORT_XY_MIN INT16_MIN +# define MOUSE_REPORT_XY_MAX INT16_MAX typedef int16_t mouse_xy_report_t; #else +# define MOUSE_REPORT_XY_MIN INT8_MIN +# define MOUSE_REPORT_XY_MAX INT8_MAX typedef int8_t mouse_xy_report_t; #endif #ifdef WHEEL_EXTENDED_REPORT +# define MOUSE_REPORT_HV_MIN INT16_MIN +# define MOUSE_REPORT_HV_MAX INT16_MAX typedef int16_t mouse_hv_report_t; #else +# define MOUSE_REPORT_HV_MIN INT8_MIN +# define MOUSE_REPORT_HV_MAX INT8_MAX typedef int8_t mouse_hv_report_t; #endif |