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

Mousekeys inertia zero friction improvements #23677

Closed
Changes from 1 commit
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
Prev Previous commit
Brought calc_inertia in line with stlyeguide
  • Loading branch information
chaorace committed May 7, 2024
commit f3d9898e76f202f760c97cd37e2eebfac0433b83
10 changes: 6 additions & 4 deletions quantum/mousekey.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,16 +288,18 @@ static int8_t calc_inertia(int8_t direction, int8_t velocity) {
// simulate acceleration and deceleration

// deceleration
if (velocity != 0)
if (velocity != 0) {
velocity = velocity * (256 - MOUSEKEY_FRICTION) / 256;
}

// acceleration
if ((direction > 0) && (velocity < mk_time_to_max))
if ((direction > 0) && (velocity < mk_time_to_max)) {
velocity++;
else if ((direction < 0) && (velocity > -mk_time_to_max))
} else if ((direction < 0) && (velocity > -mk_time_to_max)) {
velocity--;
else if (velocity <= MOUSEKEY_STOP_SPEED && velocity >= -MOUSEKEY_STOP_SPEED)
} else if (velocity <= MOUSEKEY_STOP_SPEED && velocity >= -MOUSEKEY_STOP_SPEED) {
velocity = 0;
}

return velocity;
}
Expand Down
Loading