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

Started to add other acceleration modifiers #1169

Closed
Closed
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
2 changes: 1 addition & 1 deletion quantum/keymap_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ action_t action_for_key(uint8_t layer, keypos_t key)
case KC_AUDIO_MUTE ... KC_MEDIA_REWIND:
action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode));
break;
case KC_MS_UP ... KC_MS_ACCEL2:
case KC_MS_UP ... KC_MS_UPSPED:
action.code = ACTION_MOUSEKEY(keycode);
break;
case KC_TRNS:
Expand Down
9 changes: 6 additions & 3 deletions tmk_core/common/keycode.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define KC_ACL0 KC_MS_ACCEL0
#define KC_ACL1 KC_MS_ACCEL1
#define KC_ACL2 KC_MS_ACCEL2
#define KC_ACL3 KC_MS_ACCEL3
#define KC_USPD KC_MS_UPSPED
#define KC_DSPD KC_MS_DNSPED
/* Sytem Control */
#define KC_PWR KC_SYSTEM_POWER
#define KC_SLEP KC_SYSTEM_SLEEP
Expand Down Expand Up @@ -481,9 +484,9 @@ enum internal_special_keycodes {
KC_MS_WH_LEFT,
KC_MS_WH_RIGHT, /* 0xFC */
/* Mousekey accel */
KC_MS_ACCEL0,
KC_MS_ACCEL1,
KC_MS_ACCEL2 /* 0xFF */
KC_MS_ACCEL3,
KC_MS_DNSPED,
KC_MS_UPSPED /* 0xFF */
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to remove the existing MS_ACCEL because the last register 0xFF was already taken up

};

#endif /* KEYCODE_H */
47 changes: 29 additions & 18 deletions tmk_core/common/mousekey.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ uint8_t mk_max_speed = MOUSEKEY_MAX_SPEED;
uint8_t mk_time_to_max = MOUSEKEY_TIME_TO_MAX;
/* ramp used to reach maximum pointer speed (NOT SUPPORTED) */
//int8_t mk_curve = 0;
uint8_t mk_move_delta = MOUSEKEY_MOVE_DELTA;
/* wheel params */
uint8_t mk_wheel_max_speed = MOUSEKEY_WHEEL_MAX_SPEED;
uint8_t mk_wheel_time_to_max = MOUSEKEY_WHEEL_TIME_TO_MAX;
Expand All @@ -60,17 +61,27 @@ static uint8_t move_unit(void)
{
uint16_t unit;
if (mousekey_accel & (1<<0)) {
unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed)/4;
unit = (mk_move_delta * mk_max_speed)*2;
} else if (mousekey_accel & (1<<1)) {
unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed)/2;
if (mk_move_delta < 10) mk_move_delta++;
unit = (mk_move_delta * mk_max_speed);
} else if (mousekey_accel & (1<<2)) {
unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed);
if (mk_move_delta > 1) mk_move_delta--;
unit = (mk_move_delta * mk_max_speed);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding and removing from the delta currently work, however it would be better if they could only change the value once per keypress

// } else if (mousekey_accel & (1<<3)) {
// unit = (mk_move_delta * mk_max_speed)*2;
// } else if (mousekey_accel & (1<<4)) {
// mk_move_delta++;
// unit = (mk_move_delta * mk_max_speed);
// } else if (mousekey_accel & (1<<5)) {
// mk_move_delta--;
// unit = (mk_move_delta * mk_max_speed);
} else if (mousekey_repeat == 0) {
unit = MOUSEKEY_MOVE_DELTA;
unit = mk_move_delta;
} else if (mousekey_repeat >= mk_time_to_max) {
unit = MOUSEKEY_MOVE_DELTA * mk_max_speed;
unit = mk_move_delta * mk_max_speed;
} else {
unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed * mousekey_repeat) / mk_time_to_max;
unit = (mk_move_delta * mk_max_speed * mousekey_repeat) / mk_time_to_max;
}
return (unit > MOUSEKEY_MOVE_MAX ? MOUSEKEY_MOVE_MAX : (unit == 0 ? 1 : unit));
}
Expand Down Expand Up @@ -137,12 +148,12 @@ void mousekey_on(uint8_t code)
else if (code == KC_MS_WH_RIGHT) mouse_report.h = wheel_unit();
else if (code == KC_MS_BTN1) mouse_report.buttons |= MOUSE_BTN1;
else if (code == KC_MS_BTN2) mouse_report.buttons |= MOUSE_BTN2;
else if (code == KC_MS_BTN3) mouse_report.buttons |= MOUSE_BTN3;
else if (code == KC_MS_BTN4) mouse_report.buttons |= MOUSE_BTN4;
else if (code == KC_MS_BTN5) mouse_report.buttons |= MOUSE_BTN5;
else if (code == KC_MS_ACCEL0) mousekey_accel |= (1<<0);
else if (code == KC_MS_ACCEL1) mousekey_accel |= (1<<1);
else if (code == KC_MS_ACCEL2) mousekey_accel |= (1<<2);
else if (code == KC_MS_ACCEL3) mousekey_accel |= (1<<0);
else if (code == KC_MS_UPSPED) mousekey_accel |= (1<<1);
else if (code == KC_MS_DNSPED) mousekey_accel |= (1<<2);
// else if (code == KC_MS_ACCEL3) mousekey_accel |= (1<<3);
// else if (code == KC_MS_UPSPED) mousekey_accel |= (1<<4);
// else if (code == KC_MS_DNSPED) mousekey_accel |= (1<<5);
}

void mousekey_off(uint8_t code)
Expand All @@ -157,12 +168,12 @@ void mousekey_off(uint8_t code)
else if (code == KC_MS_WH_RIGHT && mouse_report.h > 0) mouse_report.h = 0;
else if (code == KC_MS_BTN1) mouse_report.buttons &= ~MOUSE_BTN1;
else if (code == KC_MS_BTN2) mouse_report.buttons &= ~MOUSE_BTN2;
else if (code == KC_MS_BTN3) mouse_report.buttons &= ~MOUSE_BTN3;
else if (code == KC_MS_BTN4) mouse_report.buttons &= ~MOUSE_BTN4;
else if (code == KC_MS_BTN5) mouse_report.buttons &= ~MOUSE_BTN5;
else if (code == KC_MS_ACCEL0) mousekey_accel &= ~(1<<0);
else if (code == KC_MS_ACCEL1) mousekey_accel &= ~(1<<1);
else if (code == KC_MS_ACCEL2) mousekey_accel &= ~(1<<2);
// else if (code == KC_MS_ACCEL0) mousekey_accel &= ~(1<<0);
// else if (code == KC_MS_ACCEL1) mousekey_accel &= ~(1<<1);
// else if (code == KC_MS_ACCEL2) mousekey_accel &= ~(1<<2);
else if (code == KC_MS_ACCEL3) mousekey_accel &= ~(1<<0);
else if (code == KC_MS_UPSPED) mousekey_accel &= ~(1<<1);
else if (code == KC_MS_DNSPED) mousekey_accel &= ~(1<<2);

if (mouse_report.x == 0 && mouse_report.y == 0 && mouse_report.v == 0 && mouse_report.h == 0)
mousekey_repeat = 0;
Expand Down