diff options
| author | Manna Harbour <51143715+manna-harbour@users.noreply.github.com> | 2020-07-03 06:54:15 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-02 21:54:15 +0100 |
| commit | b7dc2eb9ab2bb3c6ac9ac8e975728002e0e9d62d (patch) | |
| tree | c711547dbd79f0dee916a7cf2e28f64ab0820645 /tmk_core | |
| parent | 00fc35539d774c43cde383a8d2cc8b254787ce6c (diff) | |
| download | qmk_firmware-b7dc2eb9ab2bb3c6ac9ac8e975728002e0e9d62d.tar.gz qmk_firmware-b7dc2eb9ab2bb3c6ac9ac8e975728002e0e9d62d.zip | |
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')
| -rw-r--r-- | tmk_core/protocol/ps2_mouse.c | 5 | ||||
| -rw-r--r-- | tmk_core/protocol/ps2_mouse.h | 3 |
2 files changed, 8 insertions, 0 deletions
diff --git a/tmk_core/protocol/ps2_mouse.c b/tmk_core/protocol/ps2_mouse.c index a0e52bc7c..8df465026 100644 --- a/tmk_core/protocol/ps2_mouse.c +++ b/tmk_core/protocol/ps2_mouse.c | |||
| @@ -68,6 +68,8 @@ void ps2_mouse_init(void) { | |||
| 68 | 68 | ||
| 69 | __attribute__((weak)) void ps2_mouse_init_user(void) {} | 69 | __attribute__((weak)) void ps2_mouse_init_user(void) {} |
| 70 | 70 | ||
| 71 | __attribute__((weak)) void ps2_mouse_moved_user(report_mouse_t *mouse_report) {} | ||
| 72 | |||
| 71 | void ps2_mouse_task(void) { | 73 | void ps2_mouse_task(void) { |
| 72 | static uint8_t buttons_prev = 0; | 74 | static uint8_t buttons_prev = 0; |
| 73 | extern int tp_buttons; | 75 | extern int tp_buttons; |
| @@ -98,6 +100,9 @@ void ps2_mouse_task(void) { | |||
| 98 | #if PS2_MOUSE_SCROLL_BTN_MASK | 100 | #if PS2_MOUSE_SCROLL_BTN_MASK |
| 99 | ps2_mouse_scroll_button_task(&mouse_report); | 101 | ps2_mouse_scroll_button_task(&mouse_report); |
| 100 | #endif | 102 | #endif |
| 103 | if (mouse_report.x || mouse_report.y || mouse_report.v) { | ||
| 104 | ps2_mouse_moved_user(&mouse_report); | ||
| 105 | } | ||
| 101 | #ifdef PS2_MOUSE_DEBUG_HID | 106 | #ifdef PS2_MOUSE_DEBUG_HID |
| 102 | // Used to debug the bytes sent to the host | 107 | // Used to debug the bytes sent to the host |
| 103 | ps2_mouse_print_report(&mouse_report); | 108 | ps2_mouse_print_report(&mouse_report); |
diff --git a/tmk_core/protocol/ps2_mouse.h b/tmk_core/protocol/ps2_mouse.h index 30053ef18..d743fb3d8 100644 --- a/tmk_core/protocol/ps2_mouse.h +++ b/tmk_core/protocol/ps2_mouse.h | |||
| @@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 20 | 20 | ||
| 21 | #include <stdbool.h> | 21 | #include <stdbool.h> |
| 22 | #include "debug.h" | 22 | #include "debug.h" |
| 23 | #include "report.h" | ||
| 23 | 24 | ||
| 24 | #define PS2_MOUSE_SEND(command, message) \ | 25 | #define PS2_MOUSE_SEND(command, message) \ |
| 25 | do { \ | 26 | do { \ |
| @@ -174,4 +175,6 @@ void ps2_mouse_set_resolution(ps2_mouse_resolution_t resolution); | |||
| 174 | 175 | ||
| 175 | void ps2_mouse_set_sample_rate(ps2_mouse_sample_rate_t sample_rate); | 176 | void ps2_mouse_set_sample_rate(ps2_mouse_sample_rate_t sample_rate); |
| 176 | 177 | ||
| 178 | void ps2_mouse_moved_user(report_mouse_t *mouse_report); | ||
| 179 | |||
| 177 | #endif | 180 | #endif |
