Gestion de la couche typo

This commit is contained in:
Kawamashi 2025-03-25 19:37:13 +01:00
commit e3af9fcaa7
10 changed files with 167 additions and 139 deletions

View file

@ -99,11 +99,13 @@ bool clever_key_finder(uint16_t next_keycode, keyrecord_t* record) {
}
break;
}
break;
case FG_CCED:
if (!isLetter(next_keycode)) {
invoke_key(FG_A, record);
}
break;
}
@ -126,6 +128,12 @@ bool clever_key_finder(uint16_t next_keycode, keyrecord_t* record) {
}
break;
/* case KC_SPC:
if (get_last_keycode() == FG_TYPO) {
invoke_key(FG_A, record);
}
break; */
case MAGIC:
switch (prev_keycode) {
@ -209,7 +217,7 @@ bool clever_key_finder(uint16_t next_keycode, keyrecord_t* record) {
case FG_D:
// "d@" -> "déjà"
layer_off(_TYPO);
return finish_word((uint16_t[]) {FG_EACU, FG_J, FG_A}, 3, record);
return finish_word((uint16_t[]) {FG_EACU, FG_J, FG_TYPO, FG_A}, 4, record);
}
}
break;
@ -252,11 +260,19 @@ bool clever_key_finder(uint16_t next_keycode, keyrecord_t* record) {
case OU_GRV:
layer_off(_TYPO);
return finish_word((uint16_t[]) {FG_O, FG_TYPO, FG_U}, 3, record);
return finish_word((uint16_t[]) {FG_O, FG_TYPO, FG_D}, 3, record);
case AGRV_SPC:
//layer_off(_TYPO);
return finish_word((uint16_t[]) {FG_A, KC_SPC}, 2, record);
/* const 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);
}
invoke_key(FG_TYPO, record);
if (is_shifted) { set_oneshot_mods(MOD_BIT(KC_LSFT)); } */
layer_off(_TYPO);
return finish_word((uint16_t[]) {FG_AGR, KC_SPC}, 2, record);
}
return false; // Process next keycode normally

View file

@ -73,6 +73,18 @@ uint16_t get_next_keycode(uint16_t keycode, keyrecord_t* record) {
// Handles custom keycodes.
if IS_QK_USER(keycode) { return keycode; }
//if (keycode == FG_CCED) { return FG_CCED; }
if (IS_LAYER_ON(_TYPO)) {
switch (keycode) {
case FG_K:
case FG_J:
case FG_AROB:
case FG_CCED:
break;
default:
return KC_NO;
}
}
uint8_t basic_keycode = keycode;
// Handle keys carrying a modifier, for ex on layers(! and ?).

View file

@ -16,6 +16,7 @@
#include "macros.h"
bool is_typo_shifted = false;
bool process_macros(uint16_t keycode, keyrecord_t *record) {
//const uint8_t mods = get_mods();
@ -27,18 +28,25 @@ bool process_macros(uint16_t keycode, keyrecord_t *record) {
case REV_TAB:
return process_swapper(S(KC_TAB)); */
case OS_TYPO:
/* case OS_TYPO:
if ((get_mods() | get_weak_mods() | get_oneshot_mods()) & MOD_BIT(KC_ALGR)) {
tap_code16(ALGR(FG_TYPO));
return false;
}
const bool is_shifted = get_mods() & MOD_MASK_SHIFT;
if (is_shifted) {
is_typo_shifted = (get_mods() | get_weak_mods() | get_oneshot_mods()) & MOD_MASK_SHIFT;
if (is_typo_shifted) {
del_weak_mods(MOD_MASK_SHIFT);
unregister_mods(MOD_MASK_SHIFT);
set_oneshot_mods(MOD_BIT(KC_LSFT));
del_oneshot_mods(MOD_BIT(KC_LSFT));
}
return true;
return true; */
/* case FG_TYPO:
if ((get_mods() | get_weak_mods() | get_oneshot_mods()) & MOD_MASK_SHIFT) {
del_weak_mods(MOD_MASK_SHIFT);
del_oneshot_mods(MOD_MASK_SHIFT);
unregister_mods(MOD_MASK_SHIFT);
}
return true; */
case AIDE_MEM:
switch(get_highest_layer(layer_state|default_layer_state)) {

View file

@ -22,7 +22,7 @@
#ifdef __cplusplus
extern "C" {
#endif
extern bool is_typo_shifted;
bool process_macros(uint16_t keycode, keyrecord_t *record);

View file

@ -55,7 +55,8 @@ bool should_terminate_num_word(uint16_t keycode, const keyrecord_t *record) {
// Numpad keycodes
case KC_1 ... KC_0:
case KC_PDOT:
case FG_VIRG:
case FG_POIN:
//case FG_VIRG:
case FG_MOIN:
case FG_ASTX:
case FG_PLUS:
@ -65,6 +66,7 @@ bool should_terminate_num_word(uint16_t keycode, const keyrecord_t *record) {
// Misc
case KC_BSPC:
case FG_TYPO: // Not to exit Numword when chording it with Typo
case NUMWORD: // For the combo NUMWORD to work
/*

View file

@ -17,111 +17,91 @@
#include "typo_layer.h"
//bool is_typo = false;
bool exit_typo = false;
void typo_layer_off() {
layer_off(_TYPO);
exit_typo = false;
}
bool process_typo(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) { // On press
const uint8_t mods = get_mods() | get_weak_mods() | get_oneshot_mods();
static bool is_shifted = false;
if (keycode == OS_TYPO) {
// Handle the custom OSL that go with this feature
// It's timerless, to avoid problems when rolling with an other key, when shift is on.
// Custom behaviour when alt-gr
if (mods & MOD_BIT(KC_ALGR)) {
tap_code16(ALGR(FG_TYPO));
return false;
}
is_shifted = mods & MOD_MASK_SHIFT;
if (is_shifted) {
del_weak_mods(MOD_MASK_SHIFT);
del_oneshot_mods(MOD_MASK_SHIFT);
unregister_mods(MOD_MASK_SHIFT);
}
layer_on(_TYPO);
return false;
} else if (keycode == FG_TYPO) {
// Special behaviour of FR_TYPO when shifted
// Shift must apply to the next keycode
/* is_shifted = 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(FR_TYPO);
return true;
} else if (IS_LAYER_ON(_TYPO)) {
switch (keycode) {
case FG_AROB:
case FG_K:
case FG_J:
case OU_GRV:
case FG_CCED:
case AGRV_SPC:
case CNL_TYPO:
break;
default:
/* is_shifted = 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(FG_TYPO);
}
if (!IS_LAYER_ON(_APOS_DR)) {
switch (keycode) {
case FG_M:
case FG_L:
is_shifted = true;
}
}
if (is_shifted) {
//set_mods(mods);
set_oneshot_mods(MOD_BIT(KC_LSFT));
is_shifted = false;
}
exit_typo = true;
}
/* } else { // On release
switch (keycode) {
case OS_TYPO:
case FG_TYPO:
break;
default:
if (exit_typo) { typo_layer_off(); }
} */
}
return true;
}
/* bool process_typo(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
switch (keycode) {
case OS_TYPO:
// Handle the custom OSL that go with this feature
// It's timerless, to avoid problems when rolling with an other key, when shift is on.
//is_typo = true;
if ((get_mods() | get_weak_mods() | get_oneshot_mods()) & MOD_BIT(KC_ALGR)) {
tap_code16(ALGR(FG_TYPO));
} else {
layer_on(_TYPO);
}
return false;
case FG_TYPO:
const bool is_shifted = (get_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(FG_TYPO);
//set_mods(mods);
if (is_shifted) {
set_oneshot_mods(MOD_BIT(KC_LSFT));
//is_shifted = false;
}
}
if (IS_LAYER_ON(_TYPO)) {
switch (keycode) {
case TG_TYPO:
case FG_AROB:
case FG_K:
case FG_J:
case OU_GRV:
break;
default:
//tap_code(FG_TYPO);
const bool is_shifted = (get_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(FG_TYPO);
if (is_shifted) { set_oneshot_mods(MOD_BIT(KC_LSFT)); }
}
exit_typo = true;
}
}
return true;
} */
/* bool process_typo(uint16_t keycode, const keyrecord_t *record) {
// Handle the custom keycodes that go with this feature
if (keycode == OS_TYPO) {
if (record->event.pressed) {
is_typo = true;
layer_on(_TYPO);
return false;
}
}
// Other than the custom keycode, nothing else in this feature will activate
// if the behavior is not on, so allow QMK to handle the event as usual.
if (!is_typo) { return true; }
switch (keycode) {
case TG_TYPO :
case FG_AROB:
case FG_K:
case FG_J:
case OU_GRV:
break;
default:
const bool is_shifted = (get_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(FG_TYPO);
if (is_shifted) { set_oneshot_mods(MOD_BIT(KC_LSFT)); }
}
exit_typo = true;
return true;
} */
void typo_layer_off(void) {
layer_off(_TYPO);
exit_typo = false;
}

View file

@ -47,9 +47,41 @@ uint16_t tap_hold_extractor(uint16_t keycode) {
bool caps_word_press_user(uint16_t keycode) {
// Caps Word shouldnt be applied with Alt-gr
// Managing underscore on alt gr + E.
// Underscore must continue Caps Word, without shifting.
if ((get_mods() & MOD_BIT(KC_ALGR)) && keycode == FG_E) { return true; }
if ((get_mods() & MOD_BIT(KC_ALGR))) {
switch (keycode) {
case FG_E:
case FG_T:
return true;
default:
return false;
}
}
if (IS_LAYER_ON(_TYPO)) {
switch (keycode) {
case FG_VIRG:
add_weak_mods(MOD_BIT(KC_LSFT)); // Apply shift to next key.
return true;
case FG_I:
case FG_H:
return true;
case FG_U:
case FG_T:
case FG_G:
case FG_B:
case FG_F:
case FG_M:
case FG_L:
case FG_S:
case FG_N:
return false;
}
}
//
// Keycodes that continue Caps Word, with shift applied.
if (isLetter(keycode)) {
@ -62,8 +94,6 @@ bool caps_word_press_user(uint16_t keycode) {
case FG_TYPO:
//case FG_GRV:
case FG_MOIN:
case FG_UNDS:
case FG_SLSH:
case KC_KP_1 ... KC_KP_0:
case KC_LEFT:
case KC_RIGHT:

View file

@ -97,35 +97,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
// Custom tap-hold keys
if (!process_custom_tap_hold(keycode, record)) { return false; }
// Custom behaviour of the typo dead-key
if (!process_typo(keycode, record)) { return false; }
if (IS_LAYER_ON(_TYPO) && record->event.pressed) {
switch (keycode) {
case FG_AROB:
case FG_K:
case FG_J:
case OU_GRV:
case FG_CCED:
case AGRV_SPC:
break;
default:
const bool is_shifted = (get_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(FG_TYPO);
//set_mods(mods);
if (is_shifted) {
set_oneshot_mods(MOD_BIT(KC_LSFT));
//is_shifted = false;
}
}
}
// Macros
if (!process_macros(keycode, record)) { return false; }
@ -141,6 +115,7 @@ void post_process_record_user(uint16_t keycode, keyrecord_t* record) {
if (os4a_layer != 0 && exit_os4a_layer) { os4a_layer_off(os4a_layer); }
if (exit_num_word) { disable_num_word(); }
//if (exit_typo && keycode != FG_TYPO) { typo_layer_off(); }
if (exit_typo) { typo_layer_off(); }
}
@ -247,10 +222,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* `----------------------------------' `----------------------------------'
*/
[_NUMBERS] = LAYOUT(
_______, _______, FG_ASTX, FG_EGAL, _______, FG_PERC, KC_6, _______, FG_PLUS, FG_MOIN, _______, _______,
_______, KC_6, KC_4, KC_2, FG_SLSH, FG_CARN, S(FG_ACIR), KC_1, KC_3, KC_5, KC_7, _______,
_______, _______, _______, _______, KC_8, _______, _______, _______, _______, _______, _______, KC_9, _______, _______, _______, _______,
_______, _______, FG_VIRG, KC_0 , NUMWORD, LT_REPT, KC_SPC, _______, _______, _______
_______, _______, FG_ASTX, FG_EGAL, KC_7, FG_PERC, S(FG_ACIR), _______, FG_PLUS, FG_MOIN, _______, _______,
_______, KC_6, KC_4, KC_2, MT_SLSH, _______, FG_CARN, MT_1, KC_3, KC_5, KC_7, _______,
_______, _______, _______, _______, KC_8, _______, _______, _______, _______, _______, _______, KC_9, KC_6, _______, FG_TYPO, _______,
_______, _______, KC_PDOT, KC_0 , NUMWORD, LT_REPT, KC_SPC, _______, _______, _______
),
@ -269,9 +244,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* `----------------------------------' `----------------------------------'
*/
[_TYPO] = LAYOUT(
_______, _______, _______, _______, _______, FG_D, _______, S(FG_M), S(FG_L), _______, _______, _______,
_______, OU_GRV, _______, _______, FG_B, _______, _______, FG_J, FG_T, FG_AROB, _______, _______,
_______, _______, _______, _______, FG_DQUO, _______, _______, _______, _______, _______, _______, FG_CCED, _______, FG_K, TG_TYPO, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, OU_GRV, _______, _______, FG_U, _______, _______, FG_J, FG_T, FG_AROB, _______, _______,
_______, _______, _______, _______, FG_F, _______, _______, _______, _______, _______, _______, FG_CCED, _______, FG_K, CNL_TYPO, _______,
_______, _______, _______, _______, FG_O, _______, AGRV_SPC, _______, _______, _______
),

View file

@ -68,7 +68,8 @@ enum custom_keycodes {
OS_RALT,
OS_LALT,
OS_WIN,
//OS_TYPO
OS_TYPO,
CNL_TYPO
};
// Layer taps
@ -76,11 +77,11 @@ enum custom_keycodes {
#define LT_E ALGR_T(FG_E)
#define LT_REPT LT(_NUMBERS, KC_0)
#define LT_MGC LT(_SHORTNAV, KC_0)
#define OS_TYPO OSL(_TYPO)
#define OS_FA OSL(_FUNCAPPS)
#define TT_FA TT(_FUNCAPPS)
#define TG_TYPO TG(_TYPO)
#define TG_APOD TG(_APOS_DR)
#define MT_SLSH SFT_T(FG_SLSH)
#define MT_1 SFT_T(KC_1)
// One shot mods
#define L_OS4A LSFT_T(OS4A)

View file

@ -122,7 +122,7 @@
/* AltGr symbols
*
*                                     
*                         à           
*
*       ^  !  =  $  %  #  ;  '  ?  :            
*     
@ -134,6 +134,10 @@
*
*/
// Row 1
#define FG_AGR ALGR(FG_SLSH)
// Row 2
#define FG_ACIR ALGR(FG_X) // ^
//#define FG_EXLM ALGR(FG_VIRG) // !