diff options
author | Manna Harbour <51143715+manna-harbour@users.noreply.github.com> | 2020-07-03 06:54:15 +1000 |
---|---|---|
committer | Drashna Jael're <drashna@live.com> | 2020-08-08 22:08:38 -0700 |
commit | dce40e33d4e47ca1ac9da91d94c93d9388a86f3d (patch) | |
tree | 50fce01c3697869bcdb2636903740c41c1e1bce3 /tmk_core/protocol/ps2_mouse.c | |
parent | 3fa11d8613535655a22b54714f4b14310a6830a9 (diff) |
Add movement hook to ps2_mouse (#8805)
Process mouse movement in the keymap before it is sent to the host. Example uses
include filtering noise, adding acceleration, and automatically activating a
layer. To use, define the following function in your keymap:
void ps2_mouse_moved_user(report_mouse_t *mouse_report);
Diffstat (limited to 'tmk_core/protocol/ps2_mouse.c')
-rw-r--r-- | tmk_core/protocol/ps2_mouse.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tmk_core/protocol/ps2_mouse.c b/tmk_core/protocol/ps2_mouse.c index a0e52bc7c3..8df465026b 100644 --- a/tmk_core/protocol/ps2_mouse.c +++ b/tmk_core/protocol/ps2_mouse.c @@ -68,6 +68,8 @@ void ps2_mouse_init(void) { __attribute__((weak)) void ps2_mouse_init_user(void) {} +__attribute__((weak)) void ps2_mouse_moved_user(report_mouse_t *mouse_report) {} + void ps2_mouse_task(void) { static uint8_t buttons_prev = 0; extern int tp_buttons; @@ -98,6 +100,9 @@ void ps2_mouse_task(void) { #if PS2_MOUSE_SCROLL_BTN_MASK ps2_mouse_scroll_button_task(&mouse_report); #endif + if (mouse_report.x || mouse_report.y || mouse_report.v) { + ps2_mouse_moved_user(&mouse_report); + } #ifdef PS2_MOUSE_DEBUG_HID // Used to debug the bytes sent to the host ps2_mouse_print_report(&mouse_report); |