magic.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. keymap_config_t keymap_config;
  28. __attribute__((weak)) void bootmagic(void) {}
  29. /** \brief Magic
  30. *
  31. * FIXME: Needs doc
  32. */
  33. void magic(void) {
  34. /* check signature */
  35. if (!eeconfig_is_enabled()) {
  36. eeconfig_init();
  37. }
  38. /* init globals */
  39. debug_config.raw = eeconfig_read_debug();
  40. keymap_config.raw = eeconfig_read_keymap();
  41. bootmagic();
  42. /* read here just incase bootmagic process changed its value */
  43. layer_state_t default_layer = (layer_state_t)eeconfig_read_default_layer();
  44. default_layer_set(default_layer);
  45. /* Also initialize layer state to trigger callback functions for layer_state */
  46. layer_state_set_kb((layer_state_t)layer_state);
  47. }