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

fix broken activation of kinetic mouse mode #11766

Closed
wants to merge 2 commits into from
Closed
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
19 changes: 11 additions & 8 deletions tmk_core/common/mousekey.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,16 @@ uint8_t mk_time_to_max = MOUSEKEY_TIME_TO_MAX;
/* milliseconds between the initial key press and first repeated motion event (0-2550) */
uint8_t mk_wheel_delay = MOUSEKEY_WHEEL_DELAY / 10;
/* milliseconds between repeated motion events (0-255) */
#ifndef MK_KINETIC_SPEED
uint8_t mk_wheel_interval = MOUSEKEY_WHEEL_INTERVAL;
#else /* #ifndef MK_KINETIC_SPEED */
float mk_wheel_interval = 1000.0f / MOUSEKEY_WHEEL_INITIAL_MOVEMENTS;
#endif /* #ifndef MK_KINETIC_SPEED */
uint8_t mk_wheel_max_speed = MOUSEKEY_WHEEL_MAX_SPEED;
uint8_t mk_wheel_time_to_max = MOUSEKEY_WHEEL_TIME_TO_MAX;

# ifndef MK_COMBINED
# ifndef MK_KINETIC_SPEED

static uint8_t move_unit(void) {
uint16_t unit;
Expand Down Expand Up @@ -107,8 +112,7 @@ static uint8_t wheel_unit(void) {
return (unit > MOUSEKEY_WHEEL_MAX ? MOUSEKEY_WHEEL_MAX : (unit == 0 ? 1 : unit));
}

# else /* #ifndef MK_COMBINED */
# ifndef MK_KINETIC_SPEED
# else /* #ifndef MK_KINETIC_SPEED */

/*
* Kinetic movement acceleration algorithm
Expand All @@ -128,8 +132,8 @@ const uint16_t mk_decelerated_speed = MOUSEKEY_DECELERATED_SPEED;
const uint16_t mk_initial_speed = MOUSEKEY_INITIAL_SPEED;

static uint8_t move_unit(void) {
float speed = mk_initial_speed;

float speed = (float)mk_initial_speed;
if (mousekey_accel & ((1 << 0) | (1 << 2))) {
speed = mousekey_accel & (1 << 2) ? mk_accelerated_speed : mk_decelerated_speed;
} else if (mousekey_repeat && mouse_timer) {
Expand All @@ -146,8 +150,6 @@ static uint8_t move_unit(void) {
return speed > MOUSEKEY_MOVE_MAX ? MOUSEKEY_MOVE_MAX : speed;
}

float mk_wheel_interval = 1000.0f / MOUSEKEY_WHEEL_INITIAL_MOVEMENTS;

static uint8_t wheel_unit(void) {
float speed = MOUSEKEY_WHEEL_INITIAL_MOVEMENTS;

Expand All @@ -166,7 +168,9 @@ static uint8_t wheel_unit(void) {
return 1;
}

# else /* #ifndef MK_KINETIC_SPEED */
# endif /* #ifndef MK_KINETIC_SPEED */

# else /* #ifndef MK_COMBINED */

static uint8_t move_unit(void) {
uint16_t unit;
Expand Down Expand Up @@ -204,7 +208,6 @@ static uint8_t wheel_unit(void) {
return (unit > MOUSEKEY_WHEEL_MAX ? MOUSEKEY_WHEEL_MAX : (unit == 0 ? 1 : unit));
}

# endif /* #ifndef MK_KINETIC_SPEED */
# endif /* #ifndef MK_COMBINED */

void mousekey_task(void) {
Expand Down