diff options
| -rw-r--r-- | quantum/process_keycode/process_caps_word.c | 7 | ||||
| -rw-r--r-- | quantum/process_keycode/process_repeat_key.c | 5 | ||||
| -rw-r--r-- | tests/caps_word/test.mk | 2 | ||||
| -rw-r--r-- | tests/caps_word/test_caps_word.cpp | 52 | ||||
| -rw-r--r-- | tests/repeat_key/test.mk | 1 | ||||
| -rw-r--r-- | tests/repeat_key/test_repeat_key.cpp | 33 |
6 files changed, 91 insertions, 9 deletions
diff --git a/quantum/process_keycode/process_caps_word.c b/quantum/process_keycode/process_caps_word.c index b8fb868c6d..8ab66cc521 100644 --- a/quantum/process_keycode/process_caps_word.c +++ b/quantum/process_keycode/process_caps_word.c | |||
| @@ -160,8 +160,13 @@ bool process_caps_word(uint16_t keycode, keyrecord_t* record) { | |||
| 160 | case QK_TOGGLE_LAYER ... QK_TOGGLE_LAYER_MAX: | 160 | case QK_TOGGLE_LAYER ... QK_TOGGLE_LAYER_MAX: |
| 161 | case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX: | 161 | case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX: |
| 162 | case QK_ONE_SHOT_LAYER ... QK_ONE_SHOT_LAYER_MAX: | 162 | case QK_ONE_SHOT_LAYER ... QK_ONE_SHOT_LAYER_MAX: |
| 163 | #ifdef TRI_LAYER_ENABLE // Ignore Tri Layer keys. | ||
| 163 | case QK_TRI_LAYER_LOWER ... QK_TRI_LAYER_UPPER: | 164 | case QK_TRI_LAYER_LOWER ... QK_TRI_LAYER_UPPER: |
| 164 | // Ignore AltGr. | 165 | #endif // TRI_LAYER_ENABLE |
| 166 | #ifdef LAYER_LOCK_ENABLE // Ignore Layer Lock key. | ||
| 167 | case QK_LAYER_LOCK: | ||
| 168 | #endif // LAYER_LOCK_ENABLE | ||
| 169 | // Ignore AltGr. | ||
| 165 | case KC_RALT: | 170 | case KC_RALT: |
| 166 | case OSM(MOD_RALT): | 171 | case OSM(MOD_RALT): |
| 167 | return true; | 172 | return true; |
diff --git a/quantum/process_keycode/process_repeat_key.c b/quantum/process_keycode/process_repeat_key.c index 73f4ddedcf..fdeed4f466 100644 --- a/quantum/process_keycode/process_repeat_key.c +++ b/quantum/process_keycode/process_repeat_key.c | |||
| @@ -41,7 +41,10 @@ static bool remember_last_key(uint16_t keycode, keyrecord_t* record, uint8_t* re | |||
| 41 | #ifdef TRI_LAYER_ENABLE // Ignore Tri Layer keys. | 41 | #ifdef TRI_LAYER_ENABLE // Ignore Tri Layer keys. |
| 42 | case QK_TRI_LAYER_LOWER: | 42 | case QK_TRI_LAYER_LOWER: |
| 43 | case QK_TRI_LAYER_UPPER: | 43 | case QK_TRI_LAYER_UPPER: |
| 44 | #endif // TRI_LAYER_ENABLE | 44 | #endif // TRI_LAYER_ENABLE |
| 45 | #ifdef LAYER_LOCK_ENABLE // Ignore Layer Lock key. | ||
| 46 | case QK_LAYER_LOCK: | ||
| 47 | #endif // LAYER_LOCK_ENABLE | ||
| 45 | return false; | 48 | return false; |
| 46 | 49 | ||
| 47 | // Ignore hold events on tap-hold keys. | 50 | // Ignore hold events on tap-hold keys. |
diff --git a/tests/caps_word/test.mk b/tests/caps_word/test.mk index 2509b01858..6d5664aa05 100644 --- a/tests/caps_word/test.mk +++ b/tests/caps_word/test.mk | |||
| @@ -15,5 +15,7 @@ | |||
| 15 | 15 | ||
| 16 | CAPS_WORD_ENABLE = yes | 16 | CAPS_WORD_ENABLE = yes |
| 17 | COMMAND_ENABLE = no | 17 | COMMAND_ENABLE = no |
| 18 | LAYER_LOCK_ENABLE = yes | ||
| 18 | SPACE_CADET_ENABLE = yes | 19 | SPACE_CADET_ENABLE = yes |
| 20 | TRI_LAYER_ENABLE = yes | ||
| 19 | 21 | ||
diff --git a/tests/caps_word/test_caps_word.cpp b/tests/caps_word/test_caps_word.cpp index 28d86e9324..4b58790915 100644 --- a/tests/caps_word/test_caps_word.cpp +++ b/tests/caps_word/test_caps_word.cpp | |||
| @@ -156,21 +156,22 @@ TEST_F(CapsWord, IdleTimeout) { | |||
| 156 | // Turn on Caps Word and tap "A". | 156 | // Turn on Caps Word and tap "A". |
| 157 | caps_word_on(); | 157 | caps_word_on(); |
| 158 | tap_key(key_a); | 158 | tap_key(key_a); |
| 159 | |||
| 160 | VERIFY_AND_CLEAR(driver); | 159 | VERIFY_AND_CLEAR(driver); |
| 161 | 160 | ||
| 161 | EXPECT_EMPTY_REPORT(driver); | ||
| 162 | idle_for(CAPS_WORD_IDLE_TIMEOUT); | 162 | idle_for(CAPS_WORD_IDLE_TIMEOUT); |
| 163 | run_one_scan_loop(); | 163 | run_one_scan_loop(); |
| 164 | VERIFY_AND_CLEAR(driver); | ||
| 164 | 165 | ||
| 165 | // Caps Word should be off and mods should be clear. | 166 | // Caps Word should be off and mods should be clear. |
| 166 | EXPECT_EQ(is_caps_word_on(), false); | 167 | EXPECT_EQ(is_caps_word_on(), false); |
| 167 | EXPECT_EQ(get_mods() | get_weak_mods(), 0); | 168 | EXPECT_EQ(get_mods() | get_weak_mods(), 0); |
| 168 | 169 | ||
| 169 | EXPECT_EMPTY_REPORT(driver).Times(AnyNumber()); | ||
| 170 | // Expect unshifted "A". | 170 | // Expect unshifted "A". |
| 171 | EXPECT_REPORT(driver, (KC_A)); | 171 | EXPECT_REPORT(driver, (KC_A)); |
| 172 | EXPECT_EMPTY_REPORT(driver); | ||
| 172 | tap_key(key_a); | 173 | tap_key(key_a); |
| 173 | 174 | run_one_scan_loop(); | |
| 174 | VERIFY_AND_CLEAR(driver); | 175 | VERIFY_AND_CLEAR(driver); |
| 175 | } | 176 | } |
| 176 | 177 | ||
| @@ -244,6 +245,7 @@ TEST_F(CapsWord, ShiftsAltGrSymbols) { | |||
| 244 | // clang-format off | 245 | // clang-format off |
| 245 | EXPECT_CALL(driver, send_keyboard_mock(AnyOf( | 246 | EXPECT_CALL(driver, send_keyboard_mock(AnyOf( |
| 246 | KeyboardReport(), | 247 | KeyboardReport(), |
| 248 | KeyboardReport(KC_LSFT), | ||
| 247 | KeyboardReport(KC_RALT), | 249 | KeyboardReport(KC_RALT), |
| 248 | KeyboardReport(KC_LSFT, KC_RALT)))) | 250 | KeyboardReport(KC_LSFT, KC_RALT)))) |
| 249 | .Times(AnyNumber()); | 251 | .Times(AnyNumber()); |
| @@ -259,6 +261,9 @@ TEST_F(CapsWord, ShiftsAltGrSymbols) { | |||
| 259 | tap_key(key_a); | 261 | tap_key(key_a); |
| 260 | run_one_scan_loop(); | 262 | run_one_scan_loop(); |
| 261 | key_altgr.release(); | 263 | key_altgr.release(); |
| 264 | run_one_scan_loop(); | ||
| 265 | |||
| 266 | idle_for(CAPS_WORD_IDLE_TIMEOUT); | ||
| 262 | 267 | ||
| 263 | VERIFY_AND_CLEAR(driver); | 268 | VERIFY_AND_CLEAR(driver); |
| 264 | } | 269 | } |
| @@ -274,6 +279,7 @@ TEST_F(CapsWord, ShiftsModTapAltGrSymbols) { | |||
| 274 | // clang-format off | 279 | // clang-format off |
| 275 | EXPECT_CALL(driver, send_keyboard_mock(AnyOf( | 280 | EXPECT_CALL(driver, send_keyboard_mock(AnyOf( |
| 276 | KeyboardReport(), | 281 | KeyboardReport(), |
| 282 | KeyboardReport(KC_LSFT), | ||
| 277 | KeyboardReport(KC_RALT), | 283 | KeyboardReport(KC_RALT), |
| 278 | KeyboardReport(KC_LSFT, KC_RALT)))) | 284 | KeyboardReport(KC_LSFT, KC_RALT)))) |
| 279 | .Times(AnyNumber()); | 285 | .Times(AnyNumber()); |
| @@ -289,8 +295,11 @@ TEST_F(CapsWord, ShiftsModTapAltGrSymbols) { | |||
| 289 | tap_key(key_a); | 295 | tap_key(key_a); |
| 290 | run_one_scan_loop(); | 296 | run_one_scan_loop(); |
| 291 | key_altgr_t.release(); | 297 | key_altgr_t.release(); |
| 292 | 298 | run_one_scan_loop(); | |
| 293 | EXPECT_TRUE(is_caps_word_on()); | 299 | EXPECT_TRUE(is_caps_word_on()); |
| 300 | |||
| 301 | idle_for(CAPS_WORD_IDLE_TIMEOUT); | ||
| 302 | |||
| 294 | VERIFY_AND_CLEAR(driver); | 303 | VERIFY_AND_CLEAR(driver); |
| 295 | } | 304 | } |
| 296 | 305 | ||
| @@ -535,7 +544,11 @@ TEST_P(CapsWordDoubleTapShift, Activation) { | |||
| 535 | // machine at this point. This due to imperfect test isolation which can't | 544 | // machine at this point. This due to imperfect test isolation which can't |
| 536 | // reset the caps word double shift timer on test case setup. | 545 | // reset the caps word double shift timer on test case setup. |
| 537 | idle_for(CAPS_WORD_IDLE_TIMEOUT); | 546 | idle_for(CAPS_WORD_IDLE_TIMEOUT); |
| 547 | |||
| 548 | EXPECT_REPORT(driver, (KC_ESC)); | ||
| 549 | EXPECT_EMPTY_REPORT(driver); | ||
| 538 | tap_key(esc); | 550 | tap_key(esc); |
| 551 | VERIFY_AND_CLEAR(driver); | ||
| 539 | } | 552 | } |
| 540 | 553 | ||
| 541 | // Double tap doesn't count if another key is pressed between the taps. | 554 | // Double tap doesn't count if another key is pressed between the taps. |
| @@ -589,6 +602,7 @@ TEST_P(CapsWordDoubleTapShift, SlowTaps) { | |||
| 589 | 602 | ||
| 590 | EXPECT_EQ(is_caps_word_on(), false); // Caps Word is still off. | 603 | EXPECT_EQ(is_caps_word_on(), false); // Caps Word is still off. |
| 591 | clear_oneshot_mods(); | 604 | clear_oneshot_mods(); |
| 605 | send_keyboard_report(); | ||
| 592 | 606 | ||
| 593 | VERIFY_AND_CLEAR(driver); | 607 | VERIFY_AND_CLEAR(driver); |
| 594 | } | 608 | } |
| @@ -626,7 +640,7 @@ TEST_F(CapsWord, IgnoresOSLHold) { | |||
| 626 | run_one_scan_loop(); | 640 | run_one_scan_loop(); |
| 627 | tap_key(key_b); | 641 | tap_key(key_b); |
| 628 | key_osl.release(); | 642 | key_osl.release(); |
| 629 | run_one_scan_loop(); | 643 | idle_for(CAPS_WORD_IDLE_TIMEOUT + 1); |
| 630 | 644 | ||
| 631 | VERIFY_AND_CLEAR(driver); | 645 | VERIFY_AND_CLEAR(driver); |
| 632 | } | 646 | } |
| @@ -645,15 +659,39 @@ TEST_F(CapsWord, IgnoresOSLTap) { | |||
| 645 | KeyboardReport(), | 659 | KeyboardReport(), |
| 646 | KeyboardReport(KC_LSFT)))) | 660 | KeyboardReport(KC_LSFT)))) |
| 647 | .Times(AnyNumber()); | 661 | .Times(AnyNumber()); |
| 662 | // clang-format on | ||
| 648 | 663 | ||
| 649 | EXPECT_REPORT(driver, (KC_LSFT, KC_B)); | 664 | EXPECT_REPORT(driver, (KC_LSFT, KC_B)); |
| 650 | caps_word_on(); | 665 | caps_word_on(); |
| 651 | 666 | ||
| 652 | tap_key(key_osl); | 667 | tap_key(key_osl); |
| 653 | tap_key(key_b); | 668 | tap_key(key_b); |
| 654 | run_one_scan_loop(); | 669 | idle_for(CAPS_WORD_IDLE_TIMEOUT); |
| 670 | |||
| 671 | VERIFY_AND_CLEAR(driver); | ||
| 672 | } | ||
| 673 | |||
| 674 | TEST_F(CapsWord, IgnoresLayerLockKey) { | ||
| 675 | TestDriver driver; | ||
| 676 | KeymapKey key_llock(0, 1, 0, QK_LAYER_LOCK); | ||
| 677 | KeymapKey key_b(0, 0, 0, KC_B); | ||
| 678 | set_keymap({key_llock, key_b}); | ||
| 679 | |||
| 680 | // Allow any number of reports with no keys or only modifiers. | ||
| 681 | // clang-format off | ||
| 682 | EXPECT_CALL(driver, send_keyboard_mock(AnyOf( | ||
| 683 | KeyboardReport(), | ||
| 684 | KeyboardReport(KC_LSFT)))) | ||
| 685 | .Times(AnyNumber()); | ||
| 686 | // clang-format on | ||
| 687 | |||
| 688 | EXPECT_REPORT(driver, (KC_LSFT, KC_B)); | ||
| 689 | caps_word_on(); | ||
| 690 | |||
| 691 | tap_key(key_llock); | ||
| 692 | tap_key(key_b); | ||
| 693 | idle_for(CAPS_WORD_IDLE_TIMEOUT); | ||
| 655 | 694 | ||
| 656 | VERIFY_AND_CLEAR(driver); | 695 | VERIFY_AND_CLEAR(driver); |
| 657 | } | 696 | } |
| 658 | // clang-format on | ||
| 659 | } // namespace | 697 | } // namespace |
diff --git a/tests/repeat_key/test.mk b/tests/repeat_key/test.mk index aec8ff3bfb..186207ffc2 100644 --- a/tests/repeat_key/test.mk +++ b/tests/repeat_key/test.mk | |||
| @@ -16,3 +16,4 @@ | |||
| 16 | REPEAT_KEY_ENABLE = yes | 16 | REPEAT_KEY_ENABLE = yes |
| 17 | 17 | ||
| 18 | AUTO_SHIFT_ENABLE = yes | 18 | AUTO_SHIFT_ENABLE = yes |
| 19 | LAYER_LOCK_ENABLE = yes | ||
diff --git a/tests/repeat_key/test_repeat_key.cpp b/tests/repeat_key/test_repeat_key.cpp index eee44fc104..ed5d618761 100644 --- a/tests/repeat_key/test_repeat_key.cpp +++ b/tests/repeat_key/test_repeat_key.cpp | |||
| @@ -751,4 +751,37 @@ TEST_F(RepeatKey, RepeatKeyInvoke) { | |||
| 751 | testing::Mock::VerifyAndClearExpectations(&driver); | 751 | testing::Mock::VerifyAndClearExpectations(&driver); |
| 752 | } | 752 | } |
| 753 | 753 | ||
| 754 | // Check that mods and Layer Lock are not remembered. | ||
| 755 | TEST_F(RepeatKey, IgnoredKeys) { | ||
| 756 | TestDriver driver; | ||
| 757 | KeymapKey regular_key(0, 0, 0, KC_A); | ||
| 758 | KeymapKey key_repeat(0, 1, 0, QK_REP); | ||
| 759 | KeymapKey key_lsft(0, 2, 0, KC_LSFT); | ||
| 760 | KeymapKey key_lctl(0, 3, 0, KC_LCTL); | ||
| 761 | KeymapKey key_llck(0, 4, 0, QK_LAYER_LOCK); | ||
| 762 | set_keymap({regular_key, key_repeat, key_lsft, key_lctl, key_llck}); | ||
| 763 | |||
| 764 | // Allow any number of empty reports. | ||
| 765 | EXPECT_EMPTY_REPORT(driver).Times(AnyNumber()); | ||
| 766 | { | ||
| 767 | InSequence seq; | ||
| 768 | EXPECT_REPORT(driver, (KC_A)); | ||
| 769 | EXPECT_REPORT(driver, (KC_LSFT)); | ||
| 770 | EXPECT_REPORT(driver, (KC_LCTL)); | ||
| 771 | EXPECT_REPORT(driver, (KC_A)); | ||
| 772 | EXPECT_REPORT(driver, (KC_A)); | ||
| 773 | } | ||
| 774 | |||
| 775 | tap_key(regular_key); // Taps the KC_A key. | ||
| 776 | |||
| 777 | // Tap Shift, Ctrl, and Layer Lock keys, which should not be remembered. | ||
| 778 | tap_keys(key_lsft, key_lctl, key_llck); | ||
| 779 | EXPECT_KEYCODE_EQ(get_last_keycode(), KC_A); | ||
| 780 | |||
| 781 | // Tapping the Repeat Key should still reproduce KC_A. | ||
| 782 | tap_keys(key_repeat, key_repeat); | ||
| 783 | |||
| 784 | testing::Mock::VerifyAndClearExpectations(&driver); | ||
| 785 | } | ||
| 786 | |||
| 754 | } // namespace | 787 | } // namespace |
