Skip to content

Commit

Permalink
Fixed shift not being released and removed unnecessary flush_shift.
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacElenbaas committed Jul 31, 2020
1 parent e65a377 commit 3491f86
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions quantum/process_keycode/process_auto_shift.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@ void autoshift_timer_report(void) {
send_string((const char *)display);
}

/** \brief Releases the shift key if it was held by autoshift */
static void autoshift_flush_shift(void) {
del_weak_mods(MOD_BIT(KC_LSFT));
autoshift_flags.holding_shift = false;
}

/** \brief Record the press of an autoshiftable key
*
* \return Whether the record should be further processed.
Expand Down Expand Up @@ -131,17 +125,18 @@ static void autoshift_end(uint16_t keycode, uint16_t now, bool matrix_trigger) {
wait_ms(TAP_CODE_DELAY);
# endif
unregister_code(autoshift_lastkey);
autoshift_flush_shift();
del_weak_mods(MOD_BIT(KC_LSFT));
} else {
// Release after keyrepeat.
unregister_code(keycode);
if (keycode == autoshift_lastkey) {
// This will only fire when the key was the last auto-shiftable
// pressed. That prevents aaaaBBBB then releasing a from unshifting
// later Bs (if B wasn't auto-shiftable).
autoshift_flush_shift();
del_weak_mods(MOD_BIT(KC_LSFT));
}
}
send_keyboard_report(); // del_weak_mods doesn't send one.
// Roll the autoshift_time forward for detecting tap-and-hold.
autoshift_time = now;
}
Expand All @@ -166,14 +161,12 @@ void autoshift_enable(void) { autoshift_flags.enabled = true; }

void autoshift_disable(void) {
autoshift_flags.enabled = false;
autoshift_flush_shift();
del_weak_mods(MOD_BIT(KC_LSFT));
}

void autoshift_toggle(void) {
autoshift_flags.enabled = !autoshift_flags.enabled;
if (!autoshift_flags.enabled) {
autoshift_flush_shift();
}
del_weak_mods(MOD_BIT(KC_LSFT));
}

bool get_autoshift_state(void) { return autoshift_flags.enabled; }
Expand All @@ -190,7 +183,7 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
autoshift_end(KC_NO, record->event.time, false);
}
// For pressing another key while keyrepeating shifted autoshift.
autoshift_flush_shift();
del_weak_mods(MOD_BIT(KC_LSFT));

switch (keycode) {
case KC_ASUP:
Expand Down

0 comments on commit 3491f86

Please sign in to comment.