From ab19ebd08a8b955775e6fa94cdf6b8d128d8b43c Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Sat, 16 Apr 2016 18:51:58 -0400 Subject: MAGIC functionality, AG swap in default layout --- tmk_core/common/keyboard.c | 8 +++++++- tmk_core/common/keymap.h | 3 --- tmk_core/common/magic.c | 36 ++++++++++++++++++++++++++++++++++++ tmk_core/common/magic.h | 6 ++++++ 4 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 tmk_core/common/magic.c create mode 100644 tmk_core/common/magic.h (limited to 'tmk_core/common') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 302b3ec87..1d9981848 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -27,7 +27,11 @@ along with this program. If not, see . #include "command.h" #include "util.h" #include "sendchar.h" -#include "bootmagic.h" +#ifdef BOOTMAGIC_ENABLE + #include "bootmagic.h" +#else + #include "magic.h" +#endif #include "eeconfig.h" #include "backlight.h" #ifdef MOUSEKEY_ENABLE @@ -86,6 +90,8 @@ void keyboard_init(void) #ifdef BOOTMAGIC_ENABLE bootmagic(); +#else + magic(); #endif #ifdef BACKLIGHT_ENABLE diff --git a/tmk_core/common/keymap.h b/tmk_core/common/keymap.h index e1a6f992e..abc9bdb32 100644 --- a/tmk_core/common/keymap.h +++ b/tmk_core/common/keymap.h @@ -22,8 +22,6 @@ along with this program. If not, see . #include #include "action.h" - -#ifdef BOOTMAGIC_ENABLE /* NOTE: Not portable. Bit field order depends on implementation */ typedef union { uint8_t raw; @@ -39,7 +37,6 @@ typedef union { }; } keymap_config_t; keymap_config_t keymap_config; -#endif /* translates key to keycode */ diff --git a/tmk_core/common/magic.c b/tmk_core/common/magic.c new file mode 100644 index 000000000..f21d1346c --- /dev/null +++ b/tmk_core/common/magic.c @@ -0,0 +1,36 @@ +#include +#include +#include +#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; + +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(); + +#ifdef NKRO_ENABLE + keyboard_nkro = keymap_config.nkro; +#endif + + uint8_t default_layer = 0; + default_layer = eeconfig_read_default_layer(); + default_layer_set((uint32_t)default_layer); + +} \ No newline at end of file diff --git a/tmk_core/common/magic.h b/tmk_core/common/magic.h new file mode 100644 index 000000000..3fa2d8b81 --- /dev/null +++ b/tmk_core/common/magic.h @@ -0,0 +1,6 @@ +#ifndef MAGIC_H +#define MAGIC_H + +void magic(void); + +#endif -- cgit v1.2.3