Skip to content
Permalink
Browse files
Keep pressed keys on layer state change (fixes #2053, #2279) (#3905)
* Keep pressed keys on layer state change

* Add doc comment for clear_keyboard_but_mods_and_keys

* Keep pressed keys only if PREVENT_STUCK_MODIFIERS is on

* Check STRICT_LAYER_RELEASE instead of PREVENT_STUCK_MODIFIERS
  • Loading branch information
vomindoraan authored and mechmerlin committed Dec 28, 2018
1 parent fbcbf44 commit 93b004c943a4b13bd640fc83000e910b72cb4640
Showing with 19 additions and 1 deletion.
  1. +10 −1 tmk_core/common/action.c
  2. +1 −0 tmk_core/common/action.h
  3. +8 −0 tmk_core/common/action_layer.c
@@ -898,10 +898,19 @@ void clear_keyboard(void)
* FIXME: Needs documentation.
*/
void clear_keyboard_but_mods(void)
{
clear_keys();
clear_keyboard_but_mods_and_keys();
}

/** \brief Utilities for actions. (FIXME: Needs better description)
*
* FIXME: Needs documentation.
*/
void clear_keyboard_but_mods_and_keys()
{
clear_weak_mods();
clear_macro_mods();
clear_keys();
send_keyboard_report();
#ifdef MOUSEKEY_ENABLE
mousekey_clear();
@@ -94,6 +94,7 @@ void unregister_mods(uint8_t mods);
//void set_mods(uint8_t mods);
void clear_keyboard(void);
void clear_keyboard_but_mods(void);
void clear_keyboard_but_mods_and_keys(void);
void layer_switch(uint8_t new_layer);
bool is_tap_key(keypos_t key);

@@ -44,7 +44,11 @@ static void default_layer_state_set(uint32_t state)
default_layer_debug(); debug(" to ");
default_layer_state = state;
default_layer_debug(); debug("\n");
#ifdef STRICT_LAYER_RELEASE
clear_keyboard_but_mods(); // To avoid stuck keys
#else
clear_keyboard_but_mods_and_keys(); // Don't reset held keys
#endif
}

/** \brief Default Layer Print
@@ -127,7 +131,11 @@ void layer_state_set(uint32_t state)
layer_debug(); dprint(" to ");
layer_state = state;
layer_debug(); dprintln();
#ifdef STRICT_LAYER_RELEASE
clear_keyboard_but_mods(); // To avoid stuck keys
#else
clear_keyboard_but_mods_and_keys(); // Don't reset held keys
#endif
}

/** \brief Layer clear

0 comments on commit 93b004c

Please sign in to comment.