aboutsummaryrefslogtreecommitdiff
path: root/quantum/bootmagic/magic.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/bootmagic/magic.c')
-rw-r--r--quantum/bootmagic/magic.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/quantum/bootmagic/magic.c b/quantum/bootmagic/magic.c
new file mode 100644
index 000000000..f1cb11c39
--- /dev/null
+++ b/quantum/bootmagic/magic.c
@@ -0,0 +1,54 @@
1/* Copyright 2021 QMK
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#include <stdint.h>
17#include <stdbool.h>
18#include "wait.h"
19#include "matrix.h"
20#include "bootloader.h"
21#include "debug.h"
22#include "keymap.h"
23#include "host.h"
24#include "action_layer.h"
25#include "eeconfig.h"
26#include "bootmagic.h"
27
28keymap_config_t keymap_config;
29
30__attribute__((weak)) void bootmagic(void) {}
31
32/** \brief Magic
33 *
34 * FIXME: Needs doc
35 */
36void magic(void) {
37 /* check signature */
38 if (!eeconfig_is_enabled()) {
39 eeconfig_init();
40 }
41
42 /* init globals */
43 debug_config.raw = eeconfig_read_debug();
44 keymap_config.raw = eeconfig_read_keymap();
45
46 bootmagic();
47
48 /* read here just incase bootmagic process changed its value */
49 layer_state_t default_layer = (layer_state_t)eeconfig_read_default_layer();
50 default_layer_set(default_layer);
51
52 /* Also initialize layer state to trigger callback functions for layer_state */
53 layer_state_set_kb((layer_state_t)layer_state);
54}