1
0
Fork 0
forked from forks/qmk_firmware
qmk_firmware/tmk_core/common/magic.c
Drashna Jaelre e6266b19be 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
2020-08-29 14:30:02 -07:00

40 lines
878 B
C

#include <stdint.h>
#include <stdbool.h>
#if defined(__AVR__)
# include <util/delay.h>
#endif
#include "matrix.h"
#include "bootloader.h"
#include "debug.h"
#include "keymap.h"
#include "host.h"
#include "action_layer.h"
#include "eeconfig.h"
#include "magic.h"
keymap_config_t keymap_config;
/** \brief Magic
*
* FIXME: Needs doc
*/
void magic(void) {
/* check signature */
if (!eeconfig_is_enabled()) {
eeconfig_init();
}
/* debug enable */
debug_config.raw = eeconfig_read_debug();
/* keymap config */
keymap_config.raw = eeconfig_read_keymap();
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);
}