Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize Layer State on startup #8318

Merged
merged 4 commits into from
Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions tmk_core/common/action_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions tmk_core/common/bootmagic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
3 changes: 3 additions & 0 deletions tmk_core/common/magic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}