]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
process_action may be called either with key cache or without it
authorWojciech Siewierski <wojciech.siewierski@onet.pl>
Sat, 12 Mar 2016 23:18:20 +0000 (00:18 +0100)
committerWojciech Siewierski <wojciech.siewierski@onet.pl>
Sat, 12 Mar 2016 23:18:20 +0000 (00:18 +0100)
If one wants to temporarily disable the key cache (for example because
it interferes with a macro), `disable_action_cache` must be set to
`true`. `process_action_nocache` is a simple wrapper doing just that for
a single call.

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

index 26a5fad7ac676cbbe4517b85ce8b4ffcf74b3f27..1d3b738110f28d3594a65df5b5ef869af89b118a 100644 (file)
@@ -53,6 +53,17 @@ void action_exec(keyevent_t event)
 #endif
 }
 
+#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
+bool disable_action_cache = false;
+
+void process_action_nocache(keyrecord_t *record)
+{
+    disable_action_cache = true;
+    process_action(record);
+    disable_action_cache = false;
+}
+#endif
+
 /*
  * Make sure the action triggered when the key is released is the same
  * one as the one triggered on press. It's important for the mod keys
@@ -64,6 +75,10 @@ action_t store_or_get_action(bool pressed, keypos_t key)
 #if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
     static action_t pressed_actions[MATRIX_ROWS][MATRIX_COLS];
 
+    if (disable_action_cache) {
+        return layer_switch_get_action(key);
+    }
+
     if (pressed) {
         pressed_actions[key.row][key.col] = layer_switch_get_action(key);
     }
index 8a4736d7bc19cbb833481649b467cc4da109e1ac..34a794db2959764e5e798fae0c88ebaee5abeecb 100644 (file)
@@ -59,6 +59,10 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt);
 void action_function(keyrecord_t *record, uint8_t id, uint8_t opt);
 
 /* Utilities for actions.  */
+#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
+extern bool disable_action_cache;
+void process_action_nocache(keyrecord_t *record);
+#endif
 void process_action(keyrecord_t *record);
 void register_code(uint8_t code);
 void unregister_code(uint8_t code);