diff options
Diffstat (limited to 'qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c')
| -rw-r--r-- | qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c b/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c index e2fb583..76b6b91 100644 --- a/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c +++ b/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c @@ -3,12 +3,39 @@ bool keycodes_process_record(uint16_t keycode, keyrecord_t *record) { + static bool kc_lgui = false; + static bool kc_ralt = false; switch (keycode) { case KC_ESC: + /* By default, send the ESC code to the host. + * This code will be muted if there is a specific state to remove firts. + + * The keys L_GUI and R_ALT activate a layer automatically, but can be + * used in a combo with the ESC key, I do not want to ignore the key press + * in this case. + */ + bool handle_key = true; + if (get_oneshot_mods()) { + clear_oneshot_mods(); + handle_key = false; + } + if ( (! kc_ralt) \ + && (! kc_lgui) \ + && (layer_state_is(LAYER_KEYPAD) || layer_state_is(LAYER_ARROW) )) { + // Remove the layer the key is released. + layer_clear(); + handle_key = false; + } + if (host_keyboard_led_state().caps_lock) { + tap_code16(KC_CAPS_LOCK); + handle_key = false; + } + return handle_key; case AL_ENT: - if (!record->event.pressed && \ - (layer_state_is(LAYER_KEYPAD) || layer_state_is(LAYER_ARROW) )) { + if (!record->event.pressed \ + && (! kc_lgui) \ + && (layer_state_is(LAYER_KEYPAD) || layer_state_is(LAYER_ARROW) )) { // Remove the layer the key is released. layer_clear(); } @@ -17,16 +44,20 @@ bool keycodes_process_record(uint16_t keycode, keyrecord_t *record) { // Override the key APP when hold into AltGR + Layer 1 when hold case KEY_APP: if (!record->tap.count && record->event.pressed) { - layer_on(LAYER_ARROW); + kc_ralt = record->event.pressed; register_code(KC_RIGHT_ALT); + layer_on(LAYER_ARROW); return false; } else if (!record->tap.count && !record->event.pressed) { + kc_ralt = record->event.pressed; unregister_code(KC_RIGHT_ALT); layer_off(LAYER_ARROW); return false; } + return true; case KC_LGUI: + kc_lgui = record->event.pressed; if (record->event.pressed) { layer_on(LAYER_ARROW); } |
