summaryrefslogtreecommitdiff
path: root/tests/basic
diff options
context:
space:
mode:
authorFelix Kuehling <67731127+fxkuehl@users.noreply.github.com>2022-11-28 03:16:38 -0500
committerGitHub <noreply@github.com>2022-11-28 09:16:38 +0100
commit4ae75259233a45583b6a0d73f1f7224cb50e0398 (patch)
tree6d02ed3dc01545ae4993e6e383b8891513926f16 /tests/basic
parentbaf573a144eaa2989e57ddebaa47629724a0f4bd (diff)
Bug17281 - Retain momentary layers until the end of tapping (#17282)
* Make process_tapping more readable Move most #ifdefs into conditionally defined macros to make the logic easier to follow. * Retain momentary layers until the end of tapping This allows mod-tap and layer-tap keys on layers to behave as expected. Bug: https://github.com/qmk/qmk_firmware/issues/17281 * Add tests for delayed mod/layer release while tapping Mods and layer key release is delayed while tapping is in progress to ensure that the tap is registered with the modifier state and on the layer where the key was first pressed. Signed-off-by: Felix Kuehling <felix.kuehling@gmail.com>
Diffstat (limited to 'tests/basic')
-rw-r--r--tests/basic/test_tapping.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/basic/test_tapping.cpp b/tests/basic/test_tapping.cpp
index 6ff9cfe22b..faf9b9fe91 100644
--- a/tests/basic/test_tapping.cpp
+++ b/tests/basic/test_tapping.cpp
@@ -121,3 +121,72 @@ TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) {
121 key_shift_hold_p_tap.release(); 121 key_shift_hold_p_tap.release();
122 run_one_scan_loop(); 122 run_one_scan_loop();
123} 123}
124
125TEST_F(Tapping, TapA_CTL_T_KeyWhileReleasingShift) {
126 TestDriver driver;
127 InSequence s;
128 auto shift_key = KeymapKey(0, 7, 0, KC_LSFT);
129 auto mod_tap_hold_key = KeymapKey(0, 8, 0, CTL_T(KC_P));
130
131 set_keymap({shift_key, mod_tap_hold_key});
132
133 shift_key.press();
134 // Shift is reported
135 EXPECT_REPORT(driver, (KC_LSFT));
136 run_one_scan_loop();
137 testing::Mock::VerifyAndClearExpectations(&driver);
138
139 mod_tap_hold_key.press();
140 // Tapping keys does nothing on press
141 EXPECT_NO_REPORT(driver);
142 run_one_scan_loop();
143
144 shift_key.release();
145 // Releasing shift is delayed while tapping is in progress
146 EXPECT_NO_REPORT(driver);
147 run_one_scan_loop();
148 testing::Mock::VerifyAndClearExpectations(&driver);
149
150 mod_tap_hold_key.release();
151 // Releasing mod-tap key reports the tap and releases shift
152 EXPECT_REPORT(driver, (KC_LSFT, KC_P));
153 EXPECT_REPORT(driver, (KC_P));
154 EXPECT_EMPTY_REPORT(driver);
155 run_one_scan_loop();
156 testing::Mock::VerifyAndClearExpectations(&driver);
157}
158
159TEST_F(Tapping, TapA_CTL_T_KeyWhileReleasingLayer) {
160 TestDriver driver;
161 InSequence s;
162 auto layer_key = KeymapKey(0, 7, 0, MO(1));
163 auto trans_key = KeymapKey(1, 7, 0, KC_TRNS);
164 auto mod_tap_hold_key0 = KeymapKey(0, 8, 0, CTL_T(KC_P));
165 auto mod_tap_hold_key1 = KeymapKey(1, 8, 0, CTL_T(KC_Q));
166
167 set_keymap({layer_key, trans_key, mod_tap_hold_key0, mod_tap_hold_key1});
168
169 layer_key.press();
170 // Pressing the layer key does nothing
171 EXPECT_NO_REPORT(driver);
172 run_one_scan_loop();
173
174 mod_tap_hold_key1.press();
175 // Tapping layer 1 mod-tap key does nothing on press
176 EXPECT_NO_REPORT(driver);
177 run_one_scan_loop();
178
179 layer_key.release();
180 // Releasing layer is delayed while tapping is in progress
181 EXPECT_NO_REPORT(driver);
182 run_one_scan_loop();
183 testing::Mock::VerifyAndClearExpectations(&driver);
184
185 mod_tap_hold_key1.release();
186 // Releasing mod-tap key reports the tap of the layer 1 key
187 // If delayed layer release is broken, this reports the layer 0 key
188 EXPECT_REPORT(driver, (KC_Q));
189 EXPECT_EMPTY_REPORT(driver);
190 run_one_scan_loop();
191 testing::Mock::VerifyAndClearExpectations(&driver);
192}