-
-
Notifications
You must be signed in to change notification settings - Fork 40.2k
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
Control how interrupting the tapping function works without using "TAPPING_FORCE_HOLD" #18770
Comments
If I understand you correctly, the behavior you want for
Achieving this behavior with just the core tapping code does not seem to be possible:
Possible options that I could think of: a) If you are OK with always enabling the bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case LT(_MOVE, KC_BSPC):
if (!record->tap.count && record->tap.interrupted) {
if (record->event.pressed) {
layer_on(_MOVE);
} else {
layer_off(_MOVE);
}
} else {
if (record->event.pressed) {
register_code(KC_BSPC);
} else {
unregister_code(KC_BSPC);
}
}
return false;
}
return true;
} But the problem here is that any hold of that key will now be interpreted as a (delayed) hold of b) If you don't like the hold behavior change from a), you may try to fix that using this (complicated and untested) code: bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case LT(_MOVE, KC_BSPC):
if (record->event.pressed) {
static uint32_t last_press_timestamp;
uint16_t event_delay = timer_read() - (uint16_t)(record->event.time & ~1U);
uint32_t event_timestamp = timer_read32() - event_delay;
bool within_tapping_term = TIMER_DIFF_32(event_timestamp, last_press_timestamp) < TAPPING_TERM;
last_press_timestamp = event_timestamp;
if (!record->tap.count && !within_tapping_term) {
// first hold - force layer switch
record->tap.interrupted = true;
}
}
if (!record->tap.count && record->tap.interrupted) {
// First hold, or an interrupted hold after a tap
if (record->event.pressed) {
layer_on(_MOVE);
} else {
layer_off(_MOVE);
}
} else {
// Tap, or a non-interrupted hold after a tap
if (record->event.pressed) {
register_code(KC_BSPC);
} else {
unregister_code(KC_BSPC);
}
}
return false;
}
return true;
} This will still effectively force c) You may try replacing |
Thanks for the suggestions they work great. The behavior is exactly what I was looking for. Forcing bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case LT(_MOVE, KC_BSPC):
if (record->event.pressed) {
static uint32_t last_press_timestamp;
uint16_t event_delay = timer_read() - (uint16_t)(record->event.time & ~1U);
uint32_t event_timestamp = timer_read32() - event_delay;
bool within_tapping_term = TIMER_DIFF_32(event_timestamp, last_press_timestamp) < TAPPING_TERM;
last_press_timestamp = event_timestamp;
if (!record->tap.count && !within_tapping_term) {
// first hold - force layer switch
record->tap.interrupted = true;
}
}
if (!record->tap.count && record->tap.interrupted) {
// First hold, or an interrupted hold after a tap
if (record->event.pressed) {
layer_on(_MOVE);
return false; // To avoid calling layer_off.
}
} else {
// Tap, or a non-interrupted hold after a tap
if (record->event.pressed) {
register_code(KC_BSPC);
} else {
unregister_code(KC_BSPC);
}
}
layer_off(_MOVE);
return false;
}
return true;
}
bool get_tapping_force_hold(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case LT(_MOVE, KC_BSPC):
return true;
}
return false;
} |
Issue Description
Hi,
I have the following situation: key "LT(_MOVE, KC_BSPC)" the layer "_MOVE" has on the same key as "KC_I" the key "KC_UP".
When I do the sequence:
-> tap key.
-> press key and hold (here the tapping function starts)
-> interrupt with "KC_I" (the result is "KC_I", as if I was not holding the key "LT(_MOVE, KC_BSPC)". The hold function is never active it's like I never pressed it, I have to let go and press again.)
Basically when the keyboard enters the repeating function if I interrupt, I would expect the hold function to kick in because I'm holding the key down so I should get the key in the "_MOVE" layer. But instead I get the normal layer like I'm not pressing the "LT(_MOVE, KC_BSPC)" key.
This is solvable with "TAPPING_FORCE_HOLD" but I lose the tapping function which I don't want to.
Is there a way to achieve this and control how interrupting the tapping function works.
Thanks
The text was updated successfully, but these errors were encountered: