X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;f=common%2Fbootmagic.c;h=b002a585622029f998a94adf8d95d2fa0ce7672b;hb=8f1e311cd7624d765901c69e61837db33a51928b;hp=716f5d956b6b9b2563446fd83f10a8c8e9d98203;hpb=e59fb6f908e3e05ed135bf6d004524b0b6bf9119;p=max%2Ftmk_keyboard.git diff --git a/common/bootmagic.c b/common/bootmagic.c index 716f5d95..b002a585 100644 --- a/common/bootmagic.c +++ b/common/bootmagic.c @@ -5,6 +5,8 @@ #include "bootloader.h" #include "debug.h" #include "keymap.h" +#include "host.h" +#include "action_layer.h" #include "eeconfig.h" #include "bootmagic.h" @@ -17,8 +19,10 @@ void bootmagic(void) } /* do scans in case of bounce */ + print("boogmagic scan: ... "); uint8_t scan = 100; while (scan--) { matrix_scan(); _delay_ms(10); } + print("done.\n"); /* bootmagic skip */ if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SKIP)) { @@ -52,7 +56,7 @@ void bootmagic(void) /* keymap config */ keymap_config.raw = eeconfig_read_keymap(); - if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_CONTROL_CPASLOCK)) { + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_CONTROL_CAPSLOCK)) { keymap_config.swap_control_capslock = !keymap_config.swap_control_capslock; } if (bootmagic_scan_keycode(BOOTMAGIC_KEY_CAPSLOCK_TO_CONTROL)) { @@ -73,16 +77,41 @@ void bootmagic(void) if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_BACKSLASH_BACKSPACE)) { keymap_config.swap_backslash_backspace = !keymap_config.swap_backslash_backspace; } + if (bootmagic_scan_keycode(BOOTMAGIC_HOST_NKRO)) { + keymap_config.nkro = !keymap_config.nkro; + } eeconfig_write_keymap(keymap_config.raw); + +#ifdef NKRO_ENABLE + keyboard_nkro = keymap_config.nkro; +#endif + + /* default layer */ + uint8_t default_layer = 0; + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_0)) { default_layer |= (1<<0); } + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_1)) { default_layer |= (1<<1); } + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_2)) { default_layer |= (1<<2); } + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_3)) { default_layer |= (1<<3); } + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_4)) { default_layer |= (1<<4); } + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_5)) { default_layer |= (1<<5); } + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_6)) { default_layer |= (1<<6); } + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_7)) { default_layer |= (1<<7); } + if (default_layer) { + eeconfig_write_default_layer(default_layer); + default_layer_set((uint32_t)default_layer); + } else { + default_layer = eeconfig_read_default_layer(); + default_layer_set((uint32_t)default_layer); + } } -bool bootmagic_scan_keycode(uint8_t keycode) +static bool scan_keycode(uint8_t keycode) { for (uint8_t r = 0; r < MATRIX_ROWS; r++) { matrix_row_t matrix_row = matrix_get_row(r); for (uint8_t c = 0; c < MATRIX_COLS; c++) { if (matrix_row & ((matrix_row_t)1<