diff options
Diffstat (limited to 'quantum/pointing_device')
-rw-r--r-- | quantum/pointing_device/pointing_device.c | 11 | ||||
-rw-r--r-- | quantum/pointing_device/pointing_device_auto_mouse.c | 15 | ||||
-rw-r--r-- | quantum/pointing_device/pointing_device_auto_mouse.h | 10 |
3 files changed, 29 insertions, 7 deletions
diff --git a/quantum/pointing_device/pointing_device.c b/quantum/pointing_device/pointing_device.c index 17dc701a41..2fa49ade8e 100644 --- a/quantum/pointing_device/pointing_device.c +++ b/quantum/pointing_device/pointing_device.c @@ -251,14 +251,15 @@ __attribute__((weak)) bool pointing_device_task(void) { # else if (readPin(POINTING_DEVICE_MOTION_PIN)) # endif + { #endif #if defined(SPLIT_POINTING_ENABLE) # if defined(POINTING_DEVICE_COMBINED) static uint8_t old_buttons = 0; - local_mouse_report.buttons = old_buttons; - local_mouse_report = pointing_device_driver.get_report(local_mouse_report); - old_buttons = local_mouse_report.buttons; + local_mouse_report.buttons = old_buttons; + local_mouse_report = pointing_device_driver.get_report(local_mouse_report); + old_buttons = local_mouse_report.buttons; # elif defined(POINTING_DEVICE_LEFT) || defined(POINTING_DEVICE_RIGHT) local_mouse_report = POINTING_DEVICE_THIS_SIDE ? pointing_device_driver.get_report(local_mouse_report) : shared_mouse_report; # else @@ -268,6 +269,10 @@ __attribute__((weak)) bool pointing_device_task(void) { local_mouse_report = pointing_device_driver.get_report(local_mouse_report); #endif // defined(SPLIT_POINTING_ENABLE) +#ifdef POINTING_DEVICE_MOTION_PIN + } +#endif + // allow kb to intercept and modify report #if defined(SPLIT_POINTING_ENABLE) && defined(POINTING_DEVICE_COMBINED) if (is_keyboard_left()) { diff --git a/quantum/pointing_device/pointing_device_auto_mouse.c b/quantum/pointing_device/pointing_device_auto_mouse.c index 3135b9e531..1b11fffedb 100644 --- a/quantum/pointing_device/pointing_device_auto_mouse.c +++ b/quantum/pointing_device/pointing_device_auto_mouse.c @@ -17,6 +17,7 @@ #ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE +# include <stdlib.h> # include <string.h> # include "pointing_device_auto_mouse.h" # include "debug.h" @@ -217,7 +218,11 @@ void auto_mouse_layer_off(void) { * @return bool of pointing_device activation */ __attribute__((weak)) bool auto_mouse_activation(report_mouse_t mouse_report) { - return mouse_report.x != 0 || mouse_report.y != 0 || mouse_report.h != 0 || mouse_report.v != 0 || mouse_report.buttons; + auto_mouse_context.total_mouse_movement.x += mouse_report.x; + auto_mouse_context.total_mouse_movement.y += mouse_report.y; + auto_mouse_context.total_mouse_movement.h += mouse_report.h; + auto_mouse_context.total_mouse_movement.v += mouse_report.v; + return abs(auto_mouse_context.total_mouse_movement.x) > AUTO_MOUSE_THRESHOLD || abs(auto_mouse_context.total_mouse_movement.y) > AUTO_MOUSE_THRESHOLD || abs(auto_mouse_context.total_mouse_movement.h) > AUTO_MOUSE_THRESHOLD || abs(auto_mouse_context.total_mouse_movement.v) > AUTO_MOUSE_THRESHOLD || mouse_report.buttons; } /** @@ -235,14 +240,16 @@ void pointing_device_task_auto_mouse(report_mouse_t mouse_report) { // update activation and reset debounce auto_mouse_context.status.is_activated = auto_mouse_activation(mouse_report); if (is_auto_mouse_active()) { - auto_mouse_context.timer.active = timer_read(); - auto_mouse_context.timer.delay = 0; + auto_mouse_context.total_mouse_movement = (total_mouse_movement_t){.x = 0, .y = 0, .h = 0, .v = 0}; + auto_mouse_context.timer.active = timer_read(); + auto_mouse_context.timer.delay = 0; if (!layer_state_is((AUTO_MOUSE_TARGET_LAYER))) { layer_on((AUTO_MOUSE_TARGET_LAYER)); } } else if (layer_state_is((AUTO_MOUSE_TARGET_LAYER)) && timer_elapsed(auto_mouse_context.timer.active) > auto_mouse_context.config.timeout) { layer_off((AUTO_MOUSE_TARGET_LAYER)); - auto_mouse_context.timer.active = 0; + auto_mouse_context.timer.active = 0; + auto_mouse_context.total_mouse_movement = (total_mouse_movement_t){.x = 0, .y = 0, .h = 0, .v = 0}; } } diff --git a/quantum/pointing_device/pointing_device_auto_mouse.h b/quantum/pointing_device/pointing_device_auto_mouse.h index 1343855e00..904f18b68e 100644 --- a/quantum/pointing_device/pointing_device_auto_mouse.h +++ b/quantum/pointing_device/pointing_device_auto_mouse.h @@ -42,9 +42,18 @@ #ifndef AUTO_MOUSE_DEBOUNCE # define AUTO_MOUSE_DEBOUNCE 25 #endif +#ifndef AUTO_MOUSE_THRESHOLD +# define AUTO_MOUSE_THRESHOLD 10 +#endif /* data structure */ typedef struct { + mouse_xy_report_t x; + mouse_xy_report_t y; + int8_t v; + int8_t h; +} total_mouse_movement_t; +typedef struct { struct { bool is_enabled; uint8_t layer; @@ -60,6 +69,7 @@ typedef struct { bool is_toggled; int8_t mouse_key_tracker; } status; + total_mouse_movement_t total_mouse_movement; } auto_mouse_context_t; /* ----------Set up and control------------------------------------------------------------------------------ */ |