diff options
author | Drashna Jaelre <drashna@live.com> | 2020-07-27 14:46:39 -0700 |
---|---|---|
committer | James Young <18669334+noroadsleft@users.noreply.github.com> | 2020-08-29 14:30:02 -0700 |
commit | e6266b19be46c1340209bdd0a6c519452d5b9f2a (patch) | |
tree | 7463f3c351623667b7d4aff956ab0c34a40ee4b5 | |
parent | 4b74f985ec7b14f5517df4e591f0c36b24f85f5c (diff) |
Initialize Layer State on startup (#8318)
* Initialize Layer State on startup
Right now, on startup, the default layer state gets called and set, triggering the callback functions for the default layer state. However, the normal layer state never actually gets initialized. It's set to 0 directly, by default, but the callback functions are never actually called. This creates some inconsistency in the behavior for end users. This adds a simple "clear" that triggers the callback on startup. This should produce more consisten behavior between the two functions and layer masks.
* Stupid hack
* Fix type casting?
* Fix compile issues with magic is disabled
-rw-r--r-- | tmk_core/common/action_layer.h | 6 | ||||
-rw-r--r-- | tmk_core/common/bootmagic.c | 2 | ||||
-rw-r--r-- | tmk_core/common/magic.c | 3 |
3 files changed, 9 insertions, 2 deletions
diff --git a/tmk_core/common/action_layer.h b/tmk_core/common/action_layer.h index 16922c1ff9..9b9173c33b 100644 --- a/tmk_core/common/action_layer.h +++ b/tmk_core/common/action_layer.h @@ -85,6 +85,8 @@ void layer_invert(uint8_t layer); void layer_or(layer_state_t state); void layer_and(layer_state_t state); void layer_xor(layer_state_t state); +layer_state_t layer_state_set_user(layer_state_t state); +layer_state_t layer_state_set_kb(layer_state_t state); #else # define layer_state 0 @@ -101,10 +103,10 @@ void layer_xor(layer_state_t state); # define layer_or(state) (void)state # define layer_and(state) (void)state # define layer_xor(state) (void)state +# define layer_state_set_kb(state) (void)state +# define layer_state_set_user(state) (void)state #endif -layer_state_t layer_state_set_user(layer_state_t state); -layer_state_t layer_state_set_kb(layer_state_t state); /* pressed actions cache */ #if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE) diff --git a/tmk_core/common/bootmagic.c b/tmk_core/common/bootmagic.c index bb2aa0db8c..c1b3adf94d 100644 --- a/tmk_core/common/bootmagic.c +++ b/tmk_core/common/bootmagic.c @@ -122,6 +122,8 @@ void bootmagic(void) { default_layer = eeconfig_read_default_layer(); default_layer_set((layer_state_t)default_layer); } + /* Also initialize layer state to trigger callback functions for layer_state */ + layer_state_set_kb((layer_state_t)layer_state); /* EE_HANDS handedness */ if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EE_HANDS_LEFT)) { diff --git a/tmk_core/common/magic.c b/tmk_core/common/magic.c index d8ab525735..e14994164e 100644 --- a/tmk_core/common/magic.c +++ b/tmk_core/common/magic.c @@ -33,4 +33,7 @@ void magic(void) { uint8_t default_layer = 0; default_layer = eeconfig_read_default_layer(); default_layer_set((layer_state_t)default_layer); + + /* Also initialize layer state to trigger callback functions for layer_state */ + layer_state_set_kb((layer_state_t)layer_state); } |