From 85fa65bc0303b5ddc28877ccb6b95cedf957bc6d Mon Sep 17 00:00:00 2001 From: Rutherther Date: Tue, 16 Jul 2024 19:19:46 +0200 Subject: [PATCH] feat: remove need for plain layer for cz_accent by disabling tap-hold keys --- .../splitkb/kyria/keymaps/rutherther/keymap.c | 12 +----- .../moonlander/keymaps/rutherther/keymap.c | 4 +- users/rutherther/features/cz_accent.c | 40 +++++++++++++------ users/rutherther/features/cz_accent.h | 4 +- 4 files changed, 33 insertions(+), 27 deletions(-) diff --git a/keyboards/splitkb/kyria/keymaps/rutherther/keymap.c b/keyboards/splitkb/kyria/keymaps/rutherther/keymap.c index 875fbc084f..25f2d5079f 100644 --- a/keyboards/splitkb/kyria/keymaps/rutherther/keymap.c +++ b/keyboards/splitkb/kyria/keymaps/rutherther/keymap.c @@ -4,7 +4,6 @@ enum layers { _QWERTY = 0, - _PLAIN, _GAMES, _SYM, _NAV, @@ -65,13 +64,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { QK_LOCK, CZ_ACUTED, QK_REP, ALT_SPC, CZ_ACUTED, CZ_CARETED,ALT_ENT, KC_BSPC, CZ_CARETED, KC_APP ), - [_PLAIN] = LAYOUT( - KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS, - KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, - OSM_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, _______, CTRL, FKEYS, _______, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, OSM_RSFT, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ - ), - [_GAMES] = LAYOUT( KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS, KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, @@ -138,8 +130,8 @@ void keyboard_pre_init_user(void) { } bool process_record_user(uint16_t keycode, keyrecord_t *record) { - if (!process_czech_acute(keycode, record, CZ_ACUTED, _PLAIN)) { return false; } - if (!process_czech_caret(keycode, record, CZ_CARETED, _PLAIN)) { return false; } + if (!process_czech_acute(keycode, record, CZ_ACUTED)) { return false; } + if (!process_czech_caret(keycode, record, CZ_CARETED)) { return false; } if (!process_layer_lock(keycode, record, QK_LLCK)) { return false; } /* switch (keycode) { diff --git a/keyboards/zsa/moonlander/keymaps/rutherther/keymap.c b/keyboards/zsa/moonlander/keymaps/rutherther/keymap.c index 06de83f68b..6b0d148fb4 100644 --- a/keyboards/zsa/moonlander/keymaps/rutherther/keymap.c +++ b/keyboards/zsa/moonlander/keymaps/rutherther/keymap.c @@ -176,8 +176,8 @@ bool rgb_matrix_indicators_user(void) { bool process_record_user(uint16_t keycode, keyrecord_t *record) { - if (!process_czech_acute(keycode, record, CZ_ACUTED, PLAIN_LAYER)) { return false; } - if (!process_czech_caret(keycode, record, CZ_CARETED, PLAIN_LAYER)) { return false; } + if (!process_czech_acute(keycode, record, CZ_ACUTED)) { return false; } + if (!process_czech_caret(keycode, record, CZ_CARETED)) { return false; } if (!process_layer_lock(keycode, record, QK_LLCK)) { return false; } switch (keycode) { diff --git a/users/rutherther/features/cz_accent.c b/users/rutherther/features/cz_accent.c index f10c54c4aa..82f79a0a3d 100644 --- a/users/rutherther/features/cz_accent.c +++ b/users/rutherther/features/cz_accent.c @@ -13,22 +13,23 @@ const uint8_t NUM_CARET_KEYCODES = sizeof(cz_caret_keycodes) / sizeof(uint16_t); const uint16_t cz_scln_char = KC_U; -void process_prefixed_accent(uint16_t keycode, keyrecord_t* record, const uint16_t accent_prefix, const uint16_t *filters, const uint8_t filters_size) { - // TODO wait for the actual key, this can trigger hold condition, I think +bool process_prefixed_accent(uint16_t keycode, keyrecord_t* record, const uint16_t accent_prefix, const uint16_t *filters, const uint8_t filters_size) { if (!record->event.pressed) { - return; + return true; } + uint16_t bkeycode = QK_MODS_GET_BASIC_KEYCODE(keycode); + bool found = false; for (int i = 0; i < filters_size; i++) { - if (QK_MODS_GET_BASIC_KEYCODE(keycode) == filters[i]) { + if (bkeycode == filters[i]) { found = true; break; } } if (!found) { - return; + return true; } const uint8_t mods = get_mods() | get_weak_mods() | get_oneshot_mods(); @@ -38,8 +39,11 @@ void process_prefixed_accent(uint16_t keycode, keyrecord_t* record, const uint16 clear_oneshot_mods(); tap_code16(accent_prefix); - set_mods(mods); + + tap_code16(bkeycode); + + return false; } bool process_czech_acute(uint16_t keycode, keyrecord_t* record, @@ -55,16 +59,16 @@ bool process_czech_acute(uint16_t keycode, keyrecord_t* record, // least I think. Maybe different function will have to be overriden // somehow. if (record->event.pressed) { - layer_move(plain_layer); + /* layer_move(plain_layer); */ } else { - layer_move(0); + /* layer_move(0); */ } return false; } if (cz_send_acuted) { - process_prefixed_accent(keycode, record, QK_CZ_ACUTE, cz_acute_keycodes, NUM_ACUTE_KEYCODES); + return process_prefixed_accent(keycode, record, QK_CZ_ACUTE, cz_acute_keycodes, NUM_ACUTE_KEYCODES); } return true; @@ -78,18 +82,28 @@ bool process_czech_caret(uint16_t keycode, keyrecord_t* record, cz_send_careted = record->event.pressed; if (record->event.pressed) { - layer_move(plain_layer); + /* layer_move(plain_layer); */ } else { - layer_move(0); + /* layer_move(0); */ } return false; } if (cz_send_careted) { if (QK_MODS_GET_BASIC_KEYCODE(keycode) == cz_scln_char) - process_prefixed_accent(keycode, record, QK_CZ_SCLN, cz_caret_keycodes, NUM_CARET_KEYCODES); + return process_prefixed_accent( + keycode, + record, + QK_CZ_SCLN, + cz_caret_keycodes, + NUM_CARET_KEYCODES); else - process_prefixed_accent(keycode, record, QK_CZ_CARET, cz_caret_keycodes, NUM_CARET_KEYCODES); + return process_prefixed_accent( + keycode, + record, + QK_CZ_CARET, + cz_caret_keycodes, + NUM_CARET_KEYCODES); } return true; diff --git a/users/rutherther/features/cz_accent.h b/users/rutherther/features/cz_accent.h index 0b558d8d41..68a1088618 100644 --- a/users/rutherther/features/cz_accent.h +++ b/users/rutherther/features/cz_accent.h @@ -17,7 +17,7 @@ #define QK_CZ_SCLN LSFT(RALT(CZ_SCLN)) bool process_czech_acute(uint16_t keycode, keyrecord_t* record, - uint16_t acute_keycode, int8_t plain_layer); + uint16_t acute_keycode); bool process_czech_caret(uint16_t keycode, keyrecord_t* record, - uint16_t caret_keycode, int8_t plain_layer); + uint16_t caret_keycode); -- 2.48.1