-
-
Notifications
You must be signed in to change notification settings - Fork 42.4k
Ignore space cadet key release when caps word is active #21721
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
Conversation
|
@p3l6 thank you for contributing this fix! My impression is this fix makes sense. It is delicate logic how Caps Word and Space Cadet features interoperate. To avoid regression where some future change breaks this behavior again, it would be a good idea to add a unit test to cover In case you are new to testing in QMK, here are a few notes. I suggest:
Tests written using the GoogleTest framework. Take a look at the existing tests in the same file examples of how GoogleTest is used in QMK to simulate and test key events. |
| #ifdef BOTH_SHIFTS_TURNS_ON_CAPS_WORD | ||
| if (sc_last == holdMod && timer_elapsed(sc_timer) < GET_TAPPING_TERM(sc_keycode, record) && !is_caps_word_on()) { | ||
| #else | ||
| if (sc_last == holdMod && timer_elapsed(sc_timer) < GET_TAPPING_TERM(sc_keycode, record)) { | ||
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change effectively blocks taps of all Space Cadet keys while Caps Word is active. Because Space Cadet keys are customizable and can be used also with other modifiers than just Shift, this restriction may not be desired.
An alternative way to fix the problem might be:
- Add a function to reset the Space Cadet state (the same thing happens when any other key is pressed while a Space Cadet key is held down):
void reset_space_cadet(void) {
sc_last = 0;
}- Call
reset_space_cadet()from the Caps Word code when the press of both shifts is detected.
This way only the last tap of Space Cadet Shift which activates Caps Word would be forcibly converted to a hold, and other usage of Space Cadet keys during Caps Word would remain undisturbed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this additional context and write-up, I've re-worked the change in the way you suggested.
|
@getreuer When I went to add a new test case, I noticed that the existing cases already covered this combination, but had an exception to wait for the Tapping term to expire to work around the issue. I think removing tapping term in the existing tests could be sufficient, but let me know if you think an explicitly named case would still be good. I checked that
|
|
Another feature which probably won't work together with Space Cadet is |
|
I am also not familiar enough (or at all) with |
|
Thank you for your contribution! |
Description
If using
BOTH_SHIFTS_TURNS_ON_CAPS_WORDand Space cadet, activating Caps word before the tapping term expires produces either an unwanted0or9, depending on which shift was pressed first. A deeper explanation of the cause can be found in the linked issue below.In this change, when shift if released, I check to see if caps word is enabled, and then perform the same space cadet code branch as if the tapping term had expired. That is to say, releasing the modifier without typing the parenthesis. This works because caps word is processed first, so when entering caps word mode, the flag will already be set when processing space cadet. In the case that a shift key is tapped to exit caps word, the flag will be disabled before space cadet processes, and the key will be processed normally.
Types of Changes
Issues Fixed or Closed by This PR
Checklist