summaryrefslogtreecommitdiff
path: root/quantum/process_keycode/process_auto_shift.c
diff options
context:
space:
mode:
authorIsaac Elenbaas <isaacelenbaas@gmail.com>2023-09-24 22:45:49 -0400
committerGitHub <noreply@github.com>2023-09-25 12:45:49 +1000
commitdd94877ec6d2ee5c4cdb0e71287abd76585b0268 (patch)
tree26ded3ce8338286243d1b59d597f41329fea6ef4 /quantum/process_keycode/process_auto_shift.c
parent1fb02d5ad87e69d459ae63235bbb3057083866ef (diff)
Improve test invocation, fix Retro Shift bugs, and add Auto+Retro Shift test cases (#15889)
Diffstat (limited to 'quantum/process_keycode/process_auto_shift.c')
-rw-r--r--quantum/process_keycode/process_auto_shift.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c
index 9b78214e43..28a21c4b67 100644
--- a/quantum/process_keycode/process_auto_shift.c
+++ b/quantum/process_keycode/process_auto_shift.c
@@ -66,7 +66,7 @@ __attribute__((weak)) bool get_custom_auto_shifted_key(uint16_t keycode, keyreco
66 return false; 66 return false;
67} 67}
68 68
69/** \brief Called on physical press, returns whether is Auto Shift key */ 69/** \brief Called on physical press, returns whether key is an Auto Shift key */
70__attribute__((weak)) bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record) { 70__attribute__((weak)) bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record) {
71 switch (keycode) { 71 switch (keycode) {
72#ifndef NO_AUTO_SHIFT_ALPHA 72#ifndef NO_AUTO_SHIFT_ALPHA
@@ -178,9 +178,8 @@ static bool autoshift_press(uint16_t keycode, uint16_t now, keyrecord_t *record)
178 } 178 }
179 179
180 // Store record to be sent to user functions if there's no release record then. 180 // Store record to be sent to user functions if there's no release record then.
181 autoshift_lastrecord = *record; 181 autoshift_lastrecord = *record;
182 autoshift_lastrecord.event.pressed = false; 182 autoshift_lastrecord.event.time = 0;
183 autoshift_lastrecord.event.time = 0;
184 // clang-format off 183 // clang-format off
185#if defined(AUTO_SHIFT_REPEAT) || defined(AUTO_SHIFT_REPEAT_PER_KEY) 184#if defined(AUTO_SHIFT_REPEAT) || defined(AUTO_SHIFT_REPEAT_PER_KEY)
186 if (keycode == autoshift_lastkey && 185 if (keycode == autoshift_lastkey &&
@@ -409,8 +408,12 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
409 // If Retro Shift is disabled, possible custom actions shouldn't happen. 408 // If Retro Shift is disabled, possible custom actions shouldn't happen.
410 // clang-format off 409 // clang-format off
411#if defined(RETRO_SHIFT) && !defined(NO_ACTION_TAPPING) 410#if defined(RETRO_SHIFT) && !defined(NO_ACTION_TAPPING)
412# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY 411# ifdef HOLD_ON_OTHER_KEY_PRESS
413 const bool is_hold_on_interrupt = get_hold_on_other_key_press(keycode, record); 412 const bool is_hold_on_interrupt = (IS_QK_MOD_TAP(keycode)
413# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
414 && get_hold_on_other_key_press(keycode, record)
415# endif
416 );
414# else 417# else
415 const bool is_hold_on_interrupt = false; 418 const bool is_hold_on_interrupt = false;
416# endif 419# endif
@@ -450,8 +453,12 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
450#endif 453#endif
451 ) { 454 ) {
452 // Fixes modifiers not being applied to rolls with AUTO_SHIFT_MODIFIERS set. 455 // Fixes modifiers not being applied to rolls with AUTO_SHIFT_MODIFIERS set.
453#ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY 456#ifdef HOLD_ON_OTHER_KEY_PRESS
454 if (autoshift_flags.in_progress && get_hold_on_other_key_press(keycode, record)) { 457 if (autoshift_flags.in_progress
458# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
459 && get_hold_on_other_key_press(keycode, record)
460# endif
461 ) {
455 autoshift_end(KC_NO, now, false, &autoshift_lastrecord); 462 autoshift_end(KC_NO, now, false, &autoshift_lastrecord);
456 } 463 }
457#endif 464#endif
@@ -488,10 +495,8 @@ void retroshift_poll_time(keyevent_t *event) {
488} 495}
489// Used to swap the times of Retro Shifted key and Auto Shift key that interrupted it. 496// Used to swap the times of Retro Shifted key and Auto Shift key that interrupted it.
490void retroshift_swap_times(void) { 497void retroshift_swap_times(void) {
491 if (last_retroshift_time != 0 && autoshift_flags.in_progress) { 498 if (autoshift_flags.in_progress) {
492 uint16_t temp = retroshift_time; 499 autoshift_time = last_retroshift_time;
493 retroshift_time = last_retroshift_time;
494 last_retroshift_time = temp;
495 } 500 }
496} 501}
497#endif 502#endif