diff --git a/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/clever_keys.c b/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/clever_keys.c index bdb93565..f6e683d7 100644 --- a/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/clever_keys.c +++ b/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/clever_keys.c @@ -22,25 +22,11 @@ void get_clever_keycode(uint16_t* next_keycode, keyrecord_t* record) { uint16_t prev_keycode = recent[RECENT_SIZE - 1]; - //static bool is_shifted = false; // Apostrophe if (is_followed_by_apos(*next_keycode, prev_keycode)) { set_last_keycode(PG_APOS); - //apostrophe = true; } - - //if (is_caps_lock_on()) { -/* if (is_letter(*next_keycode) || is_send_string_macro(*next_keycode)) { - if (recent[RECENT_SIZE - 3] == PG_E && recent[RECENT_SIZE - 2] == PG_T && prev_keycode == KC_SPC) { - caps_word_on(); - } - if (recent[RECENT_SIZE - 2] == PG_VIRG && prev_keycode == KC_SPC && is_letter(*next_keycode)) { - caps_word_on(); - } - } */ - //} - switch (prev_keycode) { @@ -48,7 +34,9 @@ void get_clever_keycode(uint16_t* next_keycode, keyrecord_t* record) { switch (*next_keycode) { // Shift auto de la ponctuation après une espace fine insécable case PG_POIN: - process_word((uint16_t[]) {KC_BSPC, SAGR(KC_SPC)}, 2, record); + // uses less space than process_word + tap_code(KC_BSPC); + process_key(SAGR(KC_SPC), record); case PG_TIRE: case PG_VIRG: return replace_ongoing_key(S(*next_keycode), next_keycode, record); @@ -64,7 +52,7 @@ void get_clever_keycode(uint16_t* next_keycode, keyrecord_t* record) { // Shift the letter at the beginning of sentences. if (is_letter(*next_keycode) || is_send_string_macro(*next_keycode)) { //if (!is_caps_lock_on()) { add_weak_mods(MOD_BIT(KC_LSFT)); } - add_weak_mods(MOD_BIT(KC_LSFT)); + set_oneshot_mods(MOD_BIT(KC_LSFT)); // Don't use weak mods ! } break; } @@ -119,15 +107,11 @@ void get_clever_keycode(uint16_t* next_keycode, keyrecord_t* record) { switch (prev_keycode) { case PG_O: // oui - invoke_key(PG_U, record); + process_key(PG_U, record); case PG_U: // ui SFB return replace_ongoing_key(PG_I, next_keycode, record); -/* case PG_L: - // là - return finish_word((uint16_t[]) {PG_ODK, PG_A}, 2, next_keycode, record); */ - case PG_EACU: // éa SFB return replace_ongoing_key(PG_A, next_keycode, record); @@ -154,19 +138,27 @@ void get_clever_keycode(uint16_t* next_keycode, keyrecord_t* record) { case PG_Q: // qué scissor - return finish_word((uint16_t[]) {PG_U, PG_EACU}, 2, next_keycode, record); + //return finish_word((uint16_t[]) {PG_U, PG_EACU}, 2, next_keycode, record); + process_key(PG_U,record); + return replace_ongoing_key(PG_EACU, next_keycode, record); case PG_Y: // you bad redirection - return finish_word((uint16_t[]) {PG_O, PG_U}, 2, next_keycode, record); + //return finish_word((uint16_t[]) {PG_O, PG_U}, 2, next_keycode, record); + process_key(PG_O,record); + return replace_ongoing_key(PG_U, next_keycode, record); case PG_T: // "the" - return finish_word((uint16_t[]) {PG_H, PG_E}, 2, next_keycode, record); - + //return finish_word((uint16_t[]) {PG_H, PG_E}, 2, next_keycode, record); + process_key(PG_H,record); + return replace_ongoing_key(PG_E, next_keycode, record); + case PG_I: - return finish_word((uint16_t[]) {PG_O, PG_N}, 2, next_keycode, record); - + //return finish_word((uint16_t[]) {PG_O, PG_N}, 2, next_keycode, record); + process_key(PG_O,record); + return replace_ongoing_key(PG_N, next_keycode, record); + case PG_M: if (is_letter(recent[RECENT_SIZE - 2])) { // "ment" @@ -186,12 +178,7 @@ void get_clever_keycode(uint16_t* next_keycode, keyrecord_t* record) { default: // "à" - process_key(PG_ODK,record); - - if (is_shifted) { - is_shifted = false; - add_weak_mods(MOD_BIT(KC_LSFT)); - } + process_key(PG_ODK, record); return replace_ongoing_key(PG_A, next_keycode, record); } @@ -231,26 +218,10 @@ void get_clever_keycode(uint16_t* next_keycode, keyrecord_t* record) { } break; -/* case PG_R: - if (prev_keycode == PG_L) { - // "lr" -> "l" + 1DK - //bkspc_countdown = 0; - return replace_ongoing_key(OS_ODK, next_keycode, record); - } - break; */ - case OU_GRV: layer_off(_ODK); return finish_word((uint16_t[]) {PG_O, PG_ODK, PG_N}, 3, next_keycode, record); -/* case PG_BL: - layer_off(_ODK); - return finish_word((uint16_t[]) {PG_B, PG_L}, 2, next_keycode, record); */ - -/* case J_APOS: - layer_off(_ODK); - return finish_word((uint16_t[]) {PG_J, PG_APOS}, 2, next_keycode, record); */ - case PG_APOS: if (is_apos_dr) { return replace_ongoing_key(PG_APOD, next_keycode, record); } break; diff --git a/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/features/clever_keys_utilities.c b/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/features/clever_keys_utilities.c index 57f2cd98..e3e572f5 100644 --- a/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/features/clever_keys_utilities.c +++ b/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/features/clever_keys_utilities.c @@ -42,7 +42,7 @@ uint16_t get_ongoing_keycode(uint16_t keycode, keyrecord_t* record) { //if (mods & ~(MOD_MASK_SHIFT | MOD_BIT(KC_ALGR))) { if (mods & ~MOD_MASK_SHIFT) { - clear_recent_keys(); // Avoid interfering with ctrl, left alt, alt-gr and gui. + clear_recent_keys(); // Avoid interfering with ctrl, alt, alt-gr and gui. return KC_NO; } @@ -76,22 +76,6 @@ uint16_t get_ongoing_keycode(uint16_t keycode, keyrecord_t* record) { uint16_t custom_keycode = get_ongoing_keycode_user(keycode); if (custom_keycode != KC_TRNS) { return custom_keycode; } -/* if (is_send_string_macro(keycode)) { return keycode; } - - if (IS_LAYER_ON(_ODK)) { - switch (keycode) { - case PG_K: - case PG_B: - case PG_AROB: - case PG_3PTS: - case KC_SPC: // In order to uppercase J after '?' for ex. - return keycode; - - default: - clear_recent_keys(); - return KC_NO; - } - } */ uint8_t basic_keycode = keycode; // Handle keys carrying a modifier, for ex on layers(! and ?). @@ -149,7 +133,6 @@ void process_key(uint16_t keycode, keyrecord_t* record) { void invoke_key(uint16_t keycode, keyrecord_t* record) { process_key(keycode, record); // tap_code doesn't work with caps word. - //record->keycode = keycode; bkspc_countdown = 1; } @@ -164,10 +147,15 @@ void process_word(uint16_t keycodes[], uint8_t num_keycodes, keyrecord_t* record for (int i = 0; i < num_keycodes; ++i) { process_key(keycodes[i], record); // tap_code doesn't work with caps word. } - bkspc_countdown = num_keycodes; } void finish_word(uint16_t keycodes[], uint8_t num_keycodes, uint16_t* ongoing_keycode, keyrecord_t* record) { + process_word(keycodes, num_keycodes - 1, record); + bkspc_countdown = num_keycodes - 1; + replace_ongoing_key(keycodes[num_keycodes - 1], ongoing_keycode, record); +} + +void finish_magic(uint16_t keycodes[], uint8_t num_keycodes, uint16_t* ongoing_keycode, keyrecord_t* record) { process_word(keycodes, num_keycodes - 1, record); replace_ongoing_key(keycodes[num_keycodes - 1], ongoing_keycode, record); } diff --git a/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/features/clever_keys_utilities.h b/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/features/clever_keys_utilities.h index 76bdb1b5..e003b184 100644 --- a/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/features/clever_keys_utilities.h +++ b/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/features/clever_keys_utilities.h @@ -40,6 +40,7 @@ void invoke_key(uint16_t keycode, keyrecord_t* record); void replace_ongoing_key(uint16_t clever_keycode, uint16_t* ongoing_keycode, keyrecord_t* record); void process_word(uint16_t keycodes[], uint8_t num_keycodes, keyrecord_t* record); void finish_word(uint16_t keycodes[], uint8_t num_keycodes, uint16_t* ongoing_keycode, keyrecord_t* record); +void finish_magic(uint16_t keycodes[], uint8_t num_keycodes, uint16_t* ongoing_keycode, keyrecord_t* record); bool process_clever_keys(uint16_t keycode, keyrecord_t* record); void end_CK(keyrecord_t* record); diff --git a/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/features/macros.c b/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/features/macros.c index f5060ae1..73f12bae 100644 --- a/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/features/macros.c +++ b/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/features/macros.c @@ -19,8 +19,6 @@ bool is_apos_dr = false; bool process_macros(uint16_t keycode, keyrecord_t *record) { - //const uint8_t mods = get_mods(); - //static bool is_shifted = false; if (record->event.pressed) { // Handling of other macros (on press). switch (keycode) { @@ -52,7 +50,7 @@ bool process_macros(uint16_t keycode, keyrecord_t *record) { layer_clear(); clear_oneshot_mods(); - clear_weak_mods(); + //clear_weak_mods(); caps_word_off(); disable_num_word(); clear_recent_keys(); @@ -74,18 +72,7 @@ bool process_macros(uint16_t keycode, keyrecord_t *record) { return false; case NUM_ODK: - bool is_shifted = (get_mods() | get_weak_mods() | get_oneshot_mods()) & MOD_MASK_SHIFT; - if (is_shifted) { - del_weak_mods(MOD_MASK_SHIFT); - del_oneshot_mods(MOD_MASK_SHIFT); - unregister_mods(MOD_MASK_SHIFT); - } tap_code(PG_ODK); - - if (is_shifted) { - is_shifted = false; - set_oneshot_mods(MOD_BIT(KC_LSFT)); - } return true; case PG_DEG: diff --git a/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/features/odk_layer.c b/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/features/odk_layer.c index 4ded06f6..914d7fe7 100644 --- a/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/features/odk_layer.c +++ b/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/features/odk_layer.c @@ -16,15 +16,13 @@ #include "odk_layer.h" -bool is_shifted = false; - bool process_odk_layer(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { // On press const uint8_t mods = get_mods() | get_weak_mods() | get_oneshot_mods(); + bool invoke_odk = false; //const uint8_t mods = get_mods() | get_oneshot_mods(); - //static bool is_shifted = false; if (keycode == OS_ODK) { // Custom behaviour when alt-gr @@ -32,48 +30,50 @@ bool process_odk_layer(uint16_t keycode, keyrecord_t *record) { tap_code16(ALGR(PG_ODK)); return false; } + return true; } else if (keycode == PG_ODK) { + invoke_odk = true; + + } else if (IS_LAYER_ON(_ODK)) { + switch (keycode) { + case PG_PVIR: + case PG_AROB: + case PG_K: + case PG_B: + case PG_APOS: + case OU_GRV: + case KC_SPC: // When space is added by Clever Keys + case CNL_ODK: + case PG_ODK: + return true; + + default: + invoke_odk = true; + } + } + + if (invoke_odk) { // Special behaviour of PG_ODK when shifted // Shift must apply to the next keycode - is_shifted = mods & MOD_MASK_SHIFT; - if (is_shifted) { + //invoke_odk = false; + bool is_shifted = false; + + if (mods & MOD_MASK_SHIFT) { del_weak_mods(MOD_MASK_SHIFT); del_oneshot_mods(MOD_MASK_SHIFT); unregister_mods(MOD_MASK_SHIFT); + is_shifted = true; } - } else { - if (IS_LAYER_ON(_ODK)) { - switch (keycode) { - //case PG_3PTS: // For Clever Keys - case PG_PVIR: - case PG_AROB: - case PG_K: - case PG_B: - case PG_APOS: - case OU_GRV: - case KC_SPC: // When space is added by Clever Keys - case CNL_ODK: - break; - - default: - tap_code(PG_ODK); - } - } + tap_code(PG_ODK); + if (is_shifted) { - is_shifted = false; - //set_mods(mods); - add_weak_mods(MOD_BIT(KC_LSFT)); + set_oneshot_mods(MOD_BIT(KC_LSFT)); // Don't use weak mods ! + //is_shifted = false; } + if (keycode == PG_ODK) { return false; } } } return true; -} - -/* void odk_layer_exit_check(uint16_t keycode) { - if (keycode == odk_keycode) { - layer_off(_ODK); - odk_keycode = KC_NO; - } -} */ \ No newline at end of file +} \ No newline at end of file diff --git a/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/features/odk_layer.h b/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/features/odk_layer.h index 66775f2f..dad5bf25 100644 --- a/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/features/odk_layer.h +++ b/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/features/odk_layer.h @@ -24,10 +24,7 @@ extern "C" { #endif -extern bool is_shifted; - bool process_odk_layer(uint16_t keycode, keyrecord_t *record); -//void odk_layer_exit_check(uint16_t keycode); #ifdef __cplusplus } diff --git a/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/features/os4a.c b/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/features/os4a.c index 33948a18..671ca35a 100644 --- a/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/features/os4a.c +++ b/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/features/os4a.c @@ -66,7 +66,7 @@ bool process_os4a_layers(uint16_t keycode, keyrecord_t *record) { // Add OS Shift when no other mods are active. // Testing exit_os4a_layer is necessary to prevent OS shift to be added when other features create keyrecords // to be processed (ex: custom altgr, clever keys). - uint8_t mods = get_mods() | get_oneshot_mods(); + const uint8_t mods = get_mods() | get_oneshot_mods(); if (!exit_os4a_layer && to_be_shifted(keycode, record) && mods == 0) { // Don't use weak mods, it interferes with Capsword. set_oneshot_mods(MOD_BIT(KC_LSFT)); @@ -99,12 +99,12 @@ bool process_mods(uint16_t keycode, keyrecord_t *record) { if (IS_OS4A_KEY(keycode)) { return process_os4a_keys(keycode, record); } // Behaviour of the OS4A layers - if (os4a_layer != 0) { exit_os4a_layer = process_os4a_layers(keycode, record); } + if (record->event.pressed) { + if (os4a_layer != 0) { exit_os4a_layer = process_os4a_layers(keycode, record); } - // When Ctrl or Shift are released, for mouse use. - //if (mods_for_mouse(keycode)) { mouse_mods_key_up(keycode, record); } - - if (!record->event.pressed) { + } else { + // When Ctrl or Shift are released, for mouse use. + //if (mods_for_mouse(keycode)) { mouse_mods_key_up(keycode, record); } if (os4a_layer != 0 && exit_os4a_layer) { os4a_layer_off(os4a_layer); } } return true; diff --git a/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/features_conf.c b/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/features_conf.c index 21f43ab3..e8f6b9f1 100644 --- a/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/features_conf.c +++ b/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/features_conf.c @@ -205,7 +205,6 @@ uint8_t get_os4a_layer(uint16_t keycode) { bool os4a_layer_changer(uint16_t keycode) { switch (keycode) { case OS_FA: - //case OS_WMNT: case NUMWORD: case TG_FA: case OS_RSA: @@ -246,16 +245,20 @@ bool is_oneshot_cancel_key(uint16_t keycode) { } bool is_oneshot_ignored_key(uint16_t keycode) { - // On veut que la touche typo soit ignorée par tous les Callum mods sauf Alt-gr. - // Ça permet de transmettre les mods à la touche suivante, par ex pour faire Ctrl + K. - // Alt-gr et shift s'appliquent à la touche typo, pour permettre de faire les majuscules plus facilement ainsi que ] avec. - uint8_t mods = get_mods() | get_weak_mods() | get_oneshot_mods(); - //if (keycode == OS_ODK && (mods & ~(MOD_MASK_SHIFT | MOD_BIT(KC_ALGR)))) { return true; } - if (keycode == OS_ODK && (mods & ~MOD_BIT(KC_ALGR))) { return true; } + const uint8_t mods = get_mods() | get_weak_mods() | get_oneshot_mods(); + //if (keycode == OS_ODK && (mods & ~(MOD_MASK_SHIFT | MOD_BIT(KC_ALGR)))) { return true; } + //if (keycode == OS_ODK && (mods & ~MOD_BIT(KC_ALGR))) { return true; } switch (keycode) { - //case OS_ODK: /!\ A ne pas remettre, sous peine de ne pas pouvoir faire shift + typo + touche de l'autre côté + case OS_ODK: + // On veut que la touche typo soit ignorée par tous les Callum mods sauf Alt-gr. + // Ça permet de transmettre les mods à la touche suivante, par ex pour faire Ctrl + K. + // Alt-gr doit pouvoir s’appliquer à la touche typo, pour permettre de faire la touche morte "~" avec. + // OS_ODK ne doit être ignored_key que lorsqu’elle est employée avec Alt-gr + // sous peine de ne pas pouvoir faire shift + typo + touche de l'autre côté + if (mods & ~MOD_BIT(KC_ALGR)) { return true; } + break; case L_OS4A: case R_OS4A: case OS_SHFT: @@ -266,12 +269,11 @@ bool is_oneshot_ignored_key(uint16_t keycode) { case OS_FA: case NUMWORD: case TG_FA: - //case OS_WMNT: - //case NUM_ODK: // Ne sert à rien, car NUM_ODK est un vrai one-shot : les mods sont transmis même sans paramétrage. - return true; - default: - return false; + return true; +/* default: + return false; */ } + return false; } @@ -299,6 +301,5 @@ uint16_t get_alt_repeat_key_keycode_user(uint16_t keycode, uint8_t mods) { if (recent[RECENT_SIZE - 1] != KC_NO) { return MAGIC; } if (get_last_keycode() == KC_NO) { return MAGIC; } - return KC_TRNS; // Defer to default definitions. } \ No newline at end of file diff --git a/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/keymap.c b/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/keymap.c index 653a8935..1372feca 100644 --- a/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/keymap.c +++ b/keyboards/splitkb/kyria/rev1/base/keymaps/Kawamashi/keymap.c @@ -40,8 +40,8 @@ bool get_hold_on_other_key_press(uint16_t keycode, keyrecord_t *record) { if (record->event.key.col != next_record.event.key.col) { - // La ligne suivante n'est nécessaire que si on a besoin de doubler rapidement un caractère présent sur la moitié droite du clavier. - // Ce n'est pas nécessaire pour l'instant, vu que les guillemets sont passés à gauche. + // Permet de doubler rapidement un caractère présent sur la moitié droite du clavier. + // Fait également gagner pas mal de place sur le FW. if (keycode == OS_ODK) { return true; } if (forbidden_chord(keycode, record, next_keycode, &next_record)) { @@ -55,16 +55,11 @@ bool get_hold_on_other_key_press(uint16_t keycode, keyrecord_t *record) { return false; } -/* bool get_permissive_hold(uint16_t keycode, keyrecord_t *record) { - return !forbidden_chord(keycode, record, next_keycode, &next_record); -} */ - // Matrix scan void matrix_scan_user(void) { recent_keys_task(); - //swapper_task(); } @@ -228,10 +223,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * `----------------------------------' `----------------------------------' */ [_NUMBERS] = LAYOUT( - _______, PG_DLR, PG_MOIN, PG_PLUS, PG_EURO, PG_PERC, PG_EXP, _______, PG_EGAL, PG_ASTX, _______, _______, - _______, KC_4, KC_3, KC_2, MT_1, PG_2PTS, PG_IND, MT_SLSH, KC_6, KC_7, KC_8, _______, - _______, _______, _______, PG_H, KC_5, _______, _______, _______, _______, _______, _______, KC_9, PG_DEG, _______, PG_ODK, _______, - _______, _______, KC_PDOT, KC_0 , LT_NBSPC, _______, KC_SPC, _______, _______, _______ + // S(KC_4), S(KC_3) and S(PG_EGAL) are here to give easy access to ⅔, ¾ and ≠. + _______, PG_DLR, PG_MOIN, PG_PLUS, PG_EURO, PG_PERC, PG_EXP, S(PG_EGAL), PG_EGAL, PG_ASTX, _______, _______, + _______, KC_4, KC_3, KC_2, MT_1, PG_2PTS, PG_IND, MT_SLSH, KC_6, KC_7, KC_8, _______, + _______, S(KC_4), S(KC_3), PG_H, KC_5, _______, _______, _______, _______, _______, _______, KC_9, PG_DEG, _______, PG_ODK, _______, + _______, _______, KC_PDOT, KC_0 , LT_NBSPC, _______, KC_SPC, _______, _______, _______ ),