From b4f442dfeaf4d434ae0d8459dc5199cd8fefc1c7 Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Sun, 27 Mar 2016 23:50:07 +0200 Subject: [PATCH] Cut the memory consumption of PREVENT_STUCK_MODIFIERS in half --- tmk_core/common/action.c | 6 +++--- tmk_core/common/action.h | 2 +- tmk_core/common/action_layer.c | 16 +++++++++------- tmk_core/common/action_layer.h | 3 +++ 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index fc09383ee..acc6d11ea 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c @@ -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 diff --git a/tmk_core/common/action.h b/tmk_core/common/action.h index 7a60f320e..2b43d001e 100644 --- a/tmk_core/common/action.h +++ b/tmk_core/common/action.h @@ -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); diff --git a/tmk_core/common/action_layer.c b/tmk_core/common/action_layer.c index c535615f4..76164adb5 100644 --- a/tmk_core/common/action_layer.c +++ b/tmk_core/common/action_layer.c @@ -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<