Shift & ODK

This commit is contained in:
Kawamashi 2025-08-03 23:26:29 +02:00
commit 634dd66dee
7 changed files with 38 additions and 41 deletions

View file

@ -52,8 +52,8 @@ void get_clever_keycode(uint16_t* next_keycode, keyrecord_t* record) {
case PG_QUES:
case PG_3PTS:
case PG_POIN:
// Add OS shift at the beginning of sentences.
if (!is_caps_lock_on()) { set_oneshot_mods(MOD_BIT(KC_LSFT)); }
// Shift the letter at the beginning of sentences.
if (!is_caps_lock_on()) { add_weak_mods(MOD_BIT(KC_LSFT)); }
break;
}
}
@ -131,17 +131,11 @@ void get_clever_keycode(uint16_t* next_keycode, keyrecord_t* record) {
case MAGIC:
if (!is_letter(prev_keycode)) {
// "à"
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);
}
process_key(PG_ODK,record);
if (is_shifted) {
//is_shifted = false;
set_oneshot_mods(MOD_BIT(KC_LSFT));
is_shifted = false;
add_weak_mods(MOD_BIT(KC_LSFT));
}
return replace_ongoing_key(PG_A, next_keycode, record);
}

View file

@ -39,7 +39,7 @@ void recent_keys_task(void) {
// Handles one event. Returns false if the key was appended to `recent`.
uint16_t get_ongoing_keycode(uint16_t keycode, keyrecord_t* record) {
uint8_t mods = get_mods() | get_oneshot_mods();
uint8_t mods = get_mods() | get_weak_mods() | get_oneshot_mods();
if (mods & ~(MOD_MASK_SHIFT | MOD_BIT(KC_ALGR))) {
clear_recent_keys(); // Avoid interfering with ctrl, left alt and gui.

View file

@ -82,7 +82,7 @@ bool process_macros(uint16_t keycode, keyrecord_t *record) {
tap_code(PG_ODK);
if (is_shifted) {
//is_shifted = false;
is_shifted = false;
set_oneshot_mods(MOD_BIT(KC_LSFT));
}
return true;

View file

@ -16,23 +16,26 @@
#include "odk_layer.h"
//static uint16_t odk_keycode = KC_NO;
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();
static bool is_shifted = false;
//const uint8_t mods = get_mods() | get_oneshot_mods();
//static bool is_shifted = false;
if (keycode == OS_ODK) {
// 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)) {
if (mods & MOD_BIT(KC_ALGR)) {
tap_code16(ALGR(PG_ODK));
return false;
} */
}
} else if (keycode == PG_ODK) {
// Special behaviour of PG_ODK when shifted
// Shift must apply to the next keycode
is_shifted = mods & MOD_MASK_SHIFT;
if (is_shifted) {
del_weak_mods(MOD_MASK_SHIFT);
@ -40,31 +43,27 @@ bool process_odk_layer(uint16_t keycode, keyrecord_t *record) {
unregister_mods(MOD_MASK_SHIFT);
}
} else if (keycode == PG_ODK) {
// Special behaviour of FR_ODK when shifted
// Shift must apply to the next keycode
return true;
} else if (IS_LAYER_ON(_ODK)) {
switch (keycode) {
case PG_3PTS: // For Clever Keys
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);
} else {
if (IS_LAYER_ON(_ODK)) {
switch (keycode) {
case PG_3PTS: // For Clever Keys
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);
}
}
if (is_shifted) {
is_shifted = false;
//set_mods(mods);
set_oneshot_mods(MOD_BIT(KC_LSFT));
add_weak_mods(MOD_BIT(KC_LSFT));
}
}
}

View file

@ -24,6 +24,8 @@
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);

View file

@ -68,7 +68,7 @@ bool process_os4a_layers(uint16_t keycode, keyrecord_t *record) {
// to be processed (ex: custom altgr, clever keys).
uint8_t mods = get_mods() | get_oneshot_mods();
if (!exit_os4a_layer && !pending_OSL && to_be_shifted(keycode, record) && mods == 0) {
set_oneshot_mods(MOD_BIT(KC_LSFT));
add_weak_mods(MOD_BIT(KC_LSFT));
}
return true;
}

View file

@ -190,6 +190,8 @@ bool to_be_shifted(uint16_t keycode, keyrecord_t *record) {
if (!IS_KEYEVENT(record->event)) { return true; }
switch (keycode) {
case OS_ODK:
is_shifted = true;
case KC_CAPS:
case CAPSWORD:
return false;
@ -232,7 +234,7 @@ bool is_oneshot_ignored_key(uint16_t keycode) {
case OS_FA:
case NUMWORD:
case TT_FA:
case NUM_ODK:
//case NUM_ODK:
//case PG_ODK:
return true;
default: