]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Keep pressed keys on layer state change (fixes #2053, #2279) (#3905)
authorKonstantin Đorđević <vomindoraan@gmail.com>
Fri, 28 Dec 2018 19:07:56 +0000 (20:07 +0100)
committerMechMerlin <30334081+mechmerlin@users.noreply.github.com>
Fri, 28 Dec 2018 19:07:56 +0000 (11:07 -0800)
* 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

tmk_core/common/action.c
tmk_core/common/action.h
tmk_core/common/action_layer.c

index 456d1e25fe4dad2423adbe847a023c68a76d88b7..b99c2acaa7a9211c5f7848aa1014b9b39c9f57a5 100644 (file)
@@ -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();
index 5d797fd628ffad87af17bde99b4bdbf60e60fec3..8e47e5339edaa8229ef0edb4efac87ca34158d03 100644 (file)
@@ -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);
 
index b8dcb34f3a04f65b8d0cd087e9f50ef931015726..120ce3f51b910fc5a02f0d12e6126c3171aa5c4c 100644 (file)
@@ -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