diff options
| author | Konstantin Đorđević <vomindoraan@gmail.com> | 2018-12-28 20:07:56 +0100 |
|---|---|---|
| committer | MechMerlin <30334081+mechmerlin@users.noreply.github.com> | 2018-12-28 11:07:56 -0800 |
| commit | 93b004c943a4b13bd640fc83000e910b72cb4640 (patch) | |
| tree | 48bde7eb31533cc3690f5638a2803deadfea0fc0 /tmk_core | |
| parent | fbcbf4492685108a7f257df4e06871abd9def4d7 (diff) | |
| download | qmk_firmware-93b004c943a4b13bd640fc83000e910b72cb4640.tar.gz qmk_firmware-93b004c943a4b13bd640fc83000e910b72cb4640.zip | |
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
Diffstat (limited to 'tmk_core')
| -rw-r--r-- | tmk_core/common/action.c | 11 | ||||
| -rw-r--r-- | tmk_core/common/action.h | 1 | ||||
| -rw-r--r-- | tmk_core/common/action_layer.c | 8 |
3 files changed, 19 insertions, 1 deletions
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index 456d1e25f..b99c2acaa 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c | |||
| @@ -899,9 +899,18 @@ void clear_keyboard(void) | |||
| 899 | */ | 899 | */ |
| 900 | void clear_keyboard_but_mods(void) | 900 | void clear_keyboard_but_mods(void) |
| 901 | { | 901 | { |
| 902 | clear_keys(); | ||
| 903 | clear_keyboard_but_mods_and_keys(); | ||
| 904 | } | ||
| 905 | |||
| 906 | /** \brief Utilities for actions. (FIXME: Needs better description) | ||
| 907 | * | ||
| 908 | * FIXME: Needs documentation. | ||
| 909 | */ | ||
| 910 | void clear_keyboard_but_mods_and_keys() | ||
| 911 | { | ||
| 902 | clear_weak_mods(); | 912 | clear_weak_mods(); |
| 903 | clear_macro_mods(); | 913 | clear_macro_mods(); |
| 904 | clear_keys(); | ||
| 905 | send_keyboard_report(); | 914 | send_keyboard_report(); |
| 906 | #ifdef MOUSEKEY_ENABLE | 915 | #ifdef MOUSEKEY_ENABLE |
| 907 | mousekey_clear(); | 916 | mousekey_clear(); |
diff --git a/tmk_core/common/action.h b/tmk_core/common/action.h index 5d797fd62..8e47e5339 100644 --- a/tmk_core/common/action.h +++ b/tmk_core/common/action.h | |||
| @@ -94,6 +94,7 @@ void unregister_mods(uint8_t mods); | |||
| 94 | //void set_mods(uint8_t mods); | 94 | //void set_mods(uint8_t mods); |
| 95 | void clear_keyboard(void); | 95 | void clear_keyboard(void); |
| 96 | void clear_keyboard_but_mods(void); | 96 | void clear_keyboard_but_mods(void); |
| 97 | void clear_keyboard_but_mods_and_keys(void); | ||
| 97 | void layer_switch(uint8_t new_layer); | 98 | void layer_switch(uint8_t new_layer); |
| 98 | bool is_tap_key(keypos_t key); | 99 | bool is_tap_key(keypos_t key); |
| 99 | 100 | ||
diff --git a/tmk_core/common/action_layer.c b/tmk_core/common/action_layer.c index b8dcb34f3..120ce3f51 100644 --- a/tmk_core/common/action_layer.c +++ b/tmk_core/common/action_layer.c | |||
| @@ -44,7 +44,11 @@ static void default_layer_state_set(uint32_t state) | |||
| 44 | default_layer_debug(); debug(" to "); | 44 | default_layer_debug(); debug(" to "); |
| 45 | default_layer_state = state; | 45 | default_layer_state = state; |
| 46 | default_layer_debug(); debug("\n"); | 46 | default_layer_debug(); debug("\n"); |
| 47 | #ifdef STRICT_LAYER_RELEASE | ||
| 47 | clear_keyboard_but_mods(); // To avoid stuck keys | 48 | clear_keyboard_but_mods(); // To avoid stuck keys |
| 49 | #else | ||
| 50 | clear_keyboard_but_mods_and_keys(); // Don't reset held keys | ||
| 51 | #endif | ||
| 48 | } | 52 | } |
| 49 | 53 | ||
| 50 | /** \brief Default Layer Print | 54 | /** \brief Default Layer Print |
| @@ -127,7 +131,11 @@ void layer_state_set(uint32_t state) | |||
| 127 | layer_debug(); dprint(" to "); | 131 | layer_debug(); dprint(" to "); |
| 128 | layer_state = state; | 132 | layer_state = state; |
| 129 | layer_debug(); dprintln(); | 133 | layer_debug(); dprintln(); |
| 134 | #ifdef STRICT_LAYER_RELEASE | ||
| 130 | clear_keyboard_but_mods(); // To avoid stuck keys | 135 | clear_keyboard_but_mods(); // To avoid stuck keys |
| 136 | #else | ||
| 137 | clear_keyboard_but_mods_and_keys(); // Don't reset held keys | ||
| 138 | #endif | ||
| 131 | } | 139 | } |
| 132 | 140 | ||
| 133 | /** \brief Layer clear | 141 | /** \brief Layer clear |
