Création branche

This commit is contained in:
Kawamashi 2025-04-01 09:39:58 +02:00
commit 984cab17e8
14 changed files with 475 additions and 27 deletions

View file

@ -33,6 +33,7 @@ bool clever_key_finder(uint16_t next_keycode, keyrecord_t* record) {
case FG_2PTS:
// Add space between punctuation and letters.
invoke_key(KC_SPC, record);
//if (next_keycode == FG_J) { layer_on(_TYPO); }
case KC_SPC:
switch (recent[RECENT_SIZE - 2]) {
@ -260,7 +261,7 @@ 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_D}, 3, record);
return finish_word((uint16_t[]) {FG_O, FG_TYPO, FG_T}, 3, record);
case AGRV_SPC:
/* const bool is_shifted = (get_mods() | get_weak_mods() | get_oneshot_mods()) & MOD_MASK_SHIFT;

View file

@ -141,6 +141,7 @@ void process_key(uint16_t keycode, keyrecord_t* record) {
void invoke_key(uint16_t keycode, keyrecord_t* record) {
process_key(keycode, record);
//record->keycode = keycode;
bkspc_countdown = 1;
}

View file

@ -89,6 +89,8 @@ bool combo_should_trigger(uint16_t combo_index, combo_t *combo, uint16_t keycode
case R_BKSPC:
case BK_WORD:
case ENTER:
case HOME:
case END:
return true;
default:

View file

@ -28,26 +28,6 @@ bool process_macros(uint16_t keycode, keyrecord_t *record) {
case REV_TAB:
return process_swapper(S(KC_TAB)); */
/* case OS_TYPO:
if ((get_mods() | get_weak_mods() | get_oneshot_mods()) & MOD_BIT(KC_ALGR)) {
tap_code16(ALGR(FG_TYPO));
return false;
}
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);
del_oneshot_mods(MOD_BIT(KC_LSFT));
}
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)) {
case _BASE:

View file

@ -6,6 +6,7 @@
typedef enum {
os_up_unqueued,
os_up_queued,
//os_up_queued_used,
os_down_unused,
os_down_used,
} oneshot_state;

View file

@ -0,0 +1,167 @@
/* Copyright 2025 @Kawamashi
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "typo_layer.h"
//#include "print.h"
oneshot_state os_typo_state = os_up_unqueued;
static bool is_shifted = false;
//static uint16_t typo_keycode = KC_NO;
//bool exit_typo = false;
bool update_oneshot_typo(oneshot_state *state, uint16_t keycode, keyrecord_t *record) {
const uint8_t mods = get_mods() | get_weak_mods() | get_oneshot_mods();
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.
if (record->event.pressed) { // On press
// 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);
//*state = os_down_unused;
*state = os_up_queued;
return false;
} else { // On release
return true;
}
//} else if (keycode == CNL_TYPO) {
} 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);
*state = os_up_queued;
return true;
} else {
if (record->event.pressed) {
uint8_t key_layer = read_source_layers_cache(record->event.key);
if (key_layer == _TYPO) {
// On non-ignored keyup, consider the oneshot used.
switch (*state) {
/* case os_down_unused:
*state = os_down_used;
dprintf("key down, layer: %d, os_down_unused -> os_down_used\n", _TYPO);
return true; */
case os_up_queued:
*state = os_up_queued_used;
dprintf("key down, layer: %d, os_up_queued -> os_up_queued_used\n", _TYPO);
return true;
case os_up_queued_used:
*state = os_up_unqueued;
layer_off(_TYPO);
dprintf("key down (off), layer: %d, os_up_queued_used -> os_up_unqueued\n", _TYPO);
//return false;
default:
break;
}
}
} else {
// Ignore key ups from other layers
uint8_t key_layer = read_source_layers_cache(record->event.key);
if (key_layer == _TYPO) {
// On non-ignored keyup, consider the oneshot used.
switch (*state) {
case os_up_queued:
*state = os_up_unqueued;
layer_off(_TYPO);
dprintf("key up (off), layer: %d, os_up_queued -> os_up_unqueued\n", _TYPO);
return true;
case os_up_queued_used:
*state = os_up_unqueued;
layer_off(_TYPO);
dprintf("key up (off), layer: %d, os_up_queued_used -> os_up_unqueued\n", _TYPO);
return true;
default:
break;
}
}
}
}
return true;
}
bool process_typo_layer(uint16_t keycode, keyrecord_t *record) {
//if (keycode == FG_TYPO) { return true; }
if (!update_oneshot_typo(&os_typo_state, keycode, record)) { return false; }
if (IS_LAYER_ON(_TYPO)) {
if (record->event.pressed) { // On press
switch (keycode) {
case FG_AROB:
case FG_K:
case FG_J:
case OU_GRV:
case FG_CCED:
case AGRV_SPC:
case KC_SPC: // When space is added by Clever Keys
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;
}
}
return true;
}
/* void typo_layer_off(void) {
layer_off(_TYPO);
exit_typo = false;
} */

View file

@ -0,0 +1,169 @@
/* Copyright 2025 @Kawamashi
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "typo_layer.h"
//#include "print.h"
oneshot_state os_typo_state = os_up_unqueued;
static bool is_shifted = false;
//static uint16_t typo_keycode = KC_NO;
//bool exit_typo = false;
bool update_oneshot_typo(oneshot_state *state, uint16_t keycode, keyrecord_t *record) {
const uint8_t mods = get_mods() | get_weak_mods() | get_oneshot_mods();
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.
if (record->event.pressed) { // On press
// 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);
//*state = os_down_unused;
*state = os_up_queued;
return false;
} else { // On release
return true;
}
//} else if (keycode == CNL_TYPO) {
} 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);
//*state = os_up_queued;
return true;
} else {
if (record->event.pressed) {
//uint8_t key_layer = read_source_layers_cache(record->event.key);
//if (key_layer == _TYPO) {
if (IS_LAYER_ON(_TYPO)) {
// On non-ignored keyup, consider the oneshot used.
switch (*state) {
/* case os_down_unused:
*state = os_down_used;
dprintf("key down, layer: %d, os_down_unused -> os_down_used\n", _TYPO);
return true; */
case os_up_queued:
*state = os_up_queued_used;
dprintf("key down, layer: %d, os_up_queued -> os_up_queued_used\n", _TYPO);
return true;
case os_up_queued_used:
*state = os_up_unqueued;
layer_off(_TYPO);
dprintf("key down (off), layer: %d, os_up_queued_used -> os_up_unqueued\n", _TYPO);
//return false;
default:
break;
}
}
} else {
// Ignore key ups from other layers
//uint8_t key_layer = read_source_layers_cache(record->event.key);
//if (key_layer == _TYPO) {
if (IS_LAYER_ON(_TYPO)) {
// On non-ignored keyup, consider the oneshot used.
switch (*state) {
case os_up_queued:
*state = os_up_unqueued;
layer_off(_TYPO);
dprintf("key up (off), layer: %d, os_up_queued -> os_up_unqueued\n", _TYPO);
return true;
case os_up_queued_used:
*state = os_up_unqueued;
layer_off(_TYPO);
dprintf("key up (off), layer: %d, os_up_queued_used -> os_up_unqueued\n", _TYPO);
return true;
default:
break;
}
}
}
}
return true;
}
bool process_typo_layer(uint16_t keycode, keyrecord_t *record) {
//if (keycode == FG_TYPO) { return true; }
if (!update_oneshot_typo(&os_typo_state, keycode, record)) { return false; }
if (IS_LAYER_ON(_TYPO)) {
if (record->event.pressed) { // On press
switch (keycode) {
case FG_AROB:
case FG_K:
case FG_J:
case OU_GRV:
case FG_CCED:
case AGRV_SPC:
case KC_SPC: // When space is added by Clever Keys
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;
}
}
return true;
}
/* void typo_layer_off(void) {
layer_off(_TYPO);
exit_typo = false;
} */

View file

@ -0,0 +1,124 @@
/* Copyright 2025 @Kawamashi
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "typo_layer.h"
static uint16_t typo_keycode = KC_NO;
//bool 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)) {
if (typo_keycode == KC_NO) {
typo_keycode = keycode;
//if (!IS_QK_USER(keycode)) { typo_keycode = keycode; }
} else {
// if another key is tapped when the 1st one is not released yet.
layer_off(_TYPO);
//typo_keycode = KC_NO;
return true;
}
switch (keycode) {
case FG_AROB:
case FG_K:
case FG_J:
case OU_GRV:
case FG_CCED:
case AGRV_SPC:
case KC_SPC: // When space is added by Clever Keys
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 {
typo_keycode = KC_NO;
}
} else { // On release
switch (keycode) {
case OS_TYPO:
case FG_TYPO:
break;
default:
//if (exit_typo) { typo_layer_off(); }
if (keycode == typo_keycode) {
layer_off(_TYPO);
typo_keycode = KC_NO;
}
}
}
return true;
}
/* void typo_layer_off(void) {
layer_off(_TYPO);
exit_typo = false;
} */

View file

@ -19,7 +19,7 @@
bool exit_typo = false;
bool process_typo(uint16_t keycode, keyrecord_t *record) {
bool process_typo_layer(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) { // On press

View file

@ -28,7 +28,8 @@ extern bool exit_typo;
void typo_layer_off(void);
bool process_typo(uint16_t keycode, keyrecord_t *record);
//bool update_oneshot_typo(oneshot_state *state, uint16_t keycode, keyrecord_t *record);
bool process_typo_layer(uint16_t keycode, keyrecord_t *record);
#ifdef __cplusplus
}

View file

@ -69,7 +69,7 @@ bool caps_word_press_user(uint16_t keycode) {
case FG_H:
return true;
case FG_U:
case FG_T:
case FG_D:
case FG_G:
case FG_B:
case FG_F:

View file

@ -98,7 +98,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (!process_custom_tap_hold(keycode, record)) { return false; }
// Custom behaviour of the typo dead-key
if (!process_typo(keycode, record)) { return false; }
if (!process_typo_layer(keycode, record)) { return false; }
// Macros
if (!process_macros(keycode, record)) { return false; }
@ -245,7 +245,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
*/
[_TYPO] = LAYOUT(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, OU_GRV, _______, _______, FG_U, _______, _______, FG_J, FG_T, FG_AROB, _______, _______,
_______, OU_GRV, _______, _______, FG_U, _______, _______, FG_J, FG_D, FG_AROB, _______, _______,
_______, _______, _______, _______, FG_F, _______, _______, _______, _______, _______, _______, FG_CCED, _______, FG_K, CNL_TYPO, _______,
_______, _______, _______, _______, FG_O, _______, AGRV_SPC, _______, _______, _______
),

View file

@ -58,7 +58,7 @@ enum custom_keycodes {
O_CIRC,
U_CIRC,
I_TREM, */
CA_CED,
//CA_CED,
/* CIRC,
TILDE,
GRAVE, */
@ -82,6 +82,7 @@ enum custom_keycodes {
#define TG_APOD TG(_APOS_DR)
#define MT_SLSH SFT_T(FG_SLSH)
#define MT_1 SFT_T(KC_1)
//#define OS_TYPO OSL(_TYPO)
// One shot mods
#define L_OS4A LSFT_T(OS4A)

View file

@ -11,6 +11,7 @@ RGBLIGHT_ENABLE = no # Disable keyboard RGB underglow
#OLED_DRIVER = ssd1306 # Enables the use of OLED displays
#OLED_DRIVER_ENABLE = yes # Enables the use of OLED displays
#CONSOLE_ENABLE = yes
LTO_ENABLE = yes