]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Cut the memory consumption of PREVENT_STUCK_MODIFIERS in half
authorWojciech Siewierski <wojciech.siewierski@onet.pl>
Sun, 27 Mar 2016 21:50:07 +0000 (23:50 +0200)
committerWojciech Siewierski <wojciech.siewierski@onet.pl>
Sun, 27 Mar 2016 21:51:46 +0000 (23:51 +0200)
tmk_core/common/action.c
tmk_core/common/action.h
tmk_core/common/action_layer.c
tmk_core/common/action_layer.h

index fc09383ee0fc424b7524b973c4f13a6bfb381a84..acc6d11eab3981130734b66ca6ff6d84977d4bce 100644 (file)
@@ -55,7 +55,7 @@ void action_exec(keyevent_t event)
 
 #if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
 bool disable_action_cache = false;
-action_t pressed_actions_cache[MATRIX_ROWS][MATRIX_COLS];
+int8_t pressed_actions_cache[MATRIX_ROWS][MATRIX_COLS];
 
 void process_action_nocache(keyrecord_t *record)
 {
@@ -84,9 +84,9 @@ action_t store_or_get_action(bool pressed, keypos_t key)
     }
 
     if (pressed) {
-        pressed_actions_cache[key.row][key.col] = layer_switch_get_action(key);
+        pressed_actions_cache[key.row][key.col] = layer_switch_get_layer(key);
     }
-    return pressed_actions_cache[key.row][key.col];
+    return action_for_key(pressed_actions_cache[key.row][key.col], key);
 #else
     return layer_switch_get_action(key);
 #endif
index 7a60f320e7a61d1d5ef5c80b525b8e45d913d8f2..2b43d001e14dad1c3809c6eff0f09e18869c95a5 100644 (file)
@@ -61,7 +61,7 @@ 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;
-extern action_t pressed_actions_cache[MATRIX_ROWS][MATRIX_COLS];
+extern int8_t pressed_actions_cache[MATRIX_ROWS][MATRIX_COLS];
 #endif
 void process_action_nocache(keyrecord_t *record);
 void process_action(keyrecord_t *record);
index c535615f44d44a8fa669e1f86825142b9c56b616..76164adb5d80eebbb036226d91784615fbea0b77 100644 (file)
@@ -111,8 +111,7 @@ void layer_debug(void)
 #endif
 
 
-
-action_t layer_switch_get_action(keypos_t key)
+int8_t layer_switch_get_layer(keypos_t key)
 {
     action_t action;
     action.code = ACTION_TRANSPARENT;
@@ -124,15 +123,18 @@ action_t layer_switch_get_action(keypos_t key)
         if (layers & (1UL<<i)) {
             action = action_for_key(i, key);
             if (action.code != ACTION_TRANSPARENT) {
-                return action;
+                return i;
             }
         }
     }
     /* fall back to layer 0 */
-    action = action_for_key(0, key);
-    return action;
+    return 0;
 #else
-    action = action_for_key(biton32(default_layer_state), key);
-    return action;
+    return biton32(default_layer_state);
 #endif
 }
+
+action_t layer_switch_get_action(keypos_t key)
+{
+    return action_for_key(layer_switch_get_layer(key), key);
+}
index b6da353cfdbe851d6bfb5689b6173135b8697d84..1a313a2590472a72efb581557191cc8fbbad7ba2 100644 (file)
@@ -71,6 +71,9 @@ void layer_xor(uint32_t state);
 #endif
 
 
+/* return the topmost non-transparent layer currently associated with key */
+int8_t layer_switch_get_layer(keypos_t key);
+
 /* return action depending on current layer status */
 action_t layer_switch_get_action(keypos_t key);