From fef1ce31186e483c3b91ea6fbd8c333c550505c1 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Thu, 18 Jul 2024 22:50:57 +0200 Subject: [PATCH] Revert "feat: remove need for plain layer for cz_accent by disabling tap-hold keys" This reverts commit 85fa65bc0303b5ddc28877ccb6b95cedf957bc6d. --- .../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, 27 insertions(+), 33 deletions(-) diff --git a/keyboards/splitkb/kyria/keymaps/rutherther/keymap.c b/keyboards/splitkb/kyria/keymaps/rutherther/keymap.c index 25f2d5079f..875fbc084f 100644 --- a/keyboards/splitkb/kyria/keymaps/rutherther/keymap.c +++ b/keyboards/splitkb/kyria/keymaps/rutherther/keymap.c @@ -4,6 +4,7 @@ enum layers { _QWERTY = 0, + _PLAIN, _GAMES, _SYM, _NAV, @@ -64,6 +65,13 @@ 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, @@ -130,8 +138,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)) { return false; } - if (!process_czech_caret(keycode, record, CZ_CARETED)) { return false; } + if (!process_czech_acute(keycode, record, CZ_ACUTED, _PLAIN)) { return false; } + if (!process_czech_caret(keycode, record, CZ_CARETED, _PLAIN)) { 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 6b0d148fb4..06de83f68b 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)) { return false; } - if (!process_czech_caret(keycode, record, CZ_CARETED)) { return false; } + 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_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 82f79a0a3d..f10c54c4aa 100644 --- a/users/rutherther/features/cz_accent.c +++ b/users/rutherther/features/cz_accent.c @@ -13,23 +13,22 @@ const uint8_t NUM_CARET_KEYCODES = sizeof(cz_caret_keycodes) / sizeof(uint16_t); const uint16_t cz_scln_char = KC_U; -bool process_prefixed_accent(uint16_t keycode, keyrecord_t* record, const uint16_t accent_prefix, const uint16_t *filters, const uint8_t filters_size) { +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 if (!record->event.pressed) { - return true; + return; } - uint16_t bkeycode = QK_MODS_GET_BASIC_KEYCODE(keycode); - bool found = false; for (int i = 0; i < filters_size; i++) { - if (bkeycode == filters[i]) { + if (QK_MODS_GET_BASIC_KEYCODE(keycode) == filters[i]) { found = true; break; } } if (!found) { - return true; + return; } const uint8_t mods = get_mods() | get_weak_mods() | get_oneshot_mods(); @@ -39,11 +38,8 @@ bool 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; + set_mods(mods); } bool process_czech_acute(uint16_t keycode, keyrecord_t* record, @@ -59,16 +55,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) { - return process_prefixed_accent(keycode, record, QK_CZ_ACUTE, cz_acute_keycodes, NUM_ACUTE_KEYCODES); + process_prefixed_accent(keycode, record, QK_CZ_ACUTE, cz_acute_keycodes, NUM_ACUTE_KEYCODES); } return true; @@ -82,28 +78,18 @@ 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) - return process_prefixed_accent( - keycode, - record, - QK_CZ_SCLN, - cz_caret_keycodes, - NUM_CARET_KEYCODES); + process_prefixed_accent(keycode, record, QK_CZ_SCLN, cz_caret_keycodes, NUM_CARET_KEYCODES); else - return process_prefixed_accent( - keycode, - record, - QK_CZ_CARET, - cz_caret_keycodes, - NUM_CARET_KEYCODES); + 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 68a1088618..0b558d8d41 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); + uint16_t acute_keycode, int8_t plain_layer); bool process_czech_caret(uint16_t keycode, keyrecord_t* record, - uint16_t caret_keycode); + uint16_t caret_keycode, int8_t plain_layer); -- 2.48.1