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>master
parent
2e08c72e95
commit
19006c9753
|
@ -39,10 +39,11 @@ In your keymap you can use the following keycodes to map key presses to mouse ac
|
||||||
|
|
||||||
## Configuring mouse keys
|
## Configuring mouse keys
|
||||||
|
|
||||||
Mouse keys supports two different modes to move the cursor:
|
Mouse keys supports three different modes to move the cursor:
|
||||||
|
|
||||||
* **Accelerated (default):** Holding movement keys accelerates the cursor until it reaches its maximum speed.
|
* **Accelerated (default):** Holding movement keys accelerates the cursor until it reaches its maximum speed.
|
||||||
* **Constant:** Holding movement keys moves the cursor at constant speeds.
|
* **Constant:** Holding movement keys moves the cursor at constant speeds.
|
||||||
|
* **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.
|
||||||
|
|
||||||
The same principle applies to scrolling.
|
The same principle applies to scrolling.
|
||||||
|
|
||||||
|
@ -120,3 +121,22 @@ Use the following settings if you want to adjust cursor movement or scrolling:
|
||||||
|`MK_W_INTERVAL_1` |120 |Time between scroll steps (`KC_ACL1`) |
|
|`MK_W_INTERVAL_1` |120 |Time between scroll steps (`KC_ACL1`) |
|
||||||
|`MK_W_OFFSET_2` |1 |Scroll steps per scroll action (`KC_ACL2`) |
|
|`MK_W_OFFSET_2` |1 |Scroll steps per scroll action (`KC_ACL2`) |
|
||||||
|`MK_W_INTERVAL_2` |20 |Time between scroll steps (`KC_ACL2`) |
|
|`MK_W_INTERVAL_2` |20 |Time between scroll steps (`KC_ACL2`) |
|
||||||
|
|
||||||
|
### Combined mode
|
||||||
|
|
||||||
|
This mode functions like **Accelerated** mode, however, you can hold `KC_ACL0`, `KC_ACL1` and `KC_ACL2`
|
||||||
|
to momentarily (while held) set the cursor and scroll speeds to constant speeds. When no acceleration
|
||||||
|
keys are held, this mode is identical to **Accelerated** mode, and can be modified using all of the
|
||||||
|
relevant settings.
|
||||||
|
|
||||||
|
* **KC_ACL0:** This acceleration sets your cursor to the slowest possible speed. This is useful for very
|
||||||
|
small and detailed movements of the cursor.
|
||||||
|
* **KC_ACL1:** This acceleration sets your cursor to half the maximum (user defined) speed.
|
||||||
|
* **KC_ACL2:** This acceleration sets your cursor to the maximum (computer defined) speed. This is
|
||||||
|
useful for moving the cursor large distances without much accuracy.
|
||||||
|
|
||||||
|
To use constant speed mode, you must at least define `MK_COMBINED` in your keymap’s `config.h` file:
|
||||||
|
|
||||||
|
```c
|
||||||
|
#define MK_COMBINED
|
||||||
|
```
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2011 Jun Wako <wakojun@gmail.com>
|
* Copyright 2011 Jun Wako <wakojun@gmail.com>
|
||||||
|
*
|
||||||
This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "keycode.h"
|
#include "keycode.h"
|
||||||
|
@ -66,6 +66,8 @@ uint8_t mk_wheel_interval = MOUSEKEY_WHEEL_INTERVAL;
|
||||||
uint8_t mk_wheel_max_speed = MOUSEKEY_WHEEL_MAX_SPEED;
|
uint8_t mk_wheel_max_speed = MOUSEKEY_WHEEL_MAX_SPEED;
|
||||||
uint8_t mk_wheel_time_to_max = MOUSEKEY_WHEEL_TIME_TO_MAX;
|
uint8_t mk_wheel_time_to_max = MOUSEKEY_WHEEL_TIME_TO_MAX;
|
||||||
|
|
||||||
|
#ifndef MK_COMBINED
|
||||||
|
|
||||||
static uint8_t move_unit(void) {
|
static uint8_t move_unit(void) {
|
||||||
uint16_t unit;
|
uint16_t unit;
|
||||||
if (mousekey_accel & (1 << 0)) {
|
if (mousekey_accel & (1 << 0)) {
|
||||||
|
@ -102,6 +104,46 @@ static uint8_t wheel_unit(void) {
|
||||||
return (unit > MOUSEKEY_WHEEL_MAX ? MOUSEKEY_WHEEL_MAX : (unit == 0 ? 1 : unit));
|
return (unit > MOUSEKEY_WHEEL_MAX ? MOUSEKEY_WHEEL_MAX : (unit == 0 ? 1 : unit));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else /* #ifndef MK_COMBINED */
|
||||||
|
|
||||||
|
static uint8_t move_unit(void) {
|
||||||
|
uint16_t unit;
|
||||||
|
if (mousekey_accel & (1 << 0)) {
|
||||||
|
unit = 1;
|
||||||
|
} else if (mousekey_accel & (1 << 1)) {
|
||||||
|
unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed) / 2;
|
||||||
|
} else if (mousekey_accel & (1 << 2)) {
|
||||||
|
unit = MOUSEKEY_MOVE_MAX;
|
||||||
|
} else if (mousekey_repeat == 0) {
|
||||||
|
unit = MOUSEKEY_MOVE_DELTA;
|
||||||
|
} else if (mousekey_repeat >= mk_time_to_max) {
|
||||||
|
unit = MOUSEKEY_MOVE_DELTA * mk_max_speed;
|
||||||
|
} else {
|
||||||
|
unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed * mousekey_repeat) / mk_time_to_max;
|
||||||
|
}
|
||||||
|
return (unit > MOUSEKEY_MOVE_MAX ? MOUSEKEY_MOVE_MAX : (unit == 0 ? 1 : unit));
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t wheel_unit(void) {
|
||||||
|
uint16_t unit;
|
||||||
|
if (mousekey_accel & (1 << 0)) {
|
||||||
|
unit = 1;
|
||||||
|
} else if (mousekey_accel & (1 << 1)) {
|
||||||
|
unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed) / 2;
|
||||||
|
} else if (mousekey_accel & (1 << 2)) {
|
||||||
|
unit = MOUSEKEY_WHEEL_MAX;
|
||||||
|
} else if (mousekey_repeat == 0) {
|
||||||
|
unit = MOUSEKEY_WHEEL_DELTA;
|
||||||
|
} else if (mousekey_repeat >= mk_wheel_time_to_max) {
|
||||||
|
unit = MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed;
|
||||||
|
} else {
|
||||||
|
unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed * mousekey_repeat) / mk_wheel_time_to_max;
|
||||||
|
}
|
||||||
|
return (unit > MOUSEKEY_WHEEL_MAX ? MOUSEKEY_WHEEL_MAX : (unit == 0 ? 1 : unit));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* #ifndef MK_COMBINED */
|
||||||
|
|
||||||
void mousekey_task(void) {
|
void mousekey_task(void) {
|
||||||
// report cursor and scroll movement independently
|
// report cursor and scroll movement independently
|
||||||
report_mouse_t const tmpmr = mouse_report;
|
report_mouse_t const tmpmr = mouse_report;
|
||||||
|
|
Loading…
Reference in New Issue