]> git.friedersdorff.com Git - max/tmk_keyboard.git/blobdiff - tmk_core/common/action_layer.c
hhkb: Revise doc
[max/tmk_keyboard.git] / tmk_core / common / action_layer.c
index e6db388d9f92e3d3915e1be7cd794587389e5fb8..6b5a7fd2b83e9216939601cb5439ec65da459e86 100644 (file)
@@ -3,6 +3,7 @@
 #include "action.h"
 #include "util.h"
 #include "action_layer.h"
+#include "hook.h"
 
 #ifdef DEBUG_ACTION
 #include "debug.h"
@@ -21,6 +22,7 @@ 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");
     clear_keyboard_but_mods(); // To avoid stuck keys
 }
@@ -62,6 +64,7 @@ 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();
     clear_keyboard_but_mods(); // To avoid stuck keys
 }
@@ -114,7 +117,7 @@ void layer_debug(void)
 
 action_t layer_switch_get_action(keypos_t key)
 {
-    action_t action = { .code = ACTION_TRANSPARENT };
+    action_t action = ACTION_TRANSPARENT;
 
 #ifndef NO_ACTION_LAYER
     uint32_t layers = layer_state | default_layer_state;
@@ -122,7 +125,7 @@ action_t layer_switch_get_action(keypos_t key)
     for (int8_t i = 31; i >= 0; i--) {
         if (layers & (1UL<<i)) {
             action = action_for_key(i, key);
-            if (action.code != ACTION_TRANSPARENT) {
+            if (action.code != (action_t)ACTION_TRANSPARENT.code) {
                 return action;
             }
         }