X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;f=tmk_core%2Fcommon%2Faction_layer.c;h=be316697190cc7b2a1533ca606a570872256967d;hb=3e8289b53ce929484651fc065fb5f718e4e3ae21;hp=c535615f44d44a8fa669e1f86825142b9c56b616;hpb=a3d96d3aa96318d339a67de1085e0ae495d57c84;p=max%2Ftmk_keyboard.git diff --git a/tmk_core/common/action_layer.c b/tmk_core/common/action_layer.c index c535615f..be316697 100644 --- a/tmk_core/common/action_layer.c +++ b/tmk_core/common/action_layer.c @@ -3,6 +3,7 @@ #include "action.h" #include "util.h" #include "action_layer.h" +#include "hook.h" #ifdef DEBUG_ACTION #include "debug.h" @@ -21,8 +22,11 @@ static void default_layer_state_set(uint32_t state) debug("default_layer_state: "); default_layer_debug(); debug(" to "); default_layer_state = state; + hook_default_layer_change(default_layer_state); default_layer_debug(); debug("\n"); +#ifdef NO_TRACK_KEY_PRESS clear_keyboard_but_mods(); // To avoid stuck keys +#endif } void default_layer_debug(void) @@ -62,8 +66,11 @@ static void layer_state_set(uint32_t state) dprint("layer_state: "); layer_debug(); dprint(" to "); layer_state = state; + hook_layer_change(layer_state); layer_debug(); dprintln(); +#ifdef NO_TRACK_KEY_PRESS clear_keyboard_but_mods(); // To avoid stuck keys +#endif } void layer_clear(void) @@ -112,27 +119,47 @@ void layer_debug(void) -action_t layer_switch_get_action(keypos_t key) +/* return layer effective for key at this time */ +static uint8_t current_layer_for_key(keypos_t key) { - action_t action; - action.code = ACTION_TRANSPARENT; - #ifndef NO_ACTION_LAYER + action_t action = ACTION_TRANSPARENT; uint32_t layers = layer_state | default_layer_state; /* check top layer first */ for (int8_t i = 31; i >= 0; i--) { if (layers & (1UL<