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 | |
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>
-rw-r--r-- | docs/feature_mouse_keys.md | 22 | ||||
-rw-r--r-- | tmk_core/common/mousekey.c | 72 |
2 files changed, 78 insertions, 16 deletions
diff --git a/docs/feature_mouse_keys.md b/docs/feature_mouse_keys.md index 88a2c7c05..a6b46bc15 100644 --- a/docs/feature_mouse_keys.md +++ b/docs/feature_mouse_keys.md | |||
@@ -39,10 +39,11 @@ In your keymap you can use the following keycodes to map key presses to mouse ac | |||
39 | 39 | ||
40 | ## Configuring mouse keys | 40 | ## Configuring mouse keys |
41 | 41 | ||
42 | Mouse keys supports two different modes to move the cursor: | 42 | Mouse keys supports three different modes to move the cursor: |
43 | 43 | ||
44 | * **Accelerated (default):** Holding movement keys accelerates the cursor until it reaches its maximum speed. | 44 | * **Accelerated (default):** Holding movement keys accelerates the cursor until it reaches its maximum speed. |
45 | * **Constant:** Holding movement keys moves the cursor at constant speeds. | 45 | * **Constant:** Holding movement keys moves the cursor at constant speeds. |
46 | * **Combined:** Holding movement keys accelerates the cursor until it reaches its maximum speed, but holding acceleration and movement keys simultaneously moves the cursor at constant speeds. | ||
46 | 47 | ||
47 | The same principle applies to scrolling. | 48 | The same principle applies to scrolling. |
48 | 49 | ||
@@ -120,3 +121,22 @@ Use the following settings if you want to adjust cursor movement or scrolling: | |||
120 | |`MK_W_INTERVAL_1` |120 |Time between scroll steps (`KC_ACL1`) | | 121 | |`MK_W_INTERVAL_1` |120 |Time between scroll steps (`KC_ACL1`) | |
121 | |`MK_W_OFFSET_2` |1 |Scroll steps per scroll action (`KC_ACL2`) | | 122 | |`MK_W_OFFSET_2` |1 |Scroll steps per scroll action (`KC_ACL2`) | |
122 | |`MK_W_INTERVAL_2` |20 |Time between scroll steps (`KC_ACL2`) | | 123 | |`MK_W_INTERVAL_2` |20 |Time between scroll steps (`KC_ACL2`) | |
124 | |||
125 | ### Combined mode | ||
126 | |||
127 | This mode functions like **Accelerated** mode, however, you can hold `KC_ACL0`, `KC_ACL1` and `KC_ACL2` | ||
128 | to momentarily (while held) set the cursor and scroll speeds to constant speeds. When no acceleration | ||
129 | keys are held, this mode is identical to **Accelerated** mode, and can be modified using all of the | ||
130 | relevant settings. | ||
131 | |||
132 | * **KC_ACL0:** This acceleration sets your cursor to the slowest possible speed. This is useful for very | ||
133 | small and detailed movements of the cursor. | ||
134 | * **KC_ACL1:** This acceleration sets your cursor to half the maximum (user defined) speed. | ||
135 | * **KC_ACL2:** This acceleration sets your cursor to the maximum (computer defined) speed. This is | ||
136 | useful for moving the cursor large distances without much accuracy. | ||
137 | |||
138 | To use constant speed mode, you must at least define `MK_COMBINED` in your keymap’s `config.h` file: | ||
139 | |||
140 | ```c | ||
141 | #define MK_COMBINED | ||
142 | ``` | ||
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; |