keyboard stuff
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Ignore the Layer Lock key in Repeat Key and Caps Word. (#25171)

authored by

Pascal Getreuer and committed by
GitHub
ea85ace4 88453acc

+91 -9
+6 -1
quantum/process_keycode/process_caps_word.c
··· 160 160 case QK_TOGGLE_LAYER ... QK_TOGGLE_LAYER_MAX: 161 161 case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX: 162 162 case QK_ONE_SHOT_LAYER ... QK_ONE_SHOT_LAYER_MAX: 163 + #ifdef TRI_LAYER_ENABLE // Ignore Tri Layer keys. 163 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 170 case KC_RALT: 166 171 case OSM(MOD_RALT): 167 172 return true;
+4 -1
quantum/process_keycode/process_repeat_key.c
··· 41 41 #ifdef TRI_LAYER_ENABLE // Ignore Tri Layer keys. 42 42 case QK_TRI_LAYER_LOWER: 43 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 48 return false; 46 49 47 50 // Ignore hold events on tap-hold keys.
+2
tests/caps_word/test.mk
··· 15 15 16 16 CAPS_WORD_ENABLE = yes 17 17 COMMAND_ENABLE = no 18 + LAYER_LOCK_ENABLE = yes 18 19 SPACE_CADET_ENABLE = yes 20 + TRI_LAYER_ENABLE = yes 19 21
+45 -7
tests/caps_word/test_caps_word.cpp
··· 156 156 // Turn on Caps Word and tap "A". 157 157 caps_word_on(); 158 158 tap_key(key_a); 159 - 160 159 VERIFY_AND_CLEAR(driver); 161 160 161 + EXPECT_EMPTY_REPORT(driver); 162 162 idle_for(CAPS_WORD_IDLE_TIMEOUT); 163 163 run_one_scan_loop(); 164 + VERIFY_AND_CLEAR(driver); 164 165 165 166 // Caps Word should be off and mods should be clear. 166 167 EXPECT_EQ(is_caps_word_on(), false); 167 168 EXPECT_EQ(get_mods() | get_weak_mods(), 0); 168 169 169 - EXPECT_EMPTY_REPORT(driver).Times(AnyNumber()); 170 170 // Expect unshifted "A". 171 171 EXPECT_REPORT(driver, (KC_A)); 172 + EXPECT_EMPTY_REPORT(driver); 172 173 tap_key(key_a); 173 - 174 + run_one_scan_loop(); 174 175 VERIFY_AND_CLEAR(driver); 175 176 } 176 177 ··· 244 245 // clang-format off 245 246 EXPECT_CALL(driver, send_keyboard_mock(AnyOf( 246 247 KeyboardReport(), 248 + KeyboardReport(KC_LSFT), 247 249 KeyboardReport(KC_RALT), 248 250 KeyboardReport(KC_LSFT, KC_RALT)))) 249 251 .Times(AnyNumber()); ··· 259 261 tap_key(key_a); 260 262 run_one_scan_loop(); 261 263 key_altgr.release(); 264 + run_one_scan_loop(); 265 + 266 + idle_for(CAPS_WORD_IDLE_TIMEOUT); 262 267 263 268 VERIFY_AND_CLEAR(driver); 264 269 } ··· 274 279 // clang-format off 275 280 EXPECT_CALL(driver, send_keyboard_mock(AnyOf( 276 281 KeyboardReport(), 282 + KeyboardReport(KC_LSFT), 277 283 KeyboardReport(KC_RALT), 278 284 KeyboardReport(KC_LSFT, KC_RALT)))) 279 285 .Times(AnyNumber()); ··· 289 295 tap_key(key_a); 290 296 run_one_scan_loop(); 291 297 key_altgr_t.release(); 292 - 298 + run_one_scan_loop(); 293 299 EXPECT_TRUE(is_caps_word_on()); 300 + 301 + idle_for(CAPS_WORD_IDLE_TIMEOUT); 302 + 294 303 VERIFY_AND_CLEAR(driver); 295 304 } 296 305 ··· 535 544 // machine at this point. This due to imperfect test isolation which can't 536 545 // reset the caps word double shift timer on test case setup. 537 546 idle_for(CAPS_WORD_IDLE_TIMEOUT); 547 + 548 + EXPECT_REPORT(driver, (KC_ESC)); 549 + EXPECT_EMPTY_REPORT(driver); 538 550 tap_key(esc); 551 + VERIFY_AND_CLEAR(driver); 539 552 } 540 553 541 554 // Double tap doesn't count if another key is pressed between the taps. ··· 589 602 590 603 EXPECT_EQ(is_caps_word_on(), false); // Caps Word is still off. 591 604 clear_oneshot_mods(); 605 + send_keyboard_report(); 592 606 593 607 VERIFY_AND_CLEAR(driver); 594 608 } ··· 626 640 run_one_scan_loop(); 627 641 tap_key(key_b); 628 642 key_osl.release(); 629 - run_one_scan_loop(); 643 + idle_for(CAPS_WORD_IDLE_TIMEOUT + 1); 630 644 631 645 VERIFY_AND_CLEAR(driver); 632 646 } ··· 645 659 KeyboardReport(), 646 660 KeyboardReport(KC_LSFT)))) 647 661 .Times(AnyNumber()); 662 + // clang-format on 648 663 649 664 EXPECT_REPORT(driver, (KC_LSFT, KC_B)); 650 665 caps_word_on(); 651 666 652 667 tap_key(key_osl); 653 668 tap_key(key_b); 654 - run_one_scan_loop(); 669 + idle_for(CAPS_WORD_IDLE_TIMEOUT); 655 670 656 671 VERIFY_AND_CLEAR(driver); 657 672 } 658 - // clang-format on 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); 694 + 695 + VERIFY_AND_CLEAR(driver); 696 + } 659 697 } // namespace
+1
tests/repeat_key/test.mk
··· 16 16 REPEAT_KEY_ENABLE = yes 17 17 18 18 AUTO_SHIFT_ENABLE = yes 19 + LAYER_LOCK_ENABLE = yes
+33
tests/repeat_key/test_repeat_key.cpp
··· 751 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 787 } // namespace