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

[Core] Bug fix: Continue Caps Word when AltGr (right Alt) is held. #17156

Merged
merged 1 commit into from
May 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion quantum/process_keycode/process_caps_word.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,17 @@ bool process_caps_word(uint16_t keycode, keyrecord_t* record) {
return true;
}

if (!(mods & ~MOD_MASK_SHIFT)) {
if (!(mods & ~(MOD_MASK_SHIFT | MOD_BIT(KC_RALT)))) {
switch (keycode) {
// Ignore MO, TO, TG, TT, and OSL layer switch keys.
case QK_MOMENTARY ... QK_MOMENTARY_MAX:
case QK_TO ... QK_TO_MAX:
case QK_TOGGLE_LAYER ... QK_TOGGLE_LAYER_MAX:
case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX:
case QK_ONE_SHOT_LAYER ... QK_ONE_SHOT_LAYER_MAX:
// Ignore AltGr.
case KC_RALT:
case OSM(MOD_RALT):
return true;

#ifndef NO_ACTION_TAPPING
Expand Down
30 changes: 30 additions & 0 deletions tests/caps_word/test_caps_word.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,36 @@ TEST_F(CapsWord, SpaceTurnsOffCapsWord) {
testing::Mock::VerifyAndClearExpectations(&driver);
}

// Tests that typing "AltGr + A" produces "Shift + AltGr + A".
TEST_F(CapsWord, ShiftsAltGrSymbols) {
TestDriver driver;
KeymapKey key_a(0, 0, 0, KC_A);
KeymapKey key_altgr(0, 1, 0, KC_RALT);
set_keymap({key_a, key_altgr});

// Allow any number of reports with no keys or only modifiers.
// clang-format off
EXPECT_CALL(driver, send_keyboard_mock(AnyOf(
KeyboardReport(),
KeyboardReport(KC_RALT),
KeyboardReport(KC_LSFT, KC_RALT))))
.Times(AnyNumber());
// Expect "Shift + AltGr + A, Space".
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_RALT, KC_A)));
// clang-format on

// Turn on Caps Word and type "AltGr + A".
caps_word_on();

key_altgr.press();
run_one_scan_loop();
TapKeys(key_a);
run_one_scan_loop();
key_altgr.release();

testing::Mock::VerifyAndClearExpectations(&driver);
}

struct CapsWordBothShiftsParams {
std::string name;
uint16_t left_shift_keycode;
Expand Down