diff options
| author | nathanvercaemert <50712356+nathanvercaemert@users.noreply.github.com> | 2020-07-20 19:28:38 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-21 09:28:38 +1000 |
| commit | 19006c9753e490bf5e0136e59476530e345c4a8a (patch) | |
| tree | d5987c7781242d613a275527ab0d1a8ecc0a9bb6 /tmk_core/common/mousekey.c | |
| parent | 2e08c72e956748996544a0c3071632427994ed67 (diff) | |
| download | qmk_firmware-19006c9753e490bf5e0136e59476530e345c4a8a.tar.gz qmk_firmware-19006c9753e490bf5e0136e59476530e345c4a8a.zip | |
Implemented New MK_COMBINED Functionality (#9557)
* implemented new mousekey_combined functionality
* minor formatting change to documentation
* Update tmk_core/common/mousekey.c
Co-authored-by: Ryan <fauxpark@gmail.com>
* Update tmk_core/common/mousekey.c
Co-authored-by: Ryan <fauxpark@gmail.com>
* Update tmk_core/common/mousekey.c
Co-authored-by: Ryan <fauxpark@gmail.com>
* Update tmk_core/common/mousekey.c
Co-authored-by: Ryan <fauxpark@gmail.com>
* Update docs/feature_mouse_keys.md
Co-authored-by: Nick Brassel <nick@tzarc.org>
* Update docs/feature_mouse_keys.md
Co-authored-by: Nick Brassel <nick@tzarc.org>
* Update docs/feature_mouse_keys.md
Co-authored-by: Nick Brassel <nick@tzarc.org>
* Update docs/feature_mouse_keys.md
Co-authored-by: Nick Brassel <nick@tzarc.org>
Co-authored-by: Nathan Vercaemert <nathan.vercaemert@gmail.com>
Co-authored-by: Ryan <fauxpark@gmail.com>
Co-authored-by: Nick Brassel <nick@tzarc.org>
Diffstat (limited to 'tmk_core/common/mousekey.c')
| -rw-r--r-- | tmk_core/common/mousekey.c | 72 |
1 files changed, 57 insertions, 15 deletions
diff --git a/tmk_core/common/mousekey.c b/tmk_core/common/mousekey.c index 74fa88abd..661384d65 100644 --- a/tmk_core/common/mousekey.c +++ b/tmk_core/common/mousekey.c | |||
| @@ -1,19 +1,19 @@ | |||
| 1 | /* | 1 | /* |
| 2 | Copyright 2011 Jun Wako <wakojun@gmail.com> | 2 | * Copyright 2011 Jun Wako <wakojun@gmail.com> |
| 3 | 3 | * | |
| 4 | This program is free software: you can redistribute it and/or modify | 4 | * This program is free software: you can redistribute it and/or modify |
| 5 | it under the terms of the GNU General Public License as published by | 5 | * it under the terms of the GNU General Public License as published by |
| 6 | the Free Software Foundation, either version 2 of the License, or | 6 | * the Free Software Foundation, either version 2 of the License, or |
| 7 | (at your option) any later version. | 7 | * (at your option) any later version. |
| 8 | 8 | * | |
| 9 | This program is distributed in the hope that it will be useful, | 9 | * This program is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | GNU General Public License for more details. | 12 | * GNU General Public License for more details. |
| 13 | 13 | * | |
| 14 | You should have received a copy of the GNU General Public License | 14 | * You should have received a copy of the GNU General Public License |
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ | 16 | */ |
| 17 | 17 | ||
| 18 | #include <stdint.h> | 18 | #include <stdint.h> |
| 19 | #include "keycode.h" | 19 | #include "keycode.h" |
| @@ -66,6 +66,8 @@ uint8_t mk_wheel_interval = MOUSEKEY_WHEEL_INTERVAL; | |||
| 66 | uint8_t mk_wheel_max_speed = MOUSEKEY_WHEEL_MAX_SPEED; | 66 | uint8_t mk_wheel_max_speed = MOUSEKEY_WHEEL_MAX_SPEED; |
| 67 | uint8_t mk_wheel_time_to_max = MOUSEKEY_WHEEL_TIME_TO_MAX; | 67 | uint8_t mk_wheel_time_to_max = MOUSEKEY_WHEEL_TIME_TO_MAX; |
| 68 | 68 | ||
| 69 | #ifndef MK_COMBINED | ||
| 70 | |||
| 69 | static uint8_t move_unit(void) { | 71 | static uint8_t move_unit(void) { |
| 70 | uint16_t unit; | 72 | uint16_t unit; |
| 71 | if (mousekey_accel & (1 << 0)) { | 73 | if (mousekey_accel & (1 << 0)) { |
| @@ -102,6 +104,46 @@ static uint8_t wheel_unit(void) { | |||
| 102 | return (unit > MOUSEKEY_WHEEL_MAX ? MOUSEKEY_WHEEL_MAX : (unit == 0 ? 1 : unit)); | 104 | return (unit > MOUSEKEY_WHEEL_MAX ? MOUSEKEY_WHEEL_MAX : (unit == 0 ? 1 : unit)); |
| 103 | } | 105 | } |
| 104 | 106 | ||
| 107 | #else /* #ifndef MK_COMBINED */ | ||
| 108 | |||
| 109 | static uint8_t move_unit(void) { | ||
| 110 | uint16_t unit; | ||
| 111 | if (mousekey_accel & (1 << 0)) { | ||
| 112 | unit = 1; | ||
| 113 | } else if (mousekey_accel & (1 << 1)) { | ||
| 114 | unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed) / 2; | ||
| 115 | } else if (mousekey_accel & (1 << 2)) { | ||
| 116 | unit = MOUSEKEY_MOVE_MAX; | ||
| 117 | } else if (mousekey_repeat == 0) { | ||
| 118 | unit = MOUSEKEY_MOVE_DELTA; | ||
| 119 | } else if (mousekey_repeat >= mk_time_to_max) { | ||
| 120 | unit = MOUSEKEY_MOVE_DELTA * mk_max_speed; | ||
| 121 | } else { | ||
| 122 | unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed * mousekey_repeat) / mk_time_to_max; | ||
| 123 | } | ||
| 124 | return (unit > MOUSEKEY_MOVE_MAX ? MOUSEKEY_MOVE_MAX : (unit == 0 ? 1 : unit)); | ||
| 125 | } | ||
| 126 | |||
| 127 | static uint8_t wheel_unit(void) { | ||
| 128 | uint16_t unit; | ||
| 129 | if (mousekey_accel & (1 << 0)) { | ||
| 130 | unit = 1; | ||
| 131 | } else if (mousekey_accel & (1 << 1)) { | ||
| 132 | unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed) / 2; | ||
| 133 | } else if (mousekey_accel & (1 << 2)) { | ||
| 134 | unit = MOUSEKEY_WHEEL_MAX; | ||
| 135 | } else if (mousekey_repeat == 0) { | ||
| 136 | unit = MOUSEKEY_WHEEL_DELTA; | ||
| 137 | } else if (mousekey_repeat >= mk_wheel_time_to_max) { | ||
| 138 | unit = MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed; | ||
| 139 | } else { | ||
| 140 | unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed * mousekey_repeat) / mk_wheel_time_to_max; | ||
| 141 | } | ||
| 142 | return (unit > MOUSEKEY_WHEEL_MAX ? MOUSEKEY_WHEEL_MAX : (unit == 0 ? 1 : unit)); | ||
| 143 | } | ||
| 144 | |||
| 145 | #endif /* #ifndef MK_COMBINED */ | ||
| 146 | |||
| 105 | void mousekey_task(void) { | 147 | void mousekey_task(void) { |
| 106 | // report cursor and scroll movement independently | 148 | // report cursor and scroll movement independently |
| 107 | report_mouse_t const tmpmr = mouse_report; | 149 | report_mouse_t const tmpmr = mouse_report; |
