I've extended your code example to easily apply to all combinations of same hand home row mods cancellation.
This applies to my layout but it can be used in any layout following the modifications already present in the post.
I'm not going to post it, so you I though you might be interested in sharing this.
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
// #define MT(mod, kc) (QK_MOD_TAP | (((mod)&0x1F) << 8) | ((kc)&0xFF))
uint16_t mods;
switch (keycode) {
case LCTL_T(KC_R):
case LALT_T(KC_S):
case LGUI_T(KC_I):
case LSFT_T(KC_T):
/*
Detect the tap.
We're only interested in overriding the tap behaviour
in a certain cicumstance. The hold behaviour can stay the same.
*/
if (record->event.pressed && record->tap.count > 0) {
mods = get_mods() & (MOD_BIT(KC_LSFT) | MOD_BIT(KC_LGUI) | MOD_BIT(KC_LALT) | MOD_BIT(KC_LCTL));
if (mods) {
// temporarily disable modifier so we can send the tapped key
unregister_mods(mods);
if (mods & MOD_BIT(KC_LSFT)) {
tap_code(KC_T);
}
if (mods & MOD_BIT(KC_LGUI)) {
tap_code(KC_I);
}
if (mods & MOD_BIT(KC_LALT)) {
tap_code(KC_S);
}
if (mods & MOD_BIT(KC_LCTL)) {
tap_code(KC_R);
}
tap_code(keycode & 0xFF);
add_mods(mods);
return false;
}
}
return true;
case RCTL_T(KC_L):
case RALT_T(KC_A):
case RGUI_T(KC_E):
case RSFT_T(KC_N):
/*
Detect the tap.
We're only interested in overriding the tap behaviour
in a certain cicumstance. The hold behaviour can stay the same.
*/
if (record->event.pressed && record->tap.count > 0) {
mods = get_mods() & (MOD_BIT(KC_RSFT) | MOD_BIT(KC_RGUI) | MOD_BIT(KC_RALT) | MOD_BIT(KC_RCTL));
if (mods) {
// temporarily disable modifier so we can send the tapped key
unregister_mods(mods);
if (mods & MOD_BIT(KC_RSFT)) {
tap_code(KC_N);
}
if (mods & MOD_BIT(KC_RGUI)) {
tap_code(KC_E);
}
if (mods & MOD_BIT(KC_RALT)) {
tap_code(KC_A);
}
if (mods & MOD_BIT(KC_RCTL)) {
tap_code(KC_L);
}
tap_code(keycode & 0xFF);
add_mods(mods);
return false;
}
}
return true;
}
return true;
}
I've extended your code example to easily apply to all combinations of same hand home row mods cancellation. This applies to my layout but it can be used in any layout following the modifications already present in the post. I'm not going to post it, so you I though you might be interested in sharing this.
Cheers