Shifted PG_ODK

This commit is contained in:
Kawamashi 2025-09-25 21:24:07 +02:00
commit af19532ac6
7 changed files with 32 additions and 88 deletions

View file

@ -22,33 +22,21 @@
void get_clever_keycode(uint16_t* next_keycode, keyrecord_t* record) { void get_clever_keycode(uint16_t* next_keycode, keyrecord_t* record) {
uint16_t prev_keycode = recent[RECENT_SIZE - 1]; uint16_t prev_keycode = recent[RECENT_SIZE - 1];
//static bool is_shifted = false;
// Apostrophe // Apostrophe
if (is_followed_by_apos(*next_keycode, prev_keycode)) { if (is_followed_by_apos(*next_keycode, prev_keycode)) {
set_last_keycode(PG_APOS); 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) { switch (prev_keycode) {
case NNB_SPC: case NNB_SPC:
switch (*next_keycode) { switch (*next_keycode) {
// Shift auto de la ponctuation après une espace fine insécable // Shift auto de la ponctuation après une espace fine insécable
case PG_POIN: 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_TIRE:
case PG_VIRG: case PG_VIRG:
return replace_ongoing_key(S(*next_keycode), next_keycode, record); 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. // Shift the letter at the beginning of sentences.
if (is_letter(*next_keycode) || is_send_string_macro(*next_keycode)) { if (is_letter(*next_keycode) || is_send_string_macro(*next_keycode)) {
//if (!is_caps_lock_on()) { add_weak_mods(MOD_BIT(KC_LSFT)); } //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; break;
} }
@ -119,15 +107,11 @@ void get_clever_keycode(uint16_t* next_keycode, keyrecord_t* record) {
switch (prev_keycode) { switch (prev_keycode) {
case PG_O: case PG_O:
// oui // oui
invoke_key(PG_U, record); process_key(PG_U, record);
case PG_U: case PG_U:
// ui SFB // ui SFB
return replace_ongoing_key(PG_I, next_keycode, record); 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: case PG_EACU:
// éa SFB // éa SFB
return replace_ongoing_key(PG_A, next_keycode, record); return replace_ongoing_key(PG_A, next_keycode, record);
@ -154,18 +138,26 @@ void get_clever_keycode(uint16_t* next_keycode, keyrecord_t* record) {
case PG_Q: case PG_Q:
// qué scissor // 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: case PG_Y:
// you bad redirection // 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: case PG_T:
// "the" // "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: 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: case PG_M:
if (is_letter(recent[RECENT_SIZE - 2])) { if (is_letter(recent[RECENT_SIZE - 2])) {
@ -187,11 +179,6 @@ void get_clever_keycode(uint16_t* next_keycode, keyrecord_t* record) {
default: default:
// "à" // "à"
process_key(PG_ODK,record); process_key(PG_ODK,record);
if (is_shifted) {
is_shifted = false;
add_weak_mods(MOD_BIT(KC_LSFT));
}
return replace_ongoing_key(PG_A, next_keycode, 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; 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: case OU_GRV:
layer_off(_ODK); layer_off(_ODK);
return finish_word((uint16_t[]) {PG_O, PG_ODK, PG_N}, 3, next_keycode, record); 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: case PG_APOS:
if (is_apos_dr) { return replace_ongoing_key(PG_APOD, next_keycode, record); } if (is_apos_dr) { return replace_ongoing_key(PG_APOD, next_keycode, record); }
break; break;

View file

@ -133,7 +133,6 @@ void process_key(uint16_t keycode, keyrecord_t* record) {
void invoke_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. process_key(keycode, record); // tap_code doesn't work with caps word.
//record->keycode = keycode;
bkspc_countdown = 1; bkspc_countdown = 1;
} }
@ -148,10 +147,15 @@ void process_word(uint16_t keycodes[], uint8_t num_keycodes, keyrecord_t* record
for (int i = 0; i < num_keycodes; ++i) { for (int i = 0; i < num_keycodes; ++i) {
process_key(keycodes[i], record); // tap_code doesn't work with caps word. 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) { 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); process_word(keycodes, num_keycodes - 1, record);
replace_ongoing_key(keycodes[num_keycodes - 1], ongoing_keycode, record); replace_ongoing_key(keycodes[num_keycodes - 1], ongoing_keycode, record);
} }

View file

@ -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 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 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_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); bool process_clever_keys(uint16_t keycode, keyrecord_t* record);
void end_CK(keyrecord_t* record); void end_CK(keyrecord_t* record);

View file

@ -19,8 +19,6 @@
bool is_apos_dr = false; bool is_apos_dr = false;
bool process_macros(uint16_t keycode, keyrecord_t *record) { 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). if (record->event.pressed) { // Handling of other macros (on press).
switch (keycode) { switch (keycode) {
@ -52,7 +50,7 @@ bool process_macros(uint16_t keycode, keyrecord_t *record) {
layer_clear(); layer_clear();
clear_oneshot_mods(); clear_oneshot_mods();
clear_weak_mods(); //clear_weak_mods();
caps_word_off(); caps_word_off();
disable_num_word(); disable_num_word();
clear_recent_keys(); clear_recent_keys();
@ -74,18 +72,7 @@ bool process_macros(uint16_t keycode, keyrecord_t *record) {
return false; return false;
case NUM_ODK: 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); tap_code(PG_ODK);
if (is_shifted) {
is_shifted = false;
set_oneshot_mods(MOD_BIT(KC_LSFT));
}
return true; return true;
case PG_DEG: case PG_DEG:

View file

@ -16,15 +16,12 @@
#include "odk_layer.h" #include "odk_layer.h"
bool is_shifted = false;
bool process_odk_layer(uint16_t keycode, keyrecord_t *record) { bool process_odk_layer(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) { // On press if (record->event.pressed) { // On press
const uint8_t mods = get_mods() | get_weak_mods() | get_oneshot_mods(); const uint8_t mods = get_mods() | get_weak_mods() | get_oneshot_mods();
//const uint8_t mods = get_mods() | get_oneshot_mods(); //const uint8_t mods = get_mods() | get_oneshot_mods();
//static bool is_shifted = false;
if (keycode == OS_ODK) { if (keycode == OS_ODK) {
// Custom behaviour when alt-gr // Custom behaviour when alt-gr
@ -36,13 +33,12 @@ bool process_odk_layer(uint16_t keycode, keyrecord_t *record) {
} else if (keycode == PG_ODK) { } else if (keycode == PG_ODK) {
// Special behaviour of PG_ODK when shifted // Special behaviour of PG_ODK when shifted
// Shift must apply to the next keycode // Shift must apply to the next keycode
is_shifted = mods & MOD_MASK_SHIFT; if (mods & MOD_MASK_SHIFT) {
if (is_shifted) {
del_weak_mods(MOD_MASK_SHIFT); del_weak_mods(MOD_MASK_SHIFT);
del_oneshot_mods(MOD_MASK_SHIFT); del_oneshot_mods(MOD_MASK_SHIFT);
unregister_mods(MOD_MASK_SHIFT); unregister_mods(MOD_MASK_SHIFT);
tap_code(PG_ODK); tap_code(PG_ODK);
add_weak_mods(MOD_BIT(KC_LSFT)); set_oneshot_mods(MOD_BIT(KC_LSFT)); // Don't use weak mods!
return false; return false;
} }
@ -61,23 +57,12 @@ bool process_odk_layer(uint16_t keycode, keyrecord_t *record) {
break; break;
default: default:
//tap_code(PG_ODK); // Don't use tap_code, it doesn't go through process_record.
// therefore it doesn't trigger the special behaviour of PG_ODK described above
invoke_key(PG_ODK, record); invoke_key(PG_ODK, record);
} }
} }
/* if (is_shifted) {
is_shifted = false;
//set_mods(mods);
add_weak_mods(MOD_BIT(KC_LSFT));
} */
} }
} }
return true; return true;
} }
/* void odk_layer_exit_check(uint16_t keycode) {
if (keycode == odk_keycode) {
layer_off(_ODK);
odk_keycode = KC_NO;
}
} */

View file

@ -24,10 +24,7 @@
extern "C" { extern "C" {
#endif #endif
extern bool is_shifted;
bool process_odk_layer(uint16_t keycode, keyrecord_t *record); bool process_odk_layer(uint16_t keycode, keyrecord_t *record);
//void odk_layer_exit_check(uint16_t keycode);
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -299,6 +299,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 (recent[RECENT_SIZE - 1] != KC_NO) { return MAGIC; }
if (get_last_keycode() == KC_NO) { return MAGIC; } if (get_last_keycode() == KC_NO) { return MAGIC; }
return KC_TRNS; // Defer to default definitions. return KC_TRNS; // Defer to default definitions.
} }