Cut the memory consumption of PREVENT_STUCK_MODIFIERS in half
This commit is contained in:
parent
a5cdc3aab1
commit
b4f442dfea
@ -55,7 +55,7 @@ void action_exec(keyevent_t event)
|
|||||||
|
|
||||||
#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
|
#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
|
||||||
bool disable_action_cache = false;
|
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)
|
void process_action_nocache(keyrecord_t *record)
|
||||||
{
|
{
|
||||||
@ -84,9 +84,9 @@ action_t store_or_get_action(bool pressed, keypos_t key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pressed) {
|
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
|
#else
|
||||||
return layer_switch_get_action(key);
|
return layer_switch_get_action(key);
|
||||||
#endif
|
#endif
|
||||||
|
@ -61,7 +61,7 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt);
|
|||||||
/* Utilities for actions. */
|
/* Utilities for actions. */
|
||||||
#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
|
#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
|
||||||
extern bool disable_action_cache;
|
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
|
#endif
|
||||||
void process_action_nocache(keyrecord_t *record);
|
void process_action_nocache(keyrecord_t *record);
|
||||||
void process_action(keyrecord_t *record);
|
void process_action(keyrecord_t *record);
|
||||||
|
@ -111,8 +111,7 @@ void layer_debug(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
int8_t layer_switch_get_layer(keypos_t key)
|
||||||
action_t layer_switch_get_action(keypos_t key)
|
|
||||||
{
|
{
|
||||||
action_t action;
|
action_t action;
|
||||||
action.code = ACTION_TRANSPARENT;
|
action.code = ACTION_TRANSPARENT;
|
||||||
@ -124,15 +123,18 @@ action_t layer_switch_get_action(keypos_t key)
|
|||||||
if (layers & (1UL<<i)) {
|
if (layers & (1UL<<i)) {
|
||||||
action = action_for_key(i, key);
|
action = action_for_key(i, key);
|
||||||
if (action.code != ACTION_TRANSPARENT) {
|
if (action.code != ACTION_TRANSPARENT) {
|
||||||
return action;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* fall back to layer 0 */
|
/* fall back to layer 0 */
|
||||||
action = action_for_key(0, key);
|
return 0;
|
||||||
return action;
|
|
||||||
#else
|
#else
|
||||||
action = action_for_key(biton32(default_layer_state), key);
|
return biton32(default_layer_state);
|
||||||
return action;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
action_t layer_switch_get_action(keypos_t key)
|
||||||
|
{
|
||||||
|
return action_for_key(layer_switch_get_layer(key), key);
|
||||||
|
}
|
||||||
|
@ -71,6 +71,9 @@ void layer_xor(uint32_t state);
|
|||||||
#endif
|
#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 */
|
/* return action depending on current layer status */
|
||||||
action_t layer_switch_get_action(keypos_t key);
|
action_t layer_switch_get_action(keypos_t key);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user