From 11022b0023c57efc72287d8f4e3e925aafe77c82 Mon Sep 17 00:00:00 2001 From: Kawamashi Date: Sun, 28 Sep 2025 05:56:55 +0200 Subject: [PATCH] essai fonction --- .../keymaps/Kawamashi/features/odk_layer.c | 38 +++++++++++++++---- .../keymaps/Kawamashi/features/odk_layer.h | 1 + .../base/keymaps/Kawamashi/features/os4a.c | 2 +- 3 files changed, 33 insertions(+), 8 deletions(-) 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 ccb39c81..22e7310a 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 @@ -21,7 +21,7 @@ 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 mod_odk = false; + //bool mod_odk = false; //const uint8_t mods = get_mods() | get_oneshot_mods(); if (keycode == OS_ODK) { @@ -32,12 +32,12 @@ bool process_odk_layer(uint16_t keycode, keyrecord_t *record) { } return true; - } else if (keycode == MOD_ODK) { - mod_odk = true; + } else if (keycode == PG_ODK) { + //mod_odk = true; + return true; } else if (IS_LAYER_ON(_ODK)) { switch (keycode) { - //case PG_3PTS: // For Clever Keys case PG_PVIR: case PG_AROB: case PG_K: @@ -46,10 +46,12 @@ bool process_odk_layer(uint16_t keycode, keyrecord_t *record) { case OU_GRV: case KC_SPC: // When space is added by Clever Keys case CNL_ODK: + case PG_ODK: return true; default: - mod_odk = true; + mod_odk(); + //mod_odk = true; //process_odk_layer(MOD_ODK, record); // 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 @@ -57,7 +59,7 @@ bool process_odk_layer(uint16_t keycode, keyrecord_t *record) { } } - if (mod_odk) { +/* if (mod_odk) { // Special behaviour of PG_ODK when shifted // Shift must apply to the next keycode mod_odk = false; @@ -74,9 +76,31 @@ bool process_odk_layer(uint16_t keycode, keyrecord_t *record) { if (is_shifted) { set_oneshot_mods(MOD_BIT(KC_LSFT)); // Don't use weak mods ! + is_shifted = false; } if (keycode == MOD_ODK) { return false; } - } + } */ } return true; +} + +void mod_odk(void) { + // Special behaviour of PG_ODK when shifted + // Shift must apply to the next keycode + bool is_shifted = false; + const uint8_t mods = get_mods() | get_weak_mods() | get_oneshot_mods(); + + 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; + } + + tap_code(PG_ODK); + + if (is_shifted) { + set_oneshot_mods(MOD_BIT(KC_LSFT)); // Don't use weak mods ! + is_shifted = false; + } } \ 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 dad5bf25..e18ee343 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 @@ -25,6 +25,7 @@ extern "C" { #endif bool process_odk_layer(uint16_t keycode, keyrecord_t *record); +void mod_odk(void); #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..16a25edd 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));