Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance overlapping mouse keys control #23341

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/features/mouse_keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,19 @@ Tips:
* Keep `MOUSEKEY_MOVE_DELTA` at 1. This allows precise movements before the gliding effect starts.
* Mouse wheel options are the same as the default accelerated mode, and do not use inertia.

### Overlapping mouse key control

When additional overlapping mouse key is pressed, the mouse cursor will continue in a new direction with the same acceleration. The following settings can be used to reset the acceleration with new overlapping keys for more precise control if desired:

|Define |Default |Description |
|------------------------------|----------------------|-----------------------------------------------------------------------|
|`MOUSEKEY_OVERLAP_RESET` |undefined |Enables overlapping mouse key control |
|`MOUSEKEY_OVERLAP_MOVE_DELTA` |`MOUSEKEY_MOVE_DELTA` |Step size of reset movement acceleration |
|`MOUSEKEY_OVERLAP_WHEEL_DELTA`|`MOUSEKEY_WHEEL_DELTA`|Step size of reset mouse wheel acceleration |
|`MOUSEKEY_OVERLAP_INTERVAL` |`MOUSEKEY_INTERVAL` |Reset time between cursor movements in milliseconds (Kinetic mode only)|

?> This feature will not be applied on Inertial mode

## Use with PS/2 Mouse and Pointing Device

Mouse keys button state is shared with [PS/2 mouse](ps2_mouse) and [pointing device](pointing_device) so mouse keys button presses can be used for clicks and drags.
10 changes: 5 additions & 5 deletions quantum/mousekey.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,18 +391,18 @@ void mousekey_on(uint8_t code) {
}
# endif

# ifndef MOUSEKEY_INERTIA
# if defined(MOUSEKEY_OVERLAP_RESET) && !defined(MOUSEKEY_INERTIA)
// If mouse report is not zero, the current mousekey press is overlapping
// with another. Restart acceleration for smoother directional transition.
if (mouse_report.x || mouse_report.y || mouse_report.h || mouse_report.v) {
# ifdef MK_KINETIC_SPEED
mouse_timer = timer_read() - (MOUSEKEY_INTERVAL << 2);
mouse_timer = timer_read() - MOUSEKEY_OVERLAP_INTERVAL;
# else
mousekey_repeat = MOUSEKEY_MOVE_DELTA;
mousekey_wheel_repeat = MOUSEKEY_WHEEL_DELTA;
mousekey_repeat = MOUSEKEY_OVERLAP_MOVE_DELTA;
mousekey_wheel_repeat = MOUSEKEY_OVERLAP_WHEEL_DELTA;
# endif
}
# endif // ifndef MOUSEKEY_INERTIA
# endif // defined(MOUSEKEY_OVERLAP_RESET) && !defined(MOUSEKEY_INERTIA)

# ifdef MOUSEKEY_INERTIA

Expand Down
10 changes: 10 additions & 0 deletions quantum/mousekey.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

#endif /* #ifndef MK_3_SPEED */

#ifndef MOUSEKEY_OVERLAP_MOVE_DELTA
# define MOUSEKEY_OVERLAP_MOVE_DELTA MOUSEKEY_MOVE_DELTA
#endif
#ifndef MOUSEKEY_OVERLAP_WHEEL_DELTA
# define MOUSEKEY_OVERLAP_WHEEL_DELTA MOUSEKEY_WHEEL_DELTA
#endif
#ifndef MOUSEKEY_OVERLAP_INTERVAL
# define MOUSEKEY_OVERLAP_INTERVAL MOUSEKEY_INTERVAL
zvecr marked this conversation as resolved.
Show resolved Hide resolved
#endif

#ifdef __cplusplus
extern "C" {
#endif
Expand Down
Loading